-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[clang][AIX] Strip unknown environment component for per target runtime directory #140850
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
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
A more general question: |
I doubt it, this code is extremely messy and there's duplication everywhere, so I suspect that diverged unintentionally |
Yeah, I think I figured it out. I updated my inline comments to suggest a change. It seems |
The reason we didn't need to change |
@llvm/pr-subscribers-clang-driver Author: Jake Egan (jakeegan) ChangesPreviously, when the triple is This ensures the correct runtime path is found if the triple has the -unknown environment component attached. Full diff: https://github.com/llvm/llvm-project/pull/140850.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 664aafad0f680..db37dccbd40b8 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -935,6 +935,15 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
if (auto Path = getPathForTriple(T))
return *Path;
+ if (T.isOSAIX() && T.getEnvironment() == Triple::UnknownEnvironment) {
+ // Strip unknown environment from the triple.
+ const llvm::Triple AIXTriple(
+ llvm::Triple(T.getArchName(), T.getVendorName(),
+ llvm::Triple::getOSTypeName(T.getOS())));
+ if (auto Path = getPathForTriple(AIXTriple))
+ return *Path;
+ }
+
if (T.isOSzOS() &&
(!T.getOSVersion().empty() || !T.getEnvironmentVersion().empty())) {
// Build the triple without version information
diff --git a/clang/test/Driver/aix-print-runtime-dir.c b/clang/test/Driver/aix-print-runtime-dir.c
index ffa4d15c21208..16fe59c918804 100644
--- a/clang/test/Driver/aix-print-runtime-dir.c
+++ b/clang/test/Driver/aix-print-runtime-dir.c
@@ -16,6 +16,11 @@
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir\
// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR64-PER-TARGET %s
+// RUN: %clang -print-runtime-dir --target=powerpc-ibm-aix-unknown \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir\
+// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR-UNKNOWN-ENV %s
+
// PRINT-RUNTIME-DIR: lib{{/|\\}}aix{{$}}
// PRINT-RUNTIME-DIR32-PER-TARGET: lib{{/|\\}}powerpc-ibm-aix{{$}}
// PRINT-RUNTIME-DIR64-PER-TARGET: lib{{/|\\}}powerpc64-ibm-aix{{$}}
+// PRINT-RUNTIME-DIR-UNKNOWN-ENV: lib{{/|\\}}powerpc-ibm-aix
|
@llvm/pr-subscribers-clang Author: Jake Egan (jakeegan) ChangesPreviously, when the triple is This ensures the correct runtime path is found if the triple has the -unknown environment component attached. Full diff: https://github.com/llvm/llvm-project/pull/140850.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 664aafad0f680..db37dccbd40b8 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -935,6 +935,15 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
if (auto Path = getPathForTriple(T))
return *Path;
+ if (T.isOSAIX() && T.getEnvironment() == Triple::UnknownEnvironment) {
+ // Strip unknown environment from the triple.
+ const llvm::Triple AIXTriple(
+ llvm::Triple(T.getArchName(), T.getVendorName(),
+ llvm::Triple::getOSTypeName(T.getOS())));
+ if (auto Path = getPathForTriple(AIXTriple))
+ return *Path;
+ }
+
if (T.isOSzOS() &&
(!T.getOSVersion().empty() || !T.getEnvironmentVersion().empty())) {
// Build the triple without version information
diff --git a/clang/test/Driver/aix-print-runtime-dir.c b/clang/test/Driver/aix-print-runtime-dir.c
index ffa4d15c21208..16fe59c918804 100644
--- a/clang/test/Driver/aix-print-runtime-dir.c
+++ b/clang/test/Driver/aix-print-runtime-dir.c
@@ -16,6 +16,11 @@
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir\
// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR64-PER-TARGET %s
+// RUN: %clang -print-runtime-dir --target=powerpc-ibm-aix-unknown \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir\
+// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR-UNKNOWN-ENV %s
+
// PRINT-RUNTIME-DIR: lib{{/|\\}}aix{{$}}
// PRINT-RUNTIME-DIR32-PER-TARGET: lib{{/|\\}}powerpc-ibm-aix{{$}}
// PRINT-RUNTIME-DIR64-PER-TARGET: lib{{/|\\}}powerpc64-ibm-aix{{$}}
+// PRINT-RUNTIME-DIR-UNKNOWN-ENV: lib{{/|\\}}powerpc-ibm-aix
|
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.
LGTM. Thanks.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/205/builds/10303 Here is the relevant piece of the build log for the reference
|
…me directory (llvm#140850) Previously, when the triple is `powerpc-ibm-aix-unknown`, the driver fails to find subdirectory `lib/powerpc-ibm-aix`. This ensures the correct runtime path is found if the triple has the -unknown environment component attached.
Previously, when the triple is
powerpc-ibm-aix-unknown
, the driver fails to find subdirectorylib/powerpc-ibm-aix
.This ensures the correct runtime path is found if the triple has the -unknown environment component attached.