0

I'm building for board nrf52833_pca10100 and nrf52840_pca10056.

changed toolchain by: export ZEPHYR_TOOLCHAIN_VARIANT=llvm I have llvm-8-dev, clang, clang-8 installed through apt. for ZEPHYR_TOOLCHAIN_VARIANT=zephyr, sample/basic/blinky can build and make fine. Once swapped to llvm, the following error happens at build:

-- The C compiler identification is Clang 6.0.0
-- The CXX compiler identification is Clang 6.0.0
-- The ASM compiler identification is Clang
-- Found assembler: /usr/bin/clang
-- Cache files will be written to: /root/.cache/zephyr 
CMake Error at ../../../cmake/extensions.cmake:1457 (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)


-- Configuring incomplete, errors occurred! See also "/home/zephyrproject/zephyr/samples/basic/blinky/test/CMakeFiles/CMakeOutput.log". 
See also "/home/zephyrproject/zephyr/samples/basic/blinky/test/CMakeFiles/CMakeError.log".

I can force this issue to not appear and build by feeding -D CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY when building. However, when I try to make, the following errors happen:

In file included from /home/zephyrproject/modules/hal/nordic/nrfx/mdk/nrf.h:164: /home/zephyrproject/modules/hal/nordic/nrfx/mdk/compiler_abstraction.h:154:16: warning:
      variable 'sp' is uninitialized when used here [-Wuninitialized]
        return sp;
               ^~ /home/zephyrproject/modules/hal/nordic/nrfx/mdk/compiler_abstraction.h:153:29: note:
      initialize the variable 'sp' to silence this warning
        register unsigned sp __ASM("sp");
                            ^
                             = 0 1 warning generated.

and at the very end of linking:

clang: warning: argument unused during compilation: '--specs=nosys.specs' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
clang: error: unable to execute command: Executable "ld.lld" doesn't exist!
clang: error: ld.lld command failed with exit code 1 (use -v to see invocation)
zephyr/CMakeFiles/zephyr_prebuilt.dir/build.make:100: recipe for target 'zephyr/zephyr_prebuilt.elf' failed
make[2]: *** [zephyr/zephyr_prebuilt.elf] Error 1
CMakeFiles/Makefile2:2133: recipe for target 'zephyr/CMakeFiles/zephyr_prebuilt.dir/all' failed
make[1]: *** [zephyr/CMakeFiles/zephyr_prebuilt.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Not sure what's wrong with it.

EDIT: more CMakeError.log content

Checking whether the ASM compiler is GNU using "--version" did not match "(GNU assembler)|(GCC)|(Free Software Foundation)":
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Performing C SOURCE FILE Test check_C__nostartfiles__nostdlib__isystem__usr_lib_llvm_6_0_lib_clang_6_0_0_include__isystem__usr_bin____lib_gcc_x86_64_linux_gnu_7_4_0_include_fixed__Wl___unresolved_symbols_ignore_in_object_files failed with the following output:
Change Dir: /home/akirakato/Desktop/ncs/zephyr/samples/basic/blinky/bc/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_11778/fast && /usr/bin/make -f CMakeFiles/cmTC_11778.dir/build.make CMakeFiles/cmTC_11778.dir/build
make[1]: Entering directory '/home/akirakato/Desktop/ncs/zephyr/samples/basic/blinky/bc/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_11778.dir/src.c.obj/usr/bin/clang --target=arm-none-eabi   -Dcheck_C__nostartfiles__nostdlib__isystem__usr_lib_llvm_6_0_lib_clang_6_0_0_include__isystem__usr_bin____lib_gcc_x86_64_linux_gnu_7_4_0_include_fixed__Wl___unresolved_symbols_ignore_in_object_files -nostartfiles -nostdlib -isystem /usr/lib/llvm-6.0/lib/clang/6.0.0/include -isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/include-fixed -Wl,--unresolved-symbols=ignore-in-object-files   -o CMakeFiles/cmTC_11778.dir/src.c.obj   -c /home/akirakato/Desktop/ncs/zephyr/samples/basic/blinky/bc/CMakeFiles/CMakeTmp/src.c
clang: warning: -Wl,--unresolved-symbols=ignore-in-object-files: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-nostartfiles' [-Wunused-command-line-argument]
Linking C executable cmTC_11778
/snap/cmake/237/bin/cmake -E cmake_link_script CMakeFiles/cmTC_11778.dir/link.txt --verbose=1
/usr/bin/clang --target=arm-none-eabi  -Dcheck_C__nostartfiles__nostdlib__isystem__usr_lib_llvm_6_0_lib_clang_6_0_0_include__isystem__usr_bin____lib_gcc_x86_64_linux_gnu_7_4_0_include_fixed__Wl___unresolved_symbols_ignore_in_object_files -nostartfiles -nostdlib -isystem /usr/lib/llvm-6.0/lib/clang/6.0.0/include -isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/include-fixed -Wl,--unresolved-symbols=ignore-in-object-files  --specs=nosys.specs  CMakeFiles/cmTC_11778.dir/src.c.obj  -o cmTC_11778
clang: warning: argument unused during compilation: '-nostartfiles' [Wunused-command-line-argument]
clang: warning: argument unused during compilation: '--specs=nosys.specs' [-Wunused-command-line-argument]
clang: error: unable to execute command: Executable "ld.lld" doesn't exist!
clang: error: ld.lld command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_11778.dir/build.make:86: recipe for target 'cmTC_11778' failed
make[1]: \*\*\* [cmTC_11778] Error 1
make[1]: Leaving directory '/home/akirakato/Desktop/ncs/zephyr/samples/basic/blinky/bc/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_11778/fast' failed
make: *** [cmTC_11778/fast] Error 2


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

I'm starting to suspect it's the clang 6 issue and that I need to use clang 8+, saw a post about clang fixing their issues which was after release date of clang 6. Not sure how to change which clang zephyr picks though.

Anarchira
  • 13
  • 7
  • Please, do not use *blockquote formatting* for logs: this formatting doesn't preserve newlines which makes the logs harder to read. Use **code formatting** instead. – Tsyvarev Jan 29 '20 at 22:11
  • Googling for the "warning: argument unused during compilation: '--specs=nosys.specs'" finds [that question](https://stackoverflow.com/questions/59089857/ld-lld-command-failed-when-build-the-hello-world-sample-in-zephyr-using-clang6-0) and [that bugreport](https://github.com/vpetrigo/arm-cmake-toolchains/issues/4). The only answer to the question says that ARM is not supported by clang. But bugreport tells that the problem was in the CMake toolchain for ARM and it has been finally fixed. – Tsyvarev Jan 29 '20 at 22:20
  • @Tsyvarev I saw that post too. I thought it was supported so must be something wrong with my set up. I noticed zephyr installs llvm 6 by default and I have manually installed llvm 8 through apt. I tried changing the paths and which clang for zephyr to work with but both fail same problem. – Anarchira Jan 29 '20 at 22:26
  • I added the CMakeError.log content too – Anarchira Jan 30 '20 at 14:52
  • I have also tried using clang-8. The build error goes away without the CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY work around, whether that's because it suppresses, builds ld.lld or finds it I don't know. However, same exact error when "make". – Anarchira Jan 30 '20 at 19:20

0 Answers0