oneapi-src / oneTBB

oneAPI Threading Building Blocks (oneTBB)
https://oneapi-src.github.io/oneTBB/
Apache License 2.0
5.72k stars 1.02k forks source link

Linking error with LLD linker #477

Closed phprus closed 3 years ago

phprus commented 3 years ago

Clang 9 + LLD

CMake:

CC=clang CXX=clang++ CXXFLAGS="-stdlib=libc++" LDFLAGS="-fuse-ld=lld" cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=RelWithDebinfo -DCMAKE_CXX_STANDARD=17 ../..

Error:

[ 14%] Linking CXX executable ../clang_9.0_cxx17_64_relwithdebinfo/test_malloc_overload_disable
cd /home/phprus/devel/oneTBB/oneTBB-2021.3.0/build/target_opensuse151-clang9/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/test_malloc_overload_disable.dir/link.txt --verbose=1
/usr/bin/clang++  -stdlib=libc++ -O2 -g -DNDEBUG  -fuse-ld=lld -rdynamic CMakeFiles/test_malloc_overload_disable.dir/tbbmalloc/test_malloc_overload_disable.cpp.o  -o ../clang_9.0_cxx17_64_relwithdebinfo/test_malloc_overload_disable  -Wl,-rpath,/home/phprus/devel/oneTBB/oneTBB-2021.3.0/build/target_opensuse151-clang9/clang_9.0_cxx17_64_relwithdebinfo ../clang_9.0_cxx17_64_relwithdebinfo/libtbbmalloc_proxy.so.2.3 ../clang_9.0_cxx17_64_relwithdebinfo/libtbbmalloc.so.2.3 -ldl -pthread
ld.lld: error: ../clang_9.0_cxx17_64_relwithdebinfo/libtbbmalloc_proxy.so.2.3: undefined reference to __TBB_malloc_safer_free
ld.lld: error: ../clang_9.0_cxx17_64_relwithdebinfo/libtbbmalloc_proxy.so.2.3: undefined reference to __TBB_malloc_safer_msize
ld.lld: error: ../clang_9.0_cxx17_64_relwithdebinfo/libtbbmalloc_proxy.so.2.3: undefined reference to __TBB_malloc_safer_realloc
clang-9.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test/CMakeFiles/test_malloc_overload_disable.dir/build.make:106: clang_9.0_cxx17_64_relwithdebinfo/test_malloc_overload_disable] Ошибка 1
make[2]: выход из каталога «/home/phprus/devel/oneTBB/oneTBB-2021.3.0/build/target_opensuse151-clang9»
make[1]: *** [CMakeFiles/Makefile2:593: test/CMakeFiles/test_malloc_overload_disable.dir/all] Ошибка 2
make[1]: выход из каталога «/home/phprus/devel/oneTBB/oneTBB-2021.3.0/build/target_opensuse151-clang9»
make: *** [Makefile:183: all] Ошибка 2
vlserov commented 3 years ago

LLVM LLD9 doesn't prioritize non-wildcards over wildcards in version script. This behavior has been fixed in LLD10 with commit-id #e28a70da.

For supporting LL9 on oneTBB side, wildcard templates in local section should be reworked for excluding explicitly defined functions of global section. For example, lin64-tbbmalloc.def has __TBB_malloc_safer_free; function defined in global section of version script, but LLD9 excludes it based on *__TBB*; wildcard in local section.

phprus commented 3 years ago

Thank you for your answer! Issue can be closed.