-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Driver] Have getTargetSubDirPath better match get_compiler_rt_target #100091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// Check that clang's and compiler-rt's ideas of per-target runtime dirs match. | ||
|
||
// RUN: %clang -### %s 2>&1 \ | ||
// RUN: --target=amd64-pc-solaris2.11 -fsanitize=undefined \ | ||
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ | ||
// RUN: --sysroot=%S/Inputs/solaris_x86_tree \ | ||
// RUN: | FileCheck --check-prefix=CHECK-SOLARIS-AMD64 %s | ||
|
||
// CHECK-SOLARIS-AMD64: x86_64-pc-solaris2.11/libclang_rt.ubsan_standalone.a | ||
// CHECK-SOLARIS-AMD64-NOT: lib/sunos/libclang_rt.ubsan_standalone-x86_64.a" | ||
|
||
// RUN: %clang -### %s 2>&1 \ | ||
// RUN: --target=sparc64-unknown-linux-gnu -fsanitize=undefined \ | ||
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ | ||
// RUN: --sysroot=%S/Inputs/debian_sparc64_tree \ | ||
// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-SPARC64 %s | ||
|
||
// CHECK-DEBIAN-SPARC64: sparcv9-unknown-linux-gnu/libclang_rt.ubsan_standalone.a | ||
// CHECK-DEBIAN-SPARC64-NOT: lib/linux/libclang_rt.ubsan_standalone-sparcv9.a" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/// Check that clang's idea of runtime dir layout matches e.g. compiler-rt's. | ||
|
||
/// Classical runtime layout. | ||
/// | ||
/// Cannot be tested: clang -print-runtime-dir always prints the new path even | ||
/// if only the old directories exist. | ||
|
||
/// New runtime layout. | ||
|
||
// RUN: mkdir -p %t-runtime/lib/x86_64-pc-solaris2.11 | ||
|
||
/// Canonical triple, 64-bit. | ||
// RUN: %clang -print-runtime-dir --target=x86_64-pc-solaris2.11 \ | ||
// RUN: -resource-dir=%t-runtime \ | ||
// RUN: | FileCheck --check-prefix=RUNTIME-DIR-X86_64 %s | ||
|
||
/// Non-canonical triple, 64-bit. | ||
// RUN: %clang -print-runtime-dir --target=amd64-pc-solaris2.11 \ | ||
// RUN: -resource-dir=%t-runtime \ | ||
// RUN: | FileCheck --check-prefix=RUNTIME-DIR-X86_64 %s | ||
|
||
// RUNTIME-DIR-X86_64: {{.*}}/lib/x86_64-pc-solaris2.11 | ||
|
||
// RUN: mkdir -p %t-runtime/lib/i386-pc-solaris2.11 | ||
|
||
/// Canonical triple, 32-bit. | ||
// RUN: %clang -print-runtime-dir --target=i386-pc-solaris2.11 \ | ||
// RUN: -resource-dir=%t-runtime \ | ||
// RUN: | FileCheck --check-prefix=RUNTIME-DIR-I386 %s | ||
|
||
/// Non-canonical triple, 32-bit. | ||
/// clang doesn't normalize --target=i686-pc-solaris2.11 to i386-pc-solaris2.11 | ||
/// subdir. | ||
|
||
// RUNTIME-DIR-I386: {{.*}}/lib/i386-pc-solaris2.11 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://reviews.llvm.org/D133406
Is this transformation only needed by Solaris? It seems that other OSes are happy with always using x86_64 and not bothering with amd64.
Can you make this Solaris specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not, some BSDs prefer the
amd64
form, too. Besides,get_compiler_rt_target
does it unconditionally, soclang
should match.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that some BSDs used
amd64
but now switched tox86_64
, e.g.x86_64-unknown-openbsd
It's fine that Solaris is different, but I think other OSes don't think this change.
Perhaps get_compiler_rt_target should be changed to affect only Solaris as well, but that change should not be merged to release/19.x to prevent potential disruption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would this change cause harm? If a target uses e.g. an
x86_64-*
orsparcv9-*
triple, it matchescompiler-rt
out of the box and this change doesn't make a difference. If on the other hand a target uses the equivalentamd64-*
orsparc64-*
forms, they need to be transformed to the form thatcompiler-rt
uses unconditionally, otherwiseclang
won't find the runtime libs. This is what this patch does: bringclang
andcompiler-rt
a little bit more in sync, nothing more, nothing less. Where do you see any disruption in that? Fixing tons of link failures in the testsuite isn't my definition of disruption, actually.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this as disruption, but I see
amd64-*
sparcv9
as workarounds. For workarounds, we generally keep their scope as narrow as possible. We don't encourage current or future use cases.I am concerned if supporting
amd64-*
opens the door for incorrectamd64-linux
usage.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is where I think you're fundamentally wrong.
Let me explain, first from a user perspective.
x86_64
andamd64
just as you see fit, and get identical results. It doesn't matter here if the triple was determined automatically byconfig.guess
at LLVM build time (as is the case forsparc64-unknown-linux-gnu
), specified by the user with-DLLVM_HOST_TRIPLE
, or given at compile time with-target
.projects
layout is used.runtimes
layout, the link fails because the runtime libs aren't found with such alternative triples. Note that the user has never been given any indication (warning or error) that there's a problem with that triple, just a link error. This strongly suggests thatclang
is confused in not being able to find it's own runtime libs. That's a bug incllang
, clear as can be.Those alternative forms have worked for years if not decades without any issues, and now they stop only in very specific circumstances. As far as I know, there's never been any indication that/why some forms of triples are better than others.
For comparison's sake, see what GCC (or the GNU toolchain in general) do instead. While they don't take triples at runtime, the configure time handling gives a good indication how this can be done without all those problems:
While users can easily use alternative forms of triples, GCC uses the
AC_CANONICAL_TARGET
/ACX_CANONICAL_TARGET
autoconf macros and only uses the resulting canonicalized triples internally, e.g. when matching in configure scripts. Only in user-facing cases (likegcc -v
output) are the pretty (user-specified) forms used at all.I think this is what LLVM should do, too: canonicalize triples at some point and stick to those canonical forms. The current duplication of (inconsistent) canonicalizions in
getTargetSubDirPath
andget_compiler_rt_target
needs to go. IMO there should be something likeclang -print-canonical-target
or some such, emittingclang
's idea of the canonical form, andcompiler-rt
should just use that rather than second-guessingclang
(or vice versa).This patch is nothing more than a baby step in this direction, removing just one inconsistency we have today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree with the third bullet point.
As is, people are fine with not using the
amd64
triples on all non-Solaris OSes.We strive not to add workarounds that could lure users to do the wrong thing.
Note: We perform basic triple canonicalization (
Triple::normalize
), as you can see from "unknown":That said, we try to keep the code simple. We cannot really do every triple normalization GCC performs.
That's a lot of complexity, workarounds for old systems.
Instead, we should assess every extra rule. It seems that Solaris, a supported OS, still uses
amd64
, so we accept it (with Solaris specific condition so that we know the difference from the generic behavior; and we can drop the behavior once it becomes unneeded)but it's not sufficient justification to extend this to all OSes.
I probably should only accepted https://reviews.llvm.org/D133406 when it was made Solaris specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still don't give any indication why one form of a triple is right and another one wrong, especially when it works in 95+% of the cases. Besides, there's no way a user can even determine what's right and and what's wrong other than spurious link failures.
We're getting absolutely nowhere with this: you keep making assertions without justification. This is a total waste of my time, the whole issue having dragged on for about two years in various forms, amounting to nothing.