This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Use libc++ and compiler-rt as default libraries in Fuchsia toolchain
ClosedPublic

Authored by phosek on Nov 10 2017, 4:53 PM.

Diff Detail

Repository
rC Clang

Event Timeline

phosek created this revision.Nov 10 2017, 4:53 PM
mcgrathr edited edge metadata.Nov 10 2017, 5:18 PM

In principle this should be OK since we're unconditionally building the runtimes for default.
However, this means that any dynamically-linked host builds will assume our toolchain-provided shared libraries are available on the runtime host in standard library places.
I don't think we want that. Perhaps we could make -static-libstdc++ default in our host targets. But that's not really enough, since compiler-rt has some too. Probably better to just disable building the shared libraries altogether for the host targets.

phosek updated this revision to Diff 123432.Nov 17 2017, 2:56 PM
mcgrathr accepted this revision.Nov 17 2017, 11:31 PM

LGTM with comment added but if a different approach will be required for multiple Linux targets (which we all treat as "hostish") then it's worth at least thinking about that now.

cmake/caches/Fuchsia-stage2.cmake
38

It's not completely obvious (to me) that these apply to the "default target" build but not to the other LLVM_RUNTIME_TARGETS builds.
A comment here would be good.

We recently discussed enabling other *-linux targets (AFAIK we might as well enable {x86_64,aarch64}-linux regardless of host, even for Mac hosts). We'd want these settings for those too. Would that have to be done differently than thsi?

This revision is now accepted and ready to land.Nov 17 2017, 11:31 PM

This is something I was already thinking about. Ideally, in our toolchain, we would build runtimes for all host and target platforms we support, i.e. on every host (Linux, macOS and Windows) we would build runtimes for i386, x86_64 and aarch64 Linux, x86_64 macOS, x86_64 Windows, and x86_64 and aarch64 Fuchsia. This means that the toolchain on every platform can target every other platform as long as you provide the right sysroot. However, there are two issues I'm aware of:

  1. The compiler-rt build for host is different from the cross-target build: In the cross-target build, it only builds artifacts for the specified target triple. However, on Linux it always does a multilib build and on macOS it produces fat archives for all supported platforms.
  2. Clang driver currently assumes that runtimes for host platform live in <toolchain>/lib/. In Fuchsia, we support runtimes being in <toolchain>/lib/<triple> but no other driver does.

To support what I described above, we would have to move to a setup when host platform isn't treated specially as it's today but it's just another triple. That's going to require some refactoring and cleanup. @beanz might have some opinion on this as well since this is something we already discussed before on IRC.

beanz edited edge metadata.Nov 27 2017, 9:49 AM

@phosek, I would love to see compiler-rt fully refactored so that we target one triple at a time always. I'd also love to see the clang driver refactored so that the code to resolve paths to runtime libraries was shared so we follow the same conventions across all driver implementations.

These are both large projects with a lot of stakeholders, and I don't expect that I'll be much use on it anytime soon.

phosek updated this revision to Diff 138882.Mar 19 2018, 12:55 AM
phosek marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.