vdt icon indicating copy to clipboard operation
vdt copied to clipboard

Linking error with clang

Open stwunsch opened this issue 5 years ago • 5 comments

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

stwunsch avatar Feb 18 '20 16:02 stwunsch

It fails only if we use -Ofast. Everything is fine with -O3.

stwunsch avatar Feb 18 '20 16:02 stwunsch

This seems very much related: https://github.com/cms-sw/cmssw/issues/24935

stwunsch avatar Feb 18 '20 17:02 stwunsch

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).

stwunsch avatar Feb 18 '20 17:02 stwunsch

https://bugs.llvm.org/show_bug.cgi?id=45034

XapaJIaMnu avatar Feb 26 '20 18:02 XapaJIaMnu

Thanks for the ping!

stwunsch avatar Feb 26 '20 20:02 stwunsch