ubsan no longer compiles when libc++ is the default

Hi,

Trying to compile llvm with the following configuration on Linux x86-64:

cmake -G Ninja -DBUILD_SHARED_LIBS=ON \
                          -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=gold"
\
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold"\
                          -DCMAKE_BUILD_TYPE=RelWithDebInfo ' \
                          -DCMAKE_C_FLAGS="-O2 -g" \
                          -DCMAKE_CXX_FLAGS="-O2 -g" \
                          -DENABLE_LINKER_BUILD_ID=ON \
                          -DLLVM_ENABLE_ASSERTIONS=ON \
                          -DLLVM_ENABLE_PIC=ON \
                          -DLLVM_BINUTILS_INCDIR=/usr/include \
                          -DLLVM_TARGETS_TO_BUILD=host \
                          -DLLVM_TARGET_ARCH=host \
                          -DLLVM_LIBDIR_SUFFIX=64 \
                          -DCLANG_DEFAULT_CXX_STDLIB=libc++ \
                          -DLLVM_ENABLE_LIBCXX=ON ..

results in the following build error:

../projects/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cc:233:
error: undefined reference to 'typeinfo for std::type_info'
../projects/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cc:233:
error: undefined reference to 'typeinfo for
__cxxabiv1::__class_type_info'
../projects/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cc:233:
error: undefined reference to '__dynamic_cast'
[...]

Looks like ubsan no longer links to libc++abi ? (I see -lgcc_s -lc
-ldl -lrt -lpthread on the linker line.)

This configuration has worked with r308719 so I am guessing this is a
regression.

Regards,
ismail

Hi,

Trying to compile llvm with the following configuration on Linux x86-64:

cmake -G Ninja -DBUILD_SHARED_LIBS=ON \
                         -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=gold"
\
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold"\
                         -DCMAKE_BUILD_TYPE=RelWithDebInfo ' \
                         -DCMAKE_C_FLAGS="-O2 -g" \
                         -DCMAKE_CXX_FLAGS="-O2 -g" \
                         -DENABLE_LINKER_BUILD_ID=ON \
                         -DLLVM_ENABLE_ASSERTIONS=ON \
                         -DLLVM_ENABLE_PIC=ON \
                         -DLLVM_BINUTILS_INCDIR=/usr/include \
                         -DLLVM_TARGETS_TO_BUILD=host \
                         -DLLVM_TARGET_ARCH=host \
                         -DLLVM_LIBDIR_SUFFIX=64 \
                         -DCLANG_DEFAULT_CXX_STDLIB=libc++ \
                         -DLLVM_ENABLE_LIBCXX=ON ..

results in the following build error:

../projects/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cc:233:
error: undefined reference to 'typeinfo for std::type_info'
../projects/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cc:233:
error: undefined reference to 'typeinfo for
__cxxabiv1::__class_type_info'
../projects/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cc:233:
error: undefined reference to '__dynamic_cast'
[...]

Looks like ubsan no longer links to libc++abi ? (I see -lgcc_s -lc
-ldl -lrt -lpthread on the linker line.)

This configuration has worked with r308719 so I am guessing this is a
regression.

This might have done it:
r309362 Support libc++abi in addition to libstdc++

Can you spot SANITIZER_CXX_ABI_LIBRARY, SANITIZER_CXX_ABI_LIBNAME, SANITIZER_CXX_ABI_INTREE, and SANITIZER_CXX_ABI_SYSTEM in your CMakeCache.txt? If so do they have the right values?

vedant

Hi,

I see the following variables in the CMakeCache.txt:

SANITIZER_CXX_ABI:STRING=default
//STRINGS property for variable: SANITIZER_CXX_ABI
SANITIZER_CXX_ABI-STRINGS:INTERNAL=none;default;libcxxabi;libstdc++

Regards,
ismail

If we knew the value of SANITIZER_CXX_ABI_LIBRARY, it might be easier to get to the bottom of this. Could you try dumping it out a configure time with a call to message()? Alternatively, you could try reverting r309362 locally to see if that helps.

vedant

Hi,

Reverting r309362 did not fix the problem so back to the drawing
board. Thanks for your help!

Regards,
ismail