Open PikachuHyA opened 7 months ago
I think this has to do with how compiler-rt links against libc++, this doesn't seem to be a libc++ issue.
Also, libc++ doesn't support being built with such an old GCC. The oldest GCC we support is GCC 13, but IDK if that would solve your problem regardless.
I think this has to do with how compiler-rt links against libc++, this doesn't seem to be a libc++ issue.
yes.
libc++ doesn't support being built with such an old GCC. The oldest GCC we support is GCC 13
the libc++ here is built by our prebuilt clang with libc++, not GCC
IDK if that would solve your problem regardless.
I want to build compiler-rt test (e.g. asan test) with libc++
currently, I use the options -DSANITIZER_TEST_CXX=libc++ -DSANITIZER_TEST_CXX_INTREE=ON -DSANITIZER_USE_STATIC_TEST_CXX=ON
, but some error occurred. see the ERROR part.
So I want to modify the CMakeLists.txt
to solve the error with the patch https://github.com/llvm/llvm-project/pull/72111.
The oldest GCC we support is GCC 13, but IDK if that would solve your problem regardless.
I test with GCC 13 and Clang 17, the Error still occured.
[root@i32d14053 llvm]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/gcc-toolset-13/root/usr --mandir=/opt/rh/gcc-toolset-13/root/usr/share/man --infodir=/opt/rh/gcc-toolset-13/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/opt/rh/gcc-toolset-13/root/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --without-isl --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_64=x86-64-v2 --with-arch_32=x86-64 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.1 20230614 (Red Hat 13.1.1-4) (GCC)
[root@i32d14053 llvm]# clang -v
clang version 17.0.1 (CentOS 17.0.1-2.el9)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13
Selected GCC installation: /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Environment Setup
centos 9 stream dokken/centos-stream-9:latest
docker run -it --net=host --privileged --restart=always --name centos9 dokken/centos-stream-9:latest /bin/bash
install gcc 13
yum install gcc-toolset-13-gcc gcc-toolset-13-libstdc++-devel gcc-toolset-13-gcc-c++
install clang 17
yum install clang clang-devel clang-libs clang-tools-extra lld lld-devel lld-libs llvm llvm-devel llvm-libs
other deps
yum -y install binutils binutils-devel glibc bash
yum -y install make dos2unix git chrpath perl-generators perl-Digest-MD5 libxml2-devel libffi-devel zlib-devel ncurses-devel libedit-devel perl-Sys-Syslog perl-Data-Dumper perl-Encode elfutils-libelf-devel
yum -y install python3 python3-pip python3-devel
yum -y install openssl-devel.x86_64
yum -y install perl-FindBin perl-File-Copy
now we build llvm and errors occured
LDFLAGS="-fuse-ld=lld -Wl,-q -Wl,-znow -Wl,-build-id=sha1" cmake -G Ninja \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_C_FLAGS="-Wno-backend-plugin" \
-DCMAKE_CXX_FLAGS="-Wno-backend-plugin" \
-DCMAKE_C_COMPILER="clang" \
-DCMAKE_CXX_COMPILER="clang++" \
-DLLVM_ENABLE_CLASSIC_FLANG=ON \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;openmp" \
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi" \
-DLLVM_LIBDIR_SUFFIX=64 \
-DLLVM_USE_LINKER=lld \
-DLLVM_PARALLEL_COMPILE_JOBS="96" \
-DLLVM_PARALLEL_LINK_JOBS=96 \
-DLLVM_ENABLE_NEW_PASS_MANAGER=ON \
-DLLVM_TARGETS_TO_BUILD="X86;BPF;WebAssembly" \
-DLLVM_ENABLE_LIBCXX=OFF \
-DLLVM_STATIC_LINK_CXX_STDLIB=OFF \
-DLLVM_BINUTILS_INCDIR="/usr/include" \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
-DCOMPILER_RT_BUILD_XRAY=OFF \
-DCOMPILER_RT_BUILD_ORC=OFF \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=OFF \
-DOPENMP_ENABLE_LIBOMPTARGET=OFF \
-DOPENMP_ENABLE_OMPT_TOOLS=OFF \
-DOPENMP_ENABLE_TESTING=OFF \
-DCOMPILER_RT_CXX_LIBRARY=libcxx \
-DSANITIZER_CXX_ABI=libc++ \
-DSANITIZER_CXX_ABI_INTREE=ON \
-DSANITIZER_USE_STATIC_CXX_ABI=ON \
-DSANITIZER_TEST_CXX=libc++ \
-DSANITIZER_TEST_CXX_INTREE=ON \
-DSANITIZER_USE_STATIC_TEST_CXX=ON \
-DSANITIZER_LIT_USE_LIBCXX=ON \
../llvm
ninja && ninja check-compiler-rt
Environment
centos 7
the latest LLVM cannot be built with gcc 4.8 on CentOS 7, then we use a prebuilt LLVM 17 with custom path (
/opt/prebuilt_llvm
). However, the compiler-rt test cannot be built due to errors likeno member named 'make_unique' in namespace 'std'
. Therefore, we need to use libc++ to build compiler-rt.Error
build with libc++ shared
build with libc++ static
reproducer
/opt/prebuilt_llvm
/llvm
set up build prerequisite
create build directory
build with libc++ shared
highlight flags
-DSANITIZER_TEST_CXX=libc++ -DSANITIZER_TEST_CXX_INTREE=ON -DSANITIZER_USE_STATIC_TEST_CXX=OFF
build
the error occur
ld.lld: error: unable to find library -lc++abi
Reason: the path of libc++abi.so is not in search path due to our libc++ is not in standard path (e.g.
/usr/lib64
)build with libc++ static
highlight flags
-DSANITIZER_TEST_CXX=libc++ -DSANITIZER_TEST_CXX_INTREE=ON -DSANITIZER_USE_STATIC_TEST_CXX=ON
build
the error occur
ld.lld: error: undefined symbol: __cxa_begin_catch
Reason: the
libc++abi.a
is not linked to binaryReference
see https://libcxx.llvm.org/UsingLibcxx.html#using-a-custom-built-libc