Link BasicTests via explicit target_link_libraries() rather than
clang_target_link_libraries() in order to fix linking when building
clang against libclang. The latter requires all listed libraries
to be part of libclang and omits them if libclang is used. However,
LLVMTestingSupport is not part of libclang, so omitting it causes
undefined symbols. Link to the library explicitly to follow suit
with the 7 other unittest programs.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
in order to fix linking when building clang against libclang
I am confused by building clang against libclang. libclang is the C API library (libclang.so on ELF platforms). Do you mean CLANG_LINK_CLANG_DYLIB libclang-cpp.so? What's your cmake command line to trigger a linker error?
Comment Actions
Yes, I'm sorry, I meant libclang-cpp.
FAILED: unittests/Basic/BasicTests : && /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -m32 -march=znver2 --param l1-cache-size=32 --param l1-cache-line-size=64 -O2 -pipe -frecord-gcc-switches -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -pedantic -Wno-long-long -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,--gc-sections unittests/Basic/CMakeFiles/BasicTests.dir/CharInfoTest.cpp.o unittests/Basic/CMakeFiles/BasicTests.dir/DarwinSDKInfoTest.cpp.o unittests/Basic/CMakeFiles/BasicTests.dir/DiagnosticTest.cpp.o unittests/Basic/CMakeFiles/BasicTests.dir/FileEntryTest.cpp.o unittests/Basic/CMakeFiles/BasicTests.dir/FileManagerTest.cpp.o unittests/Basic/CMakeFiles/BasicTests.dir/LineOffsetMappingTest.cpp.o unittests/Basic/CMakeFiles/BasicTests.dir/SanitizersTest.cpp.o unittests/Basic/CMakeFiles/BasicTests.dir/SourceManagerTest.cpp.o -o unittests/Basic/BasicTests -L/usr/lib/llvm/14/lib -Wl,-rpath,/usr/lib/llvm/14/lib:/var/tmp/portage/sys-devel/clang-14.0.0.9999/work/x/y/clang-abi_x86_32.x86/lib lib/libgtest_main.a lib/libgtest.a lib/libclang-cpp.so.14git -lpthread /usr/lib/llvm/14/lib/libLLVM-14git.so && : /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: unittests/Basic/CMakeFiles/BasicTests.dir/FileManagerTest.cpp.o: in function `(anonymous namespace)::FileManagerTest_getBypassFile_Test::TestBody()': FileManagerTest.cpp:(.text._ZN12_GLOBAL__N_134FileManagerTest_getBypassFile_Test8TestBodyEv+0x321): undefined reference to `llvm::detail::TakeError(llvm::Error)' /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: FileManagerTest.cpp:(.text._ZN12_GLOBAL__N_134FileManagerTest_getBypassFile_Test8TestBodyEv+0x797): undefined reference to `llvm::detail::TakeError(llvm::Error)' collect2: error: ld returned 1 exit status