Unable to compile native - RIOT/core/assert.c:21:9: error: expected ‘;’ before ‘void’

I am trying to compile RIOT on a new ubuntu 22.04 and I get some weird errors. Any help would be appreciated.

make all -C examples/default/
make: Entering directory '/home/ichatz/Local/RIOT/examples/default'
Building application "default" for "native" with MCU "native".

"make" -C /home/ichatz/Local/RIOT/boards/common/init
"make" -C /home/ichatz/Local/RIOT/boards/native
"make" -C /home/ichatz/Local/RIOT/boards/native/drivers
"make" -C /home/ichatz/Local/RIOT/core
/home/ichatz/Local/RIOT/core/assert.c:21:9: error: expected ‘;’ before ‘void’
   21 | NORETURN void _assert_failure(const char *file, unsigned line)
      |         ^~~~~
      |         ;
/home/ichatz/Local/RIOT/core/assert.c: In function ‘_assert_failure’:
/home/ichatz/Local/RIOT/core/assert.c:24:5: error: implicit declaration of function ‘core_panic’ [-Werror=implicit-function-declaration]
   24 |     core_panic(PANIC_ASSERT_FAIL, assert_crash_message); \
      |     ^~~~~~~~~~
/home/ichatz/Local/RIOT/core/assert.c:24:16: error: ‘PANIC_ASSERT_FAIL’ undeclared (first use in this function)
   24 |     core_panic(PANIC_ASSERT_FAIL, assert_crash_message); \
      |                ^~~~~~~~~~~~~~~~~
/home/ichatz/Local/RIOT/core/assert.c:24:16: note: each undeclared identifier is reported only once for each function it appears in
/home/ichatz/Local/RIOT/core/assert.c:24:35: error: ‘assert_crash_message’ undeclared (first use in this function)
   24 |     core_panic(PANIC_ASSERT_FAIL, assert_crash_message); \
      |                                   ^~~~~~~~~~~~~~~~~~~~
/home/ichatz/Local/RIOT/core/assert.c:25:1: error: ‘noreturn’ function does return [-Werror]
   25 | }
      | ^
cc1: all warnings being treated as errors
make[2]: *** [/home/ichatz/Local/RIOT/Makefile.base:146: /home/ichatz/Local/RIOT/examples/default/bin/native/core/assert.o] Error 1
make[1]: *** [/home/ichatz/Local/RIOT/Makefile.base:31: ALL--/home/ichatz/Local/RIOT/core] Error 2
make: *** [/home/ichatz/Local/RIOT/examples/default/../../Makefile.include:749: application_default.module] Error 2
make: Leaving directory '/home/ichatz/Local/RIOT/examples/default'

Here are some info on my system:

make print-versions

Operating System Environment
----------------------------
         Operating System: "Ubuntu" "22.04.1 LTS (Jammy Jellyfish)"
                   Kernel: Linux 5.15.0-58-generic x86_64 x86_64
             System shell: /usr/bin/dash (probably dash)
             make's shell: /usr/bin/dash (probably dash)

Installed compiler toolchains
-----------------------------
               native gcc: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
        arm-none-eabi-gcc: arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1 20210621 (release)
                  avr-gcc: missing
           msp430-elf-gcc: missing
       riscv-none-elf-gcc: missing
  riscv64-unknown-elf-gcc: missing
     riscv-none-embed-gcc: missing
     xtensa-esp32-elf-gcc: xtensa-esp32-elf-gcc (crosstool-NG esp-2022r1) 11.2.0
   xtensa-esp8266-elf-gcc: missing
                    clang: missing

Installed compiler libs
-----------------------
     arm-none-eabi-newlib: "3.3.0"
        msp430-elf-newlib: missing
    riscv-none-elf-newlib: missing
riscv64-unknown-elf-newlib: missing
  riscv-none-embed-newlib: missing
  xtensa-esp32-elf-newlib: "4.1.0"
xtensa-esp8266-elf-newlib: missing
                 avr-libc: missing (missing)

Installed development tools
---------------------------
                   ccache: ccache version 4.5.1
                    cmake: cmake version 3.22.1
                 cppcheck: missing
                  doxygen: 1.9.1
                      git: git version 2.34.1
                     make: GNU Make 4.3
                  openocd: Open On-Chip Debugger v0.11.0-esp32-20221026 (2022-10-26-14:47)
                   python: Python 3.10.6
                  python2: missing
                  python3: Python 3.10.6
                   flake8: error: /home/ichatz/.espressif/python_env/idf5.1_py3.10_env/bin/python3: No module named flake8
               coccinelle: missing

Quick update: I used the docker image to build the example but I am getting the same error. I notice that in both docker and native system gcc is v11.

sudo docker run --rm -i -t -u $UID -v $(pwd):/data/riotbuild riot/riotbuild make print-versions

Operating System Environment
----------------------------
         Operating System: "Ubuntu" "22.04.1 LTS (Jammy Jellyfish)"
                   Kernel: Linux 5.15.0-58-generic x86_64 x86_64
             System shell: /usr/bin/dash (probably dash)
             make's shell: /usr/bin/dash (probably dash)

Installed compiler toolchains
-----------------------------
               native gcc: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
        arm-none-eabi-gcc: arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)
                  avr-gcc: avr-gcc (GCC) 5.4.0
           msp430-elf-gcc: msp430-elf-gcc (GCC) 10.1.0
       riscv-none-elf-gcc: missing
  riscv64-unknown-elf-gcc: missing
     riscv-none-embed-gcc: riscv-none-embed-gcc (xPack GNU RISC-V Embedded GCC x86_64) 10.2.0
     xtensa-esp32-elf-gcc: xtensa-esp32-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0
   xtensa-esp8266-elf-gcc: xtensa-esp8266-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a5) 5.2.0
                    clang: Ubuntu clang version 14.0.0-1ubuntu1

Installed compiler libs
-----------------------
     arm-none-eabi-newlib: "4.1.0"
        msp430-elf-newlib: "3.3.0"
    riscv-none-elf-newlib: missing
riscv64-unknown-elf-newlib: missing
  riscv-none-embed-newlib: "4.1.0"
  xtensa-esp32-elf-newlib: "3.3.0"
xtensa-esp8266-elf-newlib: "2.2.0"
                 avr-libc: "2.0.0" ("20150208")

Installed development tools
---------------------------
                   ccache: ccache version 4.5.1
                    cmake: cmake version 3.22.1
                 cppcheck: Cppcheck 2.7
                  doxygen: 1.9.1
                      git: git version 2.34.1
                     make: GNU Make 4.3
                  openocd: missing
                   python: missing
                  python2: Python 2.7.18
                  python3: Python 3.10.6
                   flake8: 3.8.4 (mccabe: 0.6.1, pycodestyle: 2.6.0, pyflakes: 2.2.0) CPython 3.10.6 on
               coccinelle: spatch version 1.1.1 compiled with OCaml version 4.13.1

Hmm, I was not able to reproduce locally (older version though) or with docker.

Does it happen with examples/hello-world as well or with a board different than native?

I’m not in front of a computer at the moment, but I wagger a guess that it has to do with how NORETURN is defined. My guess is that it is defined differently depending on the version of gcc. Try git grep NORETURN for some clues perhaps…

At the end, I started from a clean clone of the RIOT repo and the problem was resolved. I had to manually move the changed files, but that was easier than debugging the error. Thanks for the help.

hmm, strange, thanks for posting your solution.