vdt
vdt copied to clipboard
Linking error with clang
Hi!
I get undefined references if i build with the following cmake command:
cmake /path/to/vdt -DDIAG=ON -DDEBUG=ON -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_C_COMPILER="clang
The error:
/usr/bin/ld: CMakeFiles/test_randomPool.dir/test_randomPool.cpp.o: in function `refMath::exp(double)':
/home/stefan/workspace/vdt/include/diagnostic/vdtdiag_helper.h:54: undefined reference to `__exp_finite'
/usr/bin/ld: CMakeFiles/test_randomPool.dir/test_randomPool.cpp.o: in function `refMath::expf(float)':
/home/stefan/workspace/vdt/include/diagnostic/vdtdiag_helper.h:55: undefined reference to `__expf_finite'
/usr/bin/ld: CMakeFiles/test_randomPool.dir/test_randomPool.cpp.o: in function `refMath::log(double)':
/home/stefan/workspace/vdt/include/diagnostic/vdtdiag_helper.h:56: undefined reference to `__log_finite'
/usr/bin/ld: CMakeFiles/test_randomPool.dir/test_randomPool.cpp.o: in function `refMath::logf(float)':
/home/stefan/workspace/vdt/include/diagnostic/vdtdiag_helper.h:57: undefined reference to `__logf_finite'
/usr/bin/ld: CMakeFiles/test_randomPool.dir/test_randomPool.cpp.o: in function `std::log(long double)':
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.2.1/../../../../include/c++/9.2.1/cmath:343: undefined reference to `__logl_finite'
/usr/bin/ld: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.2.1/../../../../include/c++/9.2.1/cmath:343: undefined reference to `__logl_finite'
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
My setup:
clang 9.0.1 cmake 3.16.4
Best Stefan
It fails only if we use -Ofast
. Everything is fine with -O3
.
This seems very much related: https://github.com/cms-sw/cmssw/issues/24935
These are the symbols, which are undefined:
nm lib/libvdt.so | c++filt | grep finit
U __expf_finite
U __exp_finite
U __logf_finite
U __log_finite
Strangely they don't show up if I build with gcc, only with clang (and -Ofast
).
https://bugs.llvm.org/show_bug.cgi?id=45034
Thanks for the ping!