This is an archive of the discontinued LLVM Phabricator instance.

Driver: Add preferred gcc triples for Red Hat operating systems
Needs ReviewPublic

Authored by tstellar on Sep 13 2021, 8:14 AM.



The GCCInstallationDetector has a list of gcc triples to search
for when trying to find a valid gcc install on the system. When
all else is equal, clang selects the first triple that appears in
the list.

This causes a problem on Red Hat operating systems, since there
is a cross-compiler gcc package that uses the triple x86_64-linux-gnu
and since this is listed in the triple list before the system gcc
install (x86_64-redhat-linux), the cross-compiler is always selected
by clang.

To solve this, we make it possible for a distro to provide a list of
preferred triples that will be selected before any triples in the
generic triple list.

Another solution to this problem would be to reorder the generic triple
lists so that distro supplied triples come first. However, I don't
have confidence that I would be able to order the list so that it
is correct for every distro.

Diff Detail

Event Timeline

tstellar created this revision.Sep 13 2021, 8:14 AM
tstellar requested review of this revision.Sep 13 2021, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 13 2021, 8:14 AM

Haven't looked closely at this particular commit, but I think hard coding the detected triples is almost always a bad idea.

See for a longer comment.

The proper way is (1) making sure CMake LLVM_DEFAULT_TARGET_TRIPLE is correct at configure time (2) the user should specify the complete --target=.

Inferring random target triple from an incomplete --target=x86_64 really should not be supported.

I uploaded D109727 to clean up suse related *Triples elements in CollectLibDirsAndTriples.
The long-term plan is to remove the *Triples variables entirely.