Unable to build any sample on Windows 10 - Assertion failed: The toolchain is unable to build a dummy C file.

Hi,

I've just received a nRF52840 DK and I'm trying to build and flash the blinky sample on it but the build failed continuously.

I also tried with other sample like the hello_world but it's exactly the same.

My setup

Windows 10 x64 10.0.19045
Visual Studio Code 1.90.2
nRF Connect for VS Code v2024.3.25
Toolchain (installed with the extension) 2.6.1 & 2.4.3
SDK (installed with the extension) 2.6.1 & 2.4.3
Zephyr 3.9.9
West 1.0.0
CMake 3.20.5
Ninja 1.9.0
Board nRF52840 DK

The steps I did

After installing everything with the nRF Connect for VS Code extension:

  1. Select the toolchain and the west workspace (already did by the extension)
  2. Create a new application
    1. Copy a sample
    2. Search and select Blinky Sample
  3. Add build configuration
    1. Select prj.conf in the Configuration input
  4. Build

It failed (describe below)

In Manage toolchains menu, Validate Toolchain say that No issues were detected with the toolchain

My Problem

After everything was installed, I tried to build the blinky sample to test if every thing work perfectly.

The first time, I'm trying to build the application (first time or after moving/deleting zephyr/.cache/ folder and the build/ directory, it threw me this error:

...
Kconfig header saved to 'C:/ncs/v2.4.3/blinky_sample/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
CMake Error at C:/ncs/v2.4.3/zephyr/cmake/modules/extensions.cmake:2161 (message):
Assertion failed: The toolchain is unable to build a dummy C file. See
CMakeError.log.
Call Stack (most recent call first):
C:/ncs/v2.4.3/zephyr/cmake/modules/kernel.cmake:145 (assert)
C:/ncs/v2.4.3/zephyr/cmake/modules/zephyr_default.cmake:124 (include)
C:/ncs/v2.4.3/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
C:/ncs/v2.4.3/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/ncs/v2.4.3/blinky_sample/build/CMakeFiles/CMakeOutput.log".
See also "C:/ncs/v2.4.3/blinky_sample/build/CMakeFiles/CMakeError.log".
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/31f4403e35/opt/bin/python.exe '-Bc:\ncs\v2.4.3\blinky_sample\build' -GNinja -DBOARD=nrf52840dk_nrf52840 -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=c:/ncs/v2.4.3/blinky_sample/prj.conf '-Sc:\ncs\v2.4.3\blinky_sample'

And this CMakeError.log:

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
Build flags:
Id flags:

The output was:
1
c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x34): undefined reference to `_exit'
collect2.exe: error: ld returned 1 exit status


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
Build flags:
Id flags:

The output was:
1
c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x34): undefined reference to `_exit'
collect2.exe: error: ld returned 1 exit status


Performing C SOURCE FILE Test check_C__nostartfiles__nostdlib__isystem__c__ncs_toolchains_31f4403e35_opt_zephyr_sdk_arm_zephyr_eabi_bin____lib_gcc_arm_zephyr_eabi_12_2_0_include___isystem__c__ncs_toolchains_31f4403e35_opt_zephyr_sdk_arm_zephyr_eabi_bin____lib_gcc_arm_zephyr_eabi_12_2_0_include_fixed___Wl___unresolved_symbols_ignore_in_object_files__Wl___entry_0 failed with the following output:
Change Dir: C:/ncs/v2.4.3/blinky_sample/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/ncs/toolchains/31f4403e35/opt/bin/ninja.exe cmTC_8e26f && [1/2] Building C object CMakeFiles/cmTC_8e26f.dir/src.c.obj
[2/2] Linking C executable cmTC_8e26f
FAILED: cmTC_8e26f
cmd.exe /C "cd . && C:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -nostartfiles -nostdlib -isystem "c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include" -isystem "c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include-fixed" -Wl,--unresolved-symbols=ignore-in-object-files -Wl,--entry=0 CMakeFiles/cmTC_8e26f.dir/src.c.obj -o cmTC_8e26f && cd ."
The filename, directory name, or volume label syntax is incorrect.
ninja: build stopped: subcommand failed.


Source file was:
int main(void) { return 0; }

Every time after this first try give me this error in the terminal (CMakeError.log didn't change) :

Building blinky_sample
C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir c:/ncs/v2.4.3/blinky_sample/build c:/ncs/v2.4.3/blinky_sample"

ninja: error: loading 'build.ninja': The system cannot find the file specified.


FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE' --build 'c:\ncs\v2.4.3\blinky_sample\build'

I tried to fix this error by adding a dummy _exit() implementation (litteraly void _exit() {} and an header file) to the libc.a mentioned in the log.

After this "fix", when building the application using the extension, I got this error (terminal):

...

Kconfig header saved to 'C:/ncs/v2.4.3/blinky_sample/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
CMake Error at C:/ncs/v2.4.3/zephyr/cmake/modules/extensions.cmake:2161 (message):
Assertion failed: The toolchain is unable to build a dummy C file. See
CMakeError.log.
Call Stack (most recent call first):
C:/ncs/v2.4.3/zephyr/cmake/modules/kernel.cmake:145 (assert)
C:/ncs/v2.4.3/zephyr/cmake/modules/zephyr_default.cmake:124 (include)
C:/ncs/v2.4.3/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
C:/ncs/v2.4.3/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/ncs/v2.4.3/blinky_sample/build/CMakeFiles/CMakeOutput.log".
See also "C:/ncs/v2.4.3/blinky_sample/build/CMakeFiles/CMakeError.log".
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/31f4403e35/opt/bin/python.exe '-Bc:\ncs\v2.4.3\blinky_sample\build' -GNinja -DBOARD=nrf52840dk_nrf52840 -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=c:/ncs/v2.4.3/blinky_sample/prj.conf '-Sc:\ncs\v2.4.3\blinky_sample'

The CMakeError.log file contains this:

Performing C SOURCE FILE Test check_C__nostartfiles__nostdlib__isystem__c__ncs_toolchains_31f4403e35_opt_zephyr_sdk_arm_zephyr_eabi_bin____lib_gcc_arm_zephyr_eabi_12_2_0_include___isystem__c__ncs_toolchains_31f4403e35_opt_zephyr_sdk_arm_zephyr_eabi_bin____lib_gcc_arm_zephyr_eabi_12_2_0_include_fixed___Wl___unresolved_symbols_ignore_in_object_files__Wl___entry_0 failed with the following output:
Change Dir: C:/ncs/v2.4.3/blinky_sample/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/ncs/toolchains/31f4403e35/opt/bin/ninja.exe cmTC_2a3f4 && [1/2] Building C object CMakeFiles/cmTC_2a3f4.dir/src.c.obj
[2/2] Linking C executable cmTC_2a3f4
FAILED: cmTC_2a3f4
cmd.exe /C "cd . && C:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -nostartfiles -nostdlib -isystem "c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include" -isystem "c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include-fixed" -Wl,--unresolved-symbols=ignore-in-object-files -Wl,--entry=0 CMakeFiles/cmTC_2a3f4.dir/src.c.obj -o cmTC_2a3f4 && cd ."
The filename, directory name, or volume label syntax is incorrect.
ninja: build stopped: subcommand failed.


Source file was:
int main(void) { return 0; }

If I rebuild instantly, it throw me the same error with ninja: error: loading 'build.ninja': The system cannot find the file specified.

Moving the zephyr/.cache/ directory and/or deleting the build/ folder doesn't change anything at all (except restarting from the beginning of this ticket).

I've tried with different versions of the toolchain (v2.6.1 and v2.4.3), totally reinstall either the toolchain and the SDK, tried to install it with the nRF Connect for Desktop application and the Toolchain Manager that is provide in this application but nothing changed.

Thank for reading this, let me know if you need more information.

Parents Reply Children
Related