This is an archive of the discontinued LLVM Phabricator instance.

Don't use CLANG_LIBS and LINK_COMPONENTS in lldb/tools/lldb-instr/CMakeLists.txt
ClosedPublic

Authored by jingham on Jan 20 2023, 11:10 AM.

Details

Summary

The presence of this entry causes the Xcode generator to produce
two references to libLLVMSupport.a, one at the end of the list, and
that causes the build to fail with a link error. The first version
was pulled in when processing the CLANG_LIBS entries in the
lldb/tools/lldb-instr/CMakeLists.txt.

I looked around and the only places where we use LINK_COMPONENTS and
CLANG_LIBS together are various lldb subdirectories that produce .a
files but don't actually link anything.

Anyway, this line doesn't seem to be needed for either the regular
Ninja or the Xcode generator, and removing it makes the xcode build
work again.

Diff Detail

Event Timeline

jingham created this revision.Jan 20 2023, 11:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2023, 11:10 AM
jingham requested review of this revision.Jan 20 2023, 11:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2023, 11:10 AM
This revision is now accepted and ready to land.Jan 20 2023, 11:18 AM
This revision was automatically updated to reflect the committed changes.
aheejin added a subscriber: aheejin.EditedFeb 9 2023, 12:23 PM

This broke -sBUILD_SHARED_LIBS=ON build:

ld.lld: error: undefined symbol: llvm::errs()
>>> referenced by Instrument.cpp:162 (/usr/local/google/home/aheejin/llvm-git/lldb/tools/lldb-instr/Instrument.cpp:162)
>>>               tools/lldb/tools/lldb-instr/CMakeFiles/lldb-instr.dir/Instrument.cpp.o:(main)

ld.lld: error: undefined symbol: llvm::vfs::getRealFileSystem()
>>> referenced by Instrument.cpp:171 (/usr/local/google/home/aheejin/llvm-git/lldb/tools/lldb-instr/Instrument.cpp:171)
>>>               tools/lldb/tools/lldb-instr/CMakeFiles/lldb-instr.dir/Instrument.cpp.o:(main)

...
...

Is using CLANG_LIBS and LINK_COMPONENTS Support in the same file a problem? There are many files that use both:

./lldb/source/Core/CMakeLists.txt
./lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt
./lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
./lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
./lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
./lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
./lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
./lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
./lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt

Friendly ping 😅