This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Link LLDB only against libclang and libLLVM .a files to fix macOS build
ClosedPublic

Authored by kubamracek on Aug 12 2016, 4:28 AM.

Details

Summary

The Xcode macOS build of LLDB is currently broken after https://reviews.llvm.org/D23232 landed, see http://lab.llvm.org:8080/green/job/lldb_build_test/20014/console, because we’re trying to link against all .a files found in the llvm-build/lib directory. Let’s be more specific in what we link against. This patch applies a regexp to only use “libclang.*”, “libLLVM.*” and not “libclang_rt.*” static archives.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 67819.Aug 12 2016, 4:28 AM
kubamracek retitled this revision from to [lldb] Link LLDB only against libclang and libLLVM .a files to fix macOS build.
kubamracek updated this object.
kubamracek added a project: Restricted Project.
kubamracek added subscribers: phosek, zaks.anna.
compnerd added inline comments.Aug 12 2016, 7:36 AM
scripts/Xcode/build-llvm.py
138

Why not use llvm-config to get the linker parameters and the correct ordering rather than relying on the alphabetical ordering (linker options are order dependent, more so in some object formats than others) and hoping that patterns will do the trick? In particular, the --libs option and --component options are interesting. If you really want to use the full path, you can abuse the --libfiles option in llvm-config.

kubamracek added inline comments.Aug 12 2016, 7:41 AM
scripts/Xcode/build-llvm.py
138

Good point. Is there a way to get a list of _Clang_ static libraries?

compnerd added inline comments.Aug 12 2016, 8:23 AM
scripts/Xcode/build-llvm.py
138

I dont *think* that there is. In general, clang isn't as modular as LLVM and doesn't provide components to embed it into other uses :-(. I suspect that its best to empirically work out the current dependency (start with -lclangBaisc -lclangCodeGen and add dependencies as necessary). Im basing the beginning point on what the clang driver links against. If the dependencies for the library change, it should be pretty quick to spot the breakage. With more components trying to re-use clang (lldb was the first, swift is the new kid on the block), I think it may make some sense to provide a clang-config tool, but that would be a much longer term thing.

tfiala edited edge metadata.EditedAug 12 2016, 9:37 AM

I think we're going to go with this for now. We can improve it later. I'd rather not use separate mechanisms for collecting the llvm and clang libraries.

I don't like the "collect all libs" approach since it can break incremental builds on CI if a library is removed - the old .a will still be around and get collected into the build.

That will require some more investigation, though. This change addresses the broken LLVM.org LLDB Green Dragon macOS builder.

This change also likely needs to have an adjustment in some downstream repositories (e.g. for Swift).

I filed the following bugzilla bug to track the idea of making this smarter:
https://llvm.org/bugs/show_bug.cgi?id=28953

tfiala accepted this revision.Aug 12 2016, 10:10 AM
tfiala edited edge metadata.

Committed here:
r278527

This revision is now accepted and ready to land.Aug 12 2016, 10:10 AM
tfiala closed this revision.Aug 12 2016, 10:10 AM