This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Add support for cross compiling.
ClosedPublic

Authored by danalbert on Jan 14 2015, 6:16 PM.

Diff Detail

Event Timeline

danalbert updated this revision to Diff 18206.Jan 14 2015, 6:16 PM
danalbert retitled this revision from to [libc++] Add support for cross compiling libc++..
danalbert updated this object.
danalbert edited the test plan for this revision. (Show Details)
danalbert added reviewers: jroelofs, EricWF.
danalbert set the repository for this revision to rL LLVM.
danalbert added a subscriber: Unknown Object (MLST).
danalbert added inline comments.Jan 14 2015, 6:20 PM
CMakeLists.txt
87

We can't use CMAKE_CROSSCOMPILING for this because AFAICT cmake (prior to 3.x) will only set that if you are compiling to a different system (i.e. Linux to Windows), but not to a different architecture. Since the variable can't be overridden, we just introduce our own.

libc++abi will need a similar one, so perhaps it should just be LLVM_CROSSCOMPILING? Do we already have such a thing? I need to take another look through how LLVM handles this.

Another option would just be removing it entirely. I suppose setting a sysroot/toolchain is probably helpful for non-cross compiles as well, and the only other thing this guards is the passing of LIBCXX_TARGET_TRIPLE to lit.site.cfg and its subsequent use in lit.cfg.

danalbert retitled this revision from [libc++] Add support for cross compiling libc++. to [libc++] Add support for cross compiling..Jan 14 2015, 6:31 PM
jroelofs edited edge metadata.Jan 15 2015, 6:46 AM

libc++abi will need a similar one, so perhaps it should just be LLVM_CROSSCOMPILING? Do we already have such a thing? I need to take another look through how LLVM handles this.

LLVM_CROSSCOMPILING and LIBCXX{ABI}_CROSSCOMPILING should be fundamentally different things. The former would only apply when host!=build, whereas the latter, because libcxx{abi} is a runtime component, applies when host!=target.

Another option would just be removing it entirely. I suppose setting a sysroot/toolchain is probably helpful for non-cross compiles as well

Yeah, there are valid use cases for this outside of cross compiles. I'd get rid of the guard.

It's awesome how terribly simple this is.

test/CMakeLists.txt
26 ↗(On Diff #18206)

I think this might belong in a separate patch.

danalbert updated this revision to Diff 18274.Jan 15 2015, 4:22 PM
danalbert edited edge metadata.

Remove LIBCXX_CROSSCOMPILING. The options it was guarding are useful outside a
cross compiling situation.

It's awesome how terribly simple this is.

If we could use cmake 3 the cmake part of this patch wouldn't even exist :(

jroelofs accepted this revision.Jan 15 2015, 4:39 PM
jroelofs edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jan 15 2015, 4:39 PM
danalbert updated this revision to Diff 18281.Jan 15 2015, 4:49 PM
danalbert edited edge metadata.

Use set() instead of option() for string options.

danalbert closed this revision.Jan 15 2015, 4:56 PM