This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

The toolchain is unable to build a dummy C file

Evaluating nRF53 PDK. Trying to build basic samples from zephyr repo as advised here - https://devzone.nordicsemi.com/f/nordic-q-a/54451/nrf5340-support-in-nrf-connect-sdk-and-zephyr/220309#220309

Both the command line 'west' command and SES project import results in the same outcome.

Configuration saved to '/Users/.../ncs/zephyr/samples/bluetooth/hci_rpmsg/build/zephyr/.config'
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /Users/.../gnuarmemb/bin/arm-none-eabi-gcc
CMake Error at ../../../cmake/extensions.cmake:1462 (message):
Assertion failed: The toolchain is unable to build a dummy C file. See
CMakeError.log.
Call Stack (most recent call first):
../../../CMakeLists.txt:42 (assert)

which says in the error of the CMakeError.log that

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /Users/.../gnuarmemb/bin/arm-none-eabi-gcc
Build flags:
Id flags:

The output was:
1
/Users/.../gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: /Users/...s/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
collect2: error: ld returned 1 exit status

I would try to specify something like https://stackoverflow.com/questions/19419782/exit-c-text0x18-undefined-reference-to-exit-when-using-arm-none-eabi-gcc but I am fairly novice in zephyr projects.

Parents
  • So --specs=nosys.specs works.

    I tried to do a dummy linking manually inside the build/CMakeFiles/3.14.5/CompilerIdC directory.

    ➜ CompilerIdC git:(b687d5d022) ✗ pwd
    .../ncs/zephyr/samples/bluetooth/hci_rpmsg/build/CMakeFiles/3.14.5/CompilerIdC
    ➜ CompilerIdC git:(b687d5d022) ✗ ll
    total 48
    -rw-r--r-- 1 svenkautlenbach staff 20K Dec 11 21:24 CMakeCCompilerId.c
    -rw-r--r-- 1 svenkautlenbach staff 1.6K Dec 11 21:24 CMakeCCompilerId.o
    drwxr-xr-x 2 svenkautlenbach staff 64B Dec 11 21:24 tmp
    ➜ CompilerIdC git:(b687d5d022) ✗ arm-none-eabi-gcc -o tere CMakeCCompilerId.c
    /Users/svenkautlenbach/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: /Users/svenkautlenbach/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x2c): undefined reference to `_exit'
    collect2: error: ld returned 1 exit status
    ➜ CompilerIdC git:(b687d5d022) ✗ arm-none-eabi-gcc --specs=nosys.specs -o tere CMakeCCompilerId.c
    ➜ CompilerIdC git:(b687d5d022) ✗

    So am I missing something important in build system or should I modify build system files then ?

  • You can also add the following line to wherever the toolchain is defined:

    # Perform compiler test without linker, since we're cross-compiling
    set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
  • Yup. First in modern CMake one should operate on target bases, not on some set({global}), so I should prefer that way, would need to learn the CMake tree in zypher projects anyway with both approaches. Second, why is this happening to my setup, since this is a dummy compilation it should happen with every board, so I believe it should not be anything specific to nRF53.

  • Could you define "wherever the toolchain is defined" better, please?

Reply Children
No Data
Related