This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Support CMake variables for setting target, sysroot and toolchain
ClosedPublic

Authored by phosek on Feb 3 2019, 4:26 PM.

Details

Summary

CMake has a standard way of setting target triple, sysroot and external
toolchain through CMAKE_<LANG>_COMPILER_TARGET, CMAKE_SYSROOT and
CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN. These are turned into
corresponding --target=, --sysroot= and --gcc-toolchain= variables add
included appended to CMAKE_<LANG>_FLAGS.

libunwind, libc++abi, libc++ provides their own mechanism through
<PROJECT>_TARGET_TRIPLE, <PROJECT>_SYSROOT and <PROJECT>_GCC_TOOLCHAIN
variables. These are also passed to lit via lit.site.cfg, and lit config
uses these to set the corresponding compiler flags when building tessts.

This means that there are two different ways of setting target, sysroot
and toolchain, but only one is properly supported in lit. This change
extends CMake build for libunwind, libc++abi and libc++ to also support
the CMake variables in addition to project specific ones in lit.

Diff Detail

Event Timeline

phosek created this revision.Feb 3 2019, 4:26 PM
phosek updated this revision to Diff 184987.Feb 3 2019, 5:10 PM
phosek edited the summary of this revision. (Show Details)
ldionne added inline comments.Feb 4 2019, 7:16 AM
libcxx/test/lit.site.cfg.in
20

This could instead be len("@TARGET_TRIPLE@") > 0 and we would avoid introducing LIBCXX_USE_TARGET.

phosek updated this revision to Diff 185062.Feb 4 2019, 8:43 AM
phosek marked 2 inline comments as done.
phosek added inline comments.
libcxx/test/lit.site.cfg.in
20

I think converting that string to bool is even easier (since empty string is falsy).

ldionne added inline comments.Feb 4 2019, 9:03 AM
libcxx/CMakeLists.txt
484

Not needed anymore.

phosek updated this revision to Diff 185108.Feb 4 2019, 11:34 AM
phosek marked an inline comment as done.
ldionne accepted this revision.Feb 4 2019, 11:36 AM
This revision is now accepted and ready to land.Feb 4 2019, 11:36 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2019, 12:02 PM

I believe this broke building libunwind standalone for me since it complains about add_target_flags() not being defined. I guess it also needs to be copied to the libunwind cmake files?

I believe this broke building libunwind standalone for me since it complains about add_target_flags() not being defined. I guess it also needs to be copied to the libunwind cmake files?

That looks right. @phosek can you submit a patch?