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.

  • Hi,

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

    Which source file is this? Could you zip me the project you've been using to recreate this?

    This does not quite look like standard setup of the SDK, so I believe that you might be better off with a complete pristine installation (not separately reinstallation of either toolchain and SDK). I.e what I suggest that you do is

    1. Uninstall VS Code
    2. Remove nRF Command line tools
    3. Remove nrfutil/nrfjprog and nRF Command line tools from PATH
    4. Uninstall and remove all of your nRF Connect SDK instances and start from https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-1-nrf-connect-sdk-introduction/topic/exercise-1-1/ or https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/installation/install_ncs.html 

    Let me know about the zip file and if you could go through the links supplied to see if you've missed anything.

    Kind regards,
    Andreas

  • Hi,

    It's literally just the Blinky sample, but yes, I can send it to you.

    I'm going to uninstall VS Code and follow your suggestions, I'm gonna tell you the result.

    Thanks,
    Victor

    blinky_sample.zip

  • Ah, so the following did not refer to the sample code

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

    Good to verify. It looked like it could've been a modified blinky sample. Let me know about the reinstallation procedure. 

    After you've set it up, if you could also try to build blinky or hello_world with the SDK repository you're using in the workspace (2.6.1 instead of the 2.7.0-rc2 which I currently had up)

    As well as make sure that the Toolchain and SDK is set in the extension:

    I'm also curious as to how your VS Code extension list looks like, i.e if there is a conflict between MS-CMake and the CMake that the installation procedure sets up, and/or if you have a different priority between these two CMake instances in your system variable PATH

    Kind regards,
    Andreas

  • I've reinstalled VS Code and follow the guide you send before to reinstall the toolchain, the sdk, etc...

    I selected the 2.6.1 version as you asked

    Concerning the extension, I only have the nRF Connect for VS Code extension pack installed as you can see in this screenshot

    Now when I'm trying to build using the extension, this little wheel spins for like 3min right now without producing any output to the terminal.

    It's not even the build that's blocking, it's the creation of the build configuration (I tried with unchecked Build after generating configuration)

    I tried to cancel it and build with the command line using:
    west -v build -b nrf52840dk_nrf52840

    The result are the same that I described in the ticket:

    "The toolchain is unable to build a dummy C file"
    And the CMakeError.log says "undefined reference to `_exit()`" and then "ninja: build stopped: subcommand failed"

  • Noted,

    Atleast now we've verified that it should not be the installation thats wrong, but there may still be something else going on with the setup.

    1. Could you verify that you have nRF Command line tools in system variable PATH? I.e something like C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin\ should be present.
    2. Could you open the developer tools in VS Code and see if there are any errors there? You can open it from the command pallet
    3. Could you also generate support information in the command pallett and attach the output here?

    Kind regards,
    Andreas

Related