This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Option to control whether shared/static library is installed
ClosedPublic

Authored by phosek on Jul 19 2018, 3:36 PM.

Details

Summary

Currently it's only possible to control whether shared or static library build of libc++, libc++abi and libunwind is enabled or disabled and whether to install everything we've built or not. However, it'd be useful to have more fine grained control, e.g. when static libraries are merged together into libc++.a we don't need to install libc++abi.a and libunwind.a. This change adds this option.

Diff Detail

Repository
rCXX libc++

Event Timeline

phosek created this revision.Jul 19 2018, 3:36 PM

Patch is missing context.

Also, this ended up going to llvm-commits instead of cfe-commits, which isn't ideal.

phosek updated this revision to Diff 156382.Jul 19 2018, 4:13 PM
phosek edited subscribers, added: cfe-commits; removed: llvm-commits.

I don't like the fact that we're adding options like crazy, thus making the build more complicated. If you don't want to have some libraries that were built, why not just remove them afterwards?

I don't like the fact that we're adding options like crazy, thus making the build more complicated. If you don't want to have some libraries that were built, why not just remove them afterwards?

The motivation behind this is that you could produce a complete toolchain with just CMake, combined with the fact that the cache files are all part of the LLVM tree, anyone can build the toolchain themselves which is useful when reproducing issues. We would like to add Fuchsia bots to upstream in the near future where reproducibility is going to be even more important and I'd like to avoid for people to have to run additional post-processing scripts.

Regarding this change, this in combination with D49502 is all we need to exactly what gets built and installed, I don't plan on adding anymore options. Alternative that I also considered would be avoid exposing these options and instead do this implicitly based on the variables that are being set, e.g. in libc++abi build check if LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY is set and if so don't even install libc++abi.a. The problem is that while this may work for us, I'm pretty sure there are going to be other clients that have other requirements where this is not the right choice and we could see combinatorial explosion of different configurations, so providing these options is probably a better choice.

Can't you simply set LIBCXX_ENABLE_SHARED=OFF when you don't want to build/install the shared library and LIBCXX_ENABLE_STATIC=OFF for the static library?

You're right that we don't need these flags for libc++, we only need them for libc++abi and libunwind for the cases when one of these is linked into libc++ or libc++abi respectively. I added them for consistency, but I'm fine dropping them from libc++, would that be more acceptable?

ldionne accepted this revision.Jul 23 2018, 2:55 PM

Ah, so you mean you need it for libc++abi because you want to build them but not install them (so they're linked into libc++)? Then LGTM as-is. I'd like to see what Eric has to say though.

This revision is now accepted and ready to land.Jul 23 2018, 2:55 PM
This revision was automatically updated to reflect the committed changes.
sbc100 added a subscriber: sbc100.Jul 25 2018, 3:36 PM

FYI, this broke the WebAssembly waterfall, where the library is no longer being installed: https://wasm-stat.us/builders/linux/builds/34191

There is probably an easy fix, but I thought I'd post here for the record.