This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add support for standalone cross compilation of libc.
ClosedPublic

Authored by sivachandra on Dec 19 2022, 1:49 PM.

Details

Summary

One should be able to do a cross build of the libc now. For example, using
clang on a x86_64 linux host, one can build for an aarch64 linux target by
specifying -DLIBC_TARGET_TRIPLE=aarch64-linux-gnu.

Follow up changes will add a baremetal config and also appropriate
documentation about cross compiling the libc for CPU targets.

Diff Detail

Event Timeline

sivachandra created this revision.Dec 19 2022, 1:49 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 19 2022, 1:49 PM
sivachandra requested review of this revision.Dec 19 2022, 1:49 PM
jhuber6 accepted this revision.Dec 19 2022, 2:02 PM

Changing the GPU to be a specific option is fine, less ambiguous for cross compiling reasons. Do we need any special handling of CMAKE_CXX_COMPILER_TARGET? That will always be set when using -DLLVM_ENABLE_RUNTIMES=libc and prepends --target=<host> to all the compilations.

This revision is now accepted and ready to land.Dec 19 2022, 2:02 PM

Changing the GPU to be a specific option is fine, less ambiguous for cross compiling reasons. Do we need any special handling of CMAKE_CXX_COMPILER_TARGET? That will always be set when using -DLLVM_ENABLE_RUNTIMES=libc and prepends --target=<host> to all the compilations.

Doing a simple bootstrap host build still works. The cross build is currently broken anyway. I have follow up patches to fix that situation.

Doing a simple bootstrap host build still works. The cross build is currently broken anyway. I have follow up patches to fix that situation.

Alright, go ahead and land this and I'll try to put some more GPU stuff on top of it and see how it pans out.

sivachandra edited the summary of this revision. (Show Details)Dec 19 2022, 4:27 PM