kraj/meta-clang

dunfell: compiler-rt: invalid argument causes sanity check to fail

Opened this issue · 2 comments

Describe the bug
When using dunfell-clang12 branch with latest poky:dunfell and meta-oe:dunfell, compiler-rt fails to build.
Failure is caused by invalid argument '-fno-diagnostics-show-caret'.

To Reproduce
Steps to reproduce the behavior:

  1. Create build as above, enable ICECC.bbclass from poky
  2. bitbake clang
  3. bitbake compiler-rt
  4. See error

Expected behavior
Build to succeed

Error:

| DEBUG: Executing shell function do_configure
| WARNING: Cannot use icecc: could not get ICECC_CC or ICECC_CXX
| -- The C compiler identification is Clang 12.0.0
| -- The CXX compiler identification is Clang 12.0.0
| -- The ASM compiler identification is Clang
| -- Found assembler: /home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-clang
| -- Check for working C compiler: /home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-clang
| -- Check for working C compiler: /home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-clang -- broken
| CMake Error at /home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
|   The C compiler
| 
|     "/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-clang"
| 
|   is not able to compile a simple test program.
| 
|   It fails with the following output:
| 
|     Change Dir: /home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/build/CMakeFiles/CMakeTmp
| 
|     Run Build Command(s):ninja cmTC_c3989 && [1/2] Building C object CMakeFiles/cmTC_c3989.dir/testCCompiler.c.o
|     FAILED: CMakeFiles/cmTC_c3989.dir/testCCompiler.c.o
|     /home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-clang   -target aarch64-poky-linux  -mcpu=cortex-a72+crc+crypto   -mlittle-endian -Qunused-arguments -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0=/usr/src/debug/compiler-rt/12.0.0-r0                      -fdebug-prefix-map=/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0=/usr/src/debug/compiler-rt/12.0.0-r0                      -fdebug-prefix-map=/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot=                      -fdebug-prefix-map=/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot-native=  -fno-diagnostics-show-caret -target aarch64-poky-linux  -mcpu=cortex-a72+crc+crypto   -mlittle-endian -Qunused-arguments -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/recipe-sysroot -o CMakeFiles/cmTC_c3989.dir/testCCompiler.c.o   -c testCCompiler.c
|     clang-12: error: unknown argument: '-fno-diagnostics-show-caret'
|     ninja: build stopped: subcommand failed.
| 
| 
| 
| 
| 
|   CMake will not be able to correctly generate this project.
| Call Stack (most recent call first):
|   CMakeLists.txt:38 (project)
| 
| 
| -- Configuring incomplete, errors occurred!
| See also "/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/build/CMakeFiles/CMakeOutput.log".
| See also "/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/build/CMakeFiles/CMakeError.log".
| WARNING: exit code 1 from a shell command.
| ERROR: Execution of '/home/ryan/workspace/apollo/build/tmp/work/aarch64-poky-linux/compiler-rt/12.0.0-r0/temp/run.do_configure.1580698' failed with exit code 1
ERROR: Task (/home/ryan/workspace/apollo/sources/meta-clang/recipes-devtools/clang/compiler-rt_git.bb:do_configure) failed with exit code '1'

This issue is the same with libcxx.

WORKAROUND:
Add compiler-rt, libcxx (maybe more) to ICECC_SYSTEM_PACKAGE_BL in local.conf
Then clean the packages with bitbake -c clean and recompile.

I've narrowed this down to ICECC setting -fno-diagnostics-show-caret.
Adding compiler-rt to ICECC_SYSTEM_PACKAGE_BL resolved the issue.
Could also set CFLAGS_append=" -Wno-error=unused-command-line-argument" for the same effect and allow distributed build.

kraj commented

clang's option for similar effect is -fno-caret-diagnostics so somewhere ICECC needs to understand clang or gcc being the compiler. I dont know what we can do in meta-clang for this.