Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linkage error with Clang compiler #938

Open
drula opened this issue Apr 18, 2024 · 2 comments
Open

Linkage error with Clang compiler #938

drula opened this issue Apr 18, 2024 · 2 comments

Comments

@drula
Copy link

drula commented Apr 18, 2024

I'm trying to use Clang for my C++ project in Yocto. I've added the following to the recipe for my project:

TOOLCHAIN = "clang"
TC_CXX_RUNTIME = "llvm"

But I got an error during the configuration of the C++ compiler: cannot find crtbeginS.o and -lgcc.

ERROR: compiler-rt-17.0.6-r0 do_configure: ExecutionError('/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/temp/run.do_configure.23915', 1, None, None)
ERROR: Logfile of failure stored in: /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/temp/log.do_configure.23915
Log data follows:
| DEBUG: Executing python function extend_recipe_sysroot
| NOTE: Direct dependencies are ['/path/to/src/lfs-core/meta-clang/recipes-devtools/clang/clang-cross_git.bb:do_populate_sysroot', '/path/to/src/lfs-core/src/poky/../../meta-lfs-core-poky/recipes-devtools/gcc12/gcc-runtime_12.2.bb:do_populate_sysroot', '/path/to/src/lfs-core/src/poky/../../meta-lfs-core-poky/recipes-devtools/gcc12/libgcc_12.2.bb:do_populate_sysroot', '/path/to/src/lfs-core/src/poky/../../meta-lfs-core-upstream/recipes-core/glibc/glibc_2.35.bb:do_populate_sysroot', '/path/to/src/lfs-core/src/poky/meta/recipes-devtools/cmake/cmake-native_3.22.3.bb:do_populate_sysroot', '/path/to/src/lfs-core/src/poky/meta/recipes-devtools/quilt/quilt-native_0.67.bb:do_populate_sysroot', 'virtual:native:/path/to/src/lfs-core/src/poky/../../meta-lfs-core-poky/recipes-devtools/python/python3_3.10.13.bb:do_populate_sysroot', 'virtual:native:/path/to/src/lfs-core/src/poky/meta/recipes-devtools/ninja/ninja_1.10.2.bb:do_populate_sysroot', 'virtual:native:/path/to/src/lfs-core/src/poky/meta/recipes-devtools/patch/patch_2.7.6.bb:do_populate_sysroot', 'virtual:native:/path/to/src/lfs-core/src/poky/meta/recipes-devtools/pkgconfig/pkgconfig_git.bb:do_populate_sysroot', 'virtual:native:/path/to/src/lfs-core/src/poky/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot']
| NOTE: Installed into sysroot: []
| NOTE: Skipping as already exists in sysroot: ['clang-cross-aarch64', 'gcc-runtime', 'libgcc', 'glibc', 'cmake-native', 'quilt-native', 'python3-native', 'ninja-native', 'patch-native', 'pkgconfig-native', 'pseudo-native', 'bzip2-native', 'zlib-native', 'curl-native', 'zstd-native', 'ncurses-native', 'xz-native', 're2c-native', 'clang-native', 'binutils-cross-aarch64', 'linux-libc-headers', 'openssl-native', 'sqlite3-native', 'libffi-native', 'util-linux-native', 'gdbm-native', 'libtool-native', 'libtirpc-native', 'readline-native', 'libnsl2-native', 'attr-native', 'gettext-minimal-native', 'binutils-native', 'swig-native', 'libxml2-native', 'libedit-native', 'texinfo-dummy-native', 'gnu-config-native', 'flex-native', 'perl-native', 'gettext-native', 'lzo-native', 'libpcre-native', 'm4-native', 'db-native']
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_configure
| -- The C compiler identification is Clang 17.0.6
| -- The CXX compiler identification is Clang 17.0.6
| -- The ASM compiler identification is Clang with GNU-like command-line
| -- Found assembler: /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-clang
| -- Detecting C compiler ABI info
| -- Detecting C compiler ABI info - failed
| -- Check for working C compiler: /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-clang
| -- Check for working C compiler: /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-clang - broken
| CMake Error at /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
| The C compiler
|
| "/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-clang"
|
| is not able to compile a simple test program.
|
| It fails with the following output:
|
| Change Dir: /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/build/CMakeFiles/CMakeTmp
|
| Run Build Command(s):ninja cmTC_18b0b && [1/2] Building C object CMakeFiles/cmTC_18b0b.dir/testCCompiler.c.o
| [2/2] Linking C executable cmTC_18b0b
| FAILED: cmTC_18b0b
| : && /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-clang --target=aarch64-linux-gnu -target aarch64-linux-gnu -mcpu=neoverse-n2+crypto -mlittle-endian -Qunused-arguments -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -ffile-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0=/usr/src/debug/compiler-rt/17.0.6-r0 -fmacro-prefix-map=/path/to/yoctobuild/tmp/work-shared/llvm-project-source-17.0.6-r0/git=/usr/src/debug/compiler-rt/17.0.6-r0 -fdebug-prefix-map=/path/to/yoctobuild/tmp/work-shared/llvm-project-source-17.0.6-r0/git=/usr/src/debug/compiler-rt/17.0.6-r0 -fmacro-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/build=/usr/src/debug/compiler-rt/17.0.6-r0 -fdebug-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/build=/usr/src/debug/compiler-rt/17.0.6-r0 -fdebug-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot= -fmacro-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot= -fdebug-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native= -target aarch64-linux-gnu -mcpu=neoverse-n2+crypto -mlittle-endian -Qunused-arguments -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -ffile-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0=/usr/src/debug/compiler-rt/17.0.6-r0 -fmacro-prefix-map=/path/to/yoctobuild/tmp/work-shared/llvm-project-source-17.0.6-r0/git=/usr/src/debug/compiler-rt/17.0.6-r0 -fdebug-prefix-map=/path/to/yoctobuild/tmp/work-shared/llvm-project-source-17.0.6-r0/git=/usr/src/debug/compiler-rt/17.0.6-r0 -fmacro-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/build=/usr/src/debug/compiler-rt/17.0.6-r0 -fdebug-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/build=/usr/src/debug/compiler-rt/17.0.6-r0 -fdebug-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot= -fmacro-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot= -fdebug-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native= -Wl,-z,relro,-z,now -unwindlib=libgcc -rtlib=libgcc -stdlib=libstdc++ -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -ffile-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0=/usr/src/debug/compiler-rt/17.0.6-r0 -fmacro-prefix-map=/path/to/yoctobuild/tmp/work-shared/llvm-project-source-17.0.6-r0/git=/usr/src/debug/compiler-rt/17.0.6-r0 -fdebug-prefix-map=/path/to/yoctobuild/tmp/work-shared/llvm-project-source-17.0.6-r0/git=/usr/src/debug/compiler-rt/17.0.6-r0 -fmacro-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/build=/usr/src/debug/compiler-rt/17.0.6-r0 -fdebug-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/build=/usr/src/debug/compiler-rt/17.0.6-r0 -fdebug-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot= -fmacro-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot= -fdebug-prefix-map=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native= -Wl,-z,relro,-z,now -unwindlib=libgcc -rtlib=libgcc -stdlib=libstdc++ CMakeFiles/cmTC_18b0b.dir/testCCompiler.c.o -o cmTC_18b0b && :
| /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-ld: cannot find crtbeginS.o: No such file or directory
| /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-ld: cannot find -lgcc: No such file or directory
| /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-ld: cannot find -lgcc: No such file or directory
| aarch64-linux-gnu-clang: error: linker command failed with exit code 1 (use -v to see invocation)
| ninja: build stopped: subcommand failed.
|
|
|
|
|
| CMake will not be able to correctly generate this project.
| Call Stack (most recent call first):
| CMakeLists.txt:47 (project)
|
|
| -- Configuring incomplete, errors occurred!
| See also "/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/build/CMakeFiles/CMakeOutput.log".
| See also "/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/build/CMakeFiles/CMakeError.log".
| WARNING: /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/temp/run.do_configure.23915:205 exit 1 from 'cmake -G 'Ninja' -DCMAKE_MAKE_PROGRAM=ninja $oecmake_sitefile /path/to/yoctobuild/tmp/work-shared/llvm-project-source-17.0.6-r0/git/llvm -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_BINDIR:PATH=bin -DCMAKE_INSTALL_SBINDIR:PATH=sbin -DCMAKE_INSTALL_LIBEXECDIR:PATH=libexec -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=../com -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=/var -DCMAKE_INSTALL_LIBDIR:PATH=lib64 -DCMAKE_INSTALL_INCLUDEDIR:PATH=include -DCMAKE_INSTALL_DATAROOTDIR:PATH=share -DPYTHON_EXECUTABLE:PATH=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/python3-native/python3 -DPython_EXECUTABLE:PATH=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/python3-native/python3 -DPython3_EXECUTABLE:PATH=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/python3-native/python3 -DLIB_SUFFIX=64 -DCMAKE_INSTALL_SO_NO_EXE=0 -DCMAKE_TOOLCHAIN_FILE=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/toolchain.cmake -DCMAKE_NO_SYSTEM_FROM_IMPORTED=1 -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DFETCHCONTENT_FULLY_DISCONNECTED=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF -DCOMPILER_RT_STANDALONE_BUILD=OFF -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DCOMPILER_RT_INCLUDE_TESTS=OFF -DCMAKE_C_COMPILER_TARGET=aarch64-linux-gnu -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_SANITIZERS=OFF -DCOMPILER_RT_BUILD_MEMPROF=OFF -DCOMPILER_RT_BUILD_LIBFUZZER=OFF -DLLVM_ENABLE_PROJECTS='compiler-rt' -DLLVM_LIBDIR_SUFFIX=64 -DCOMPILER_RT_BUILD_CRT:BOOL=OFF -DCOMPILER_RT_BUILD_PROFILE=OFF -DCMAKE_RANLIB=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-llvm-ranlib -DCMAKE_AR=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-llvm-ar -DCMAKE_NM=/path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/recipe-sysroot-native/usr/bin/aarch64-linux-gnu/aarch64-linux-gnu-llvm-nm -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Wno-dev'
| WARNING: Backtrace (BB generated script):
| #1: cmake_do_configure, /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/temp/run.do_configure.23915, line 205
| #2: do_configure, /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/temp/run.do_configure.23915, line 148
| #3: main, /path/to/yoctobuild/tmp/work/aarch64-linux-gnu/compiler-rt/17.0.6-r0/temp/run.do_configure.23915, line 205
ERROR: Task (/path/to/src/lfs-core/meta-clang/recipes-devtools/clang/compiler-rt_git.bb:do_configure) failed with exit code '1'
NOTE: Tasks Summary: Attempted 1254 tasks of which 1253 didn't need to be rerun and 1 failed.
Summary: 1 task failed:
/path/to/src/lfs-core/meta-clang/recipes-devtools/clang/compiler-rt_git.bb:do_configure
Summary: There were 50 WARNING messages.
Summary: There was 1 ERROR message, returning a non-zero exit code.

@kraj
Copy link
Owner

kraj commented Apr 19, 2024

@drula thanks for trying meta-clang out and reporting the issue you observed. I am not entirely clear what could be causing this error. I am guessing you are on a release and I would suggest that you try master branch and see if you still run into this error.

Secondly, what is your build host, perhaps that will provide some leads maybe.

Thirdly try yoe distro, it uses clang as default compiller and see if it works out ok for your case.

@kraj
Copy link
Owner

kraj commented Apr 19, 2024

and try setting

  # Use clang as default compiler
   TOOLCHAIN ?= "clang"

   # Build clang into SDK as well
   CLANGSDK = "1"

   # Use compile-rt/libcxx/libunwind as default runtime libraries
   TC_CXX_RUNTIME ?= "llvm"
   RUNTIME ?= "llvm"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants