This is an archive of the discontinued LLVM Phabricator instance.

[CMake][libcxxabi] Support merging archives when statically linking unwinder
ClosedPublic

Authored by phosek on Nov 12 2017, 4:18 PM.

Details

Summary

When using LLVM unwinder and static unwinder option is set, merge
libc++abi.a and libunwind.a into a single archive. libc++ already
supports merging libc++abi.a and libc++.a into a single archive; with
this change, it is possible to also include libunwind.a in the same
archive which is useful when doing static link and using libc++ as
a default C++ library and compiler-rt as a default runtime library.

Diff Detail

Repository
rL LLVM

Event Timeline

phosek created this revision.Nov 12 2017, 4:18 PM

What's the advantage to using python for this over doing it directly in CMake?

What's the advantage to using python for this over doing it directly in CMake?

The only one I can think of is the consistency with libc++: I've blatantly copied the implementation used by libc++, but I'd be perfectly happy to redo this in plain CMake if people are fine with it (and also update libc++ to use the same approach).

phosek updated this revision to Diff 122948.Nov 14 2017, 4:39 PM
phosek added reviewers: beanz, jroelofs.

I've modified the patch to use plain CMake, PTAL.

beanz edited edge metadata.Nov 15 2017, 11:49 AM

Rather than hand rolling ar commands, could we make libunwind, libcxxabi, and libcxx produce object libraries, then we could just create normal static library targets with the object libraries as sources.

Thoughts?

phosek updated this revision to Diff 123288.Nov 16 2017, 8:32 PM

That's a great suggestion! libunwind and libc++abi already produce object libraries so using that approach makes this change even simpler.

beanz accepted this revision.Nov 17 2017, 9:25 AM

One small nitpick, otherwise LGTM!

src/CMakeLists.txt
157 ↗(On Diff #123288)

You should be able to do this with list(APPEND ...) instead of set.

This revision is now accepted and ready to land.Nov 17 2017, 9:25 AM

I presume that this only works as long as you build libunwind and libcxxabi together in a single build instead of building them standalone? (Or put another way; when building llvm+clang+lld on linux, for linux, intended to be used as cross compiler for windows - is there any way to build libunwind+libcxxabi+libcxx within the same source tree for i686,x86_64,arm,arm64 windows/mingw?)

beanz added a comment.Nov 17 2017, 1:30 PM

@mstorsjo that is the problem that the LLVM/runtimes directory solves. It supports building all the runtime libraries as a single build with one build-tree per target and the management of separate build trees is handled by the build system.

@mstorsjo that is the problem that the LLVM/runtimes directory solves. It supports building all the runtime libraries as a single build with one build-tree per target and the management of separate build trees is handled by the build system.

Oh, interesting - I'll have to look into that and see how well it works for my case!

phosek updated this revision to Diff 123423.Nov 17 2017, 2:34 PM
phosek marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.