Compiling libc++ with clang
Posted: Fri Mar 11, 2022 10:45 am
Hello!
I'm currently trying to cross-compile libc++ (the C++ standard library for clang) to be able to cross-compile compiler-rt, which in turn should make me able to cross compile programs to run in my kernel's userspace.
The commands I have been using are:
(The sysroot contains the compiled musl C library and the target is i686-unknown-linux-musl)
And I just can't figure out why compiling libc++ seems to require the standard C++ library
Thanks for your help
I'm currently trying to cross-compile libc++ (the C++ standard library for clang) to be able to cross-compile compiler-rt, which in turn should make me able to cross compile programs to run in my kernel's userspace.
The commands I have been using are:
Code: Select all
cd llvm
mkdir -p build
cmake \
-G Ninja \
-S runtimes \
-B build \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DCMAKE_INSTALL_PREFIX="$SYSROOT" \
-DCMAKE_C_COMPILER="/bin/clang" \
-DCMAKE_CXX_COMPILER="/bin/clang++" \
-DCMAKE_C_COMPILER_TARGET="$TARGET" \
-DCMAKE_CXX_COMPILER_TARGET="$TARGET"
ninja -C build cxx cxxabi unwind
ninja -C build install-cxx install-cxxabi install-unwind
cd ..
Code: Select all
-- The C compiler identification is Clang 10.0.0
-- The CXX compiler identification is Clang 10.0.0
-- The ASM compiler identification is Clang
-- Found assembler: /bin/clang
-- Check for working C compiler: /bin/clang
-- Check for working C compiler: /bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /bin/clang++
-- Check for working CXX compiler: /bin/clang++ -- broken
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"/bin/clang++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/llenotre/Desktop/dev/gcc_maestro/llvm/build/CMakeFiles/CMakeTmp
Run Build Command(s):/bin/ninja cmTC_1a17f && [1/2] Building CXX object CMakeFiles/cmTC_1a17f.dir/testCXXCompiler.cxx.o
[2/2] Linking CXX executable cmTC_1a17f
FAILED: cmTC_1a17f
: && /bin/clang++ --target=i686-unknown-linux-musl CMakeFiles/cmTC_1a17f.dir/testCXXCompiler.cxx.o -o cmTC_1a17f && :
/bin/ld: skipping incompatible /bin/../lib/gcc/x86_64-linux-gnu/9/libstdc++.so when searching for -lstdc++
/bin/ld: skipping incompatible /bin/../lib/gcc/x86_64-linux-gnu/9/libstdc++.a when searching for -lstdc++
/bin/ld: cannot find -lstdc++
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:3 (project)
-- Configuring incomplete, errors occurred!
See also "/home/llenotre/Desktop/dev/gcc_maestro/llvm/build/CMakeFiles/CMakeOutput.log".
See also "/home/llenotre/Desktop/dev/gcc_maestro/llvm/build/CMakeFiles/CMakeError.log".
Thanks for your help