This is an archive of the discontinued LLVM Phabricator instance.

[runtimes] Don't try passing --target flags to GCC
ClosedPublic

Authored by ldionne on Jul 15 2021, 10:14 AM.

Details

Reviewers
phosek
ldionne
Group Reviewers
Restricted Project
Restricted Project
Restricted Project
Commits
rGa59165b01778: [runtimes] Don't try passing --target flags to GCC
Summary

When a target triple is specified in CMake via XXX_TARGET_TRIPLE, we tried
passing the --target=<...> flag to the compiler. However, not all compilers
support that flag (e.g. GCC, which is not a cross-compiler). As a result,
setting e.g. LIBCXX_TARGET_TRIPLE=<host-triple> would end up trying to
pass --target=<host-triple> to GCC, which breaks everything because the
flag isn't even supported.

This commit only adds --target=<...> & friends to the flags if it is
supported by the compiler.

One could argue that it's confusing to pass LIBCXX_TARGET_TRIPLE=<...>
and have it be ignored. That's correct, and one possibility would be
to assert that the requested triple is the same as the host triple when
we know the compiler is unable to cross-compile. However, note that this
is a pre-existing issue (setting the TARGET_TRIPLE variable never had an
influence on the flags passed to the compiler), and also fixing that is
starting to look like reimplementing a lot of CMake logic that is already
handled with CMAKE_CXX_COMPILER_TARGET.

Diff Detail

Event Timeline

ldionne created this revision.Jul 15 2021, 10:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2021, 10:14 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne requested review of this revision.Jul 15 2021, 10:14 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 15 2021, 10:14 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
phosek accepted this revision.Jul 15 2021, 10:36 AM

LGTM

ldionne accepted this revision.Jul 15 2021, 11:10 AM

Will ship once CI passes.

This revision is now accepted and ready to land.Jul 15 2021, 11:10 AM
This revision was automatically updated to reflect the committed changes.