This is an archive of the discontinued LLVM Phabricator instance.

Clang: GCCInstallationDetector follows --target value first
Needs RevisionPublic

Authored by wzssyqa on Aug 22 2023, 6:11 AM.

Details

Reviewers
MaskRay
Summary

If we have --target option, we should detect GCC installation
with this triple first.

So, If we call clang with --target=i386-linux-gnu -m64, we will try
the i386-linux-gnu env with multilib, instead of try x86_64-linux-gnu
first.

Diff Detail

Event Timeline

wzssyqa created this revision.Aug 22 2023, 6:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 6:11 AM
wzssyqa requested review of this revision.Aug 22 2023, 6:11 AM

I think that this is a step forward to drop *MIPSELTriples[].

wzssyqa updated this revision to Diff 552716.Aug 23 2023, 7:56 AM
wzssyqa edited the summary of this revision. (Show Details)Aug 23 2023, 7:58 AM

-target has been deprecated since 3.4. Please don't make new uses as I have pointed out in other reviews.
I need to do more analysis whether this can be simplified.

MaskRay requested changes to this revision.Aug 23 2023, 2:18 PM

Thank you for the patch. I think it would actually be nice that we probe the m32 multilib of x86_64-unknown-linux-gnu multilib first for --target=x86_64-unknown-linux-gnu -m32.

Unfortunately, due to various setArch code in computeTargetTriple (e.g. D54214), this change may change what lib they use.
And this well-intended direction is (currently) not feasible without adding more computeTargetTriple like code to Gnu.cpp.
Hopefully that your user can live with the current deficiency.

This revision now requires changes to proceed.Aug 23 2023, 2:18 PM

Thank you for the patch. I think it would actually be nice that we probe the m32 multilib of x86_64-unknown-linux-gnu multilib first for --target=x86_64-unknown-linux-gnu -m32.

Unfortunately, due to various setArch code in computeTargetTriple (e.g. D54214), this change may change what lib they use.

In fact, it won't affect, since the internal triple is used after the arg of --target is used.

And this well-intended direction is (currently) not feasible without adding more computeTargetTriple like code to Gnu.cpp.
Hopefully that your user can live with the current deficiency.

computeTargetTriple should continue be there.

wzssyqa retitled this revision from Clang: GCCInstallationDetector follows -target value first to Clang: GCCInstallationDetector follows --target value first.Aug 23 2023, 7:31 PM
wzssyqa edited the summary of this revision. (Show Details)

For this case (--target is given), maybe we have 2 choice:

Group A, which is quite straight forward, while may broken some use case.

  1. --target=T is given, and no multilib option is given, and we can find the LIBPATH with the same name of T. Let's just use it.
  2. --target=T is given, and no multilib option is given, and we can *NOT* find the LIBPATH with the same name of T. Let's just trigger an error.
  3. --target=T is given, and multilib option IS given, and we can find the LIBPATH with the same name of T. If T has multilib support, let's use T. If T has no multilib support, let's trigger error.
  4. --target=T is given, and multilib option IS given, and we can *NOT* find the LIBPATH with the same name of T. Let's just trigger an error.

Group B:

  1. --target=T is given, and no multilib option is given, and we can find the LIBPATH with the same name of T. Let's just use it.
  2. --target=T is given, and no multilib option is given, and we can *NOT* find the LIBPATH with the same name of T. We will need try to alter triple, aka "x86_64-linux-gnu" -> "i686-linux-gnu -m64"
  3. --target=T is given, and multilib option IS given, and we can find the LIBPATH with the same name of T. If T has multilib support, let's use T. If T has no multilib support, we will need try to alter triple.
  4. --target=T is given, and multilib option IS given, and we can *NOT* find the LIBPATH with the same name of T. We will need try to alter triple.

I prefer Group A.