我正在为板 nrf52833_pca10100 和 nrf52840_pca10056 构建。
通过以下方式更改工具链:export ZEPHYR_TOOLCHAIN_VARIANT=llvm 我通过 apt 安装了 llvm-8-dev、clang、clang-8。对于 ZEPHYR_TOOLCHAIN_VARIANT=zephyr,sample/basic/blinky 可以构建并制作得很好。切换到 llvm 后,构建时会出现以下错误:
-- 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".
我可以通过在构建时喂食来强制这个问题不出现和构建-D CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
。但是,当我尝试制作时,会发生以下错误:
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.
并在链接的最后:
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
不知道有什么问题。
编辑:更多 CMakeError.log 内容
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; }
我开始怀疑这是clang 6的问题,我需要使用clang 8+,看到一篇关于clang修复他们的问题的帖子是在clang 6的发布日期之后。不知道如何更改哪个clang zephyr选择。