Skip to content

Compiling with gcc 15 and UNREACHABLE_CODE, NORETURN errors #338

Open

Description

@andreasbaumann

Seems newer compilers can actually reach UNREACHABLE_CODE and complain about
it not being defined anywhere (on Archlinux, gcc 15.2.1):

util/LLgen/src/gencode.c: In function ‘prset’:
util/LLgen/src/gencode.c:463:9: error: ‘UNREACHABLE_CODE’ undeclared (first use in this function)
  463 |         UNREACHABLE_CODE;
      |         ^~~~~~~~~~~~~~~~
util/LLgen/src/gencode.c:463:9: note: each undeclared identifier is reported only once for each function it appears in
[27/9927] HOSTCC util/LLgen/+LLgen/util/LLgen/src/LLgen.c

Also there are warnings about NORETURN:

    In file included from modules/src/data/warnings.c:4:
.obj/modules/src/data/+data_hdr/warnings.h:7:16: error: expected ‘;’ before ‘void’
    7 | extern NORETURN void fatal(const char* fmt, ...);
      |                ^~~~~
      |                ;

I was able to build it with minimal (actually no) code changes by setting::

make CFLAGS='-DUNREACHABLE_CODE="__builtin_unreachable()" -DNORETURN="__attribute__((noreturn))"'

Not sure, if this needs any real fix inside the code itself. Maybe it's enough that other
people see a workaround in this bug when building with newer compilers?

Activity

  1. changed the title [-]Compiling with gcc 15 and UNREACHABLE_CODE, UNUSED errors[/-] [+]Compiling with gcc 15 and UNREACHABLE_CODE, NORETURN errors[/+] on Sep 4, 2025
  2. davidgiven commented on Sep 4, 2025

    @davidgiven
    Owner

    You don't have CFLAGS defined in the environment, do you? If so, that'll be overriding the definition in the Makefile. I should change it so that the two necessary defines are always added to CFLAGS.

  3. andreasbaumann commented on Sep 4, 2025

    @andreasbaumann
    Author

    I'm explicitely overwriting them (because of something else):

    https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ack-git#n29

  4. davidgiven commented on Sep 4, 2025

    @davidgiven
    Owner

    After some fiddling, the magic in the Makefile is:

    CFLAGS ?= -g -Os \
            -Werror=return-type \
            -Werror=implicit-function-declaration \
            -Werror=strict-prototypes
    
    override CFLAGS += \
            -DUNREACHABLE_CODE='__builtin_unreachable()' \
            -DNORETURN=_Noreturn
    

    But really the two special definitions should be added in the build.py. I'll fix that.

  5. andreasbaumann commented on Sep 4, 2025

    @andreasbaumann
    Author

    Ok, thanks. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions