[PATCH] D111367: [Driver] Change -dumpmachine to respect --target/LLVM_DEFAULT_TARGET_TRIPLE verbatim

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 7 21:04:06 PDT 2021


MaskRay added a comment.

In D111367#3050061 <https://reviews.llvm.org/D111367#3050061>, @tstellar wrote:

> In D111367#3049772 <https://reviews.llvm.org/D111367#3049772>, @MaskRay wrote:
>
>> In D111367#3049700 <https://reviews.llvm.org/D111367#3049700>, @hvdijk wrote:
>>
>>> Does Red Hat actually use `x86_64-redhat-linux` with LLVM (other than for finding the GCC installation)? I didn't see this on Fedora, I think they use the config.guess-determined target name, and I think that's the right thing for them to do. That only affects whether you've got a realistic testcase though, the main change makes sense to me.
>>
>> Thanks.
>>
>> According to https://reviews.llvm.org/D110900#3041312 Red Hat GCC uses `x86_64-redhat-linux`.
>> I don't know what its Clang currently does.
>
> I've been working on this for a few weeks now, and I think what I'm going to do for Red Hat clang is to use current triples generated from config.guess, but replace the unknown vendor with redhat (e.g. x86_64-redhat-linux-gnu).  This will be a no-op change since llvm treats the redhat vendor as unknown, but will at least allow me to identify the triple as a redhat triple, so I can patch the clang driver to select the correct gcc install.
>
> It seems to me it will be difficult to have one triple that both controls clang's behavior and selects the desired gcc install, because clang and gcc have different conventions.  I wonder if we should have a more explicit way to select the gcc install.

If GCC installation has library files under `lib/x86_64-redhat-linux`, I think inferred `LLVM_DEFAULT_TARGET_TRIPLE` should be `x86_64-redhat-linux`, instead of `x86_64-redhat-linux-gnu`.

With correct `LLVM_DEFAULT_TARGET_TRIPLE`, `clang a.c` should just work; with incorrect `LLVM_DEFAULT_TARGET_TRIPLE`, it's fair for `clang a.c` NOT to find GCC crtbegin.o/libgcc_s.so.1/etc.

For older Clang with broken target triple, I think it is fair to ask the user to specify correct `LLVM_DEFAULT_TARGET_TRIPLE` (or `LLVM_HOST_TRIPLE`).

I hope both `clang --version` and `clang -dumpmachine` print `LLVM_DEFAULT_TARGET_TRIPLE` in a verbatim way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111367/new/

https://reviews.llvm.org/D111367



More information about the cfe-commits mailing list