-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Triple::normalize: Use none as OS for XX-none-ABI #89638
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
@llvm/pr-subscribers-clang @llvm/pr-subscribers-libcxx Author: YunQiang Su (wzssyqa) ChangesIf the middle component of a 3-component triple fails to parse as known Arch/Vendor/OS/Env, it will fallback as Vendor. While for some cases, we may wish to recognize it as OS, such as In this patch, we will set OS as Fixes: #89582. Full diff: https://github.com/llvm/llvm-project/pull/89638.diff 2 Files Affected:
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
"${@}"
${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
- mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* "${BUILD_DIR}/install/lib"
+ mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* "${BUILD_DIR}/install/lib"
check-runtimes
}
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 77fdf31d4865c0..07f3df4145dad4 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1149,6 +1149,13 @@ std::string Triple::normalize(StringRef Str) {
}
}
+ // For 3-component triples, the middle component is used to set Vendor;
+ // while if it is "none", we'd prefer to set OS.
+ // This is for some baremetal cases, such as "arm-none-elf".
+ if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+ Components[1].equals("none") && Components[2].empty())
+ std::swap(Components[1], Components[2]);
+
// Replace empty components with "unknown" value.
for (StringRef &C : Components)
if (C.empty())
|
@peterwaller-arm Ohh, there is so many |
@llvm/pr-subscribers-backend-arm @llvm/pr-subscribers-backend-aarch64 |
I have tested building a toolchain using I concur with Sander that it seems prudent to have the functional change in its own commit, in case it requires further revert flip-flop. |
In current test cases, which were likely generated using clang. So they are likely not relying on that exact form of the triple, it's just what clang put out at the time. So they don't prove anything either way, unless they fail after this change of course. Thank you Peter for testing this PR, I've also asked another downstream team to test their bare metal builds with this. That'll be our best indication for now if this makes sense. |
I've just posted an RFC to discourse about how to handle triple normalization: https://discourse.llvm.org/t/rfc-baremetal-target-triple-normalization/78524 |
We don't need to revert #89234 |
The description is a bit difficult to parse. I'll suggest that using some grammar checker to fix the description. https://discourse.llvm.org/t/rfc-baremetal-target-triple-normalization/78524/8
|
Thanks @wzssyqa again for implementing this and splitting bits out per Sander's suggestion. I propose we merge these changes tomorrow, on the understanding that each of the two patches (this and #90313) are passing tests. It looks to me like you're working towards that goal. What I see in CI for this PR is Is it possible to have two patches such that they're both green? My expectation is that the majority of the triple changes in the source are unrelated to normalization and would work the same before and after the functional changes to triple normalization. (And that those tests which are impacted by changes to triple normalization should of course change in the same commit to keep things green). |
@peterwaller-arm It seems OK now. Let's wait the result of CI. |
Suggested: When parsing a 3-component triple, after we determine Arch and Env, if the middle component is "none", treat it as OS instead of Vendor. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
e238896
to
f5aca8b
Compare
I'm checking the picolib libcxx build right now so please hold off on landing this. |
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.
Thanks for doing this and waiting for RFC comments.
I think this can be merged, the one thing which needs fixing is removing the change I've commented on so that the picolibc builder can succeed (it uses a version of clang on the builder, which @DavidSpickett will update at the right time).
Also this change should be release noted with a tip that build scripts may want to change to asking clang for the triple instead. |
When parsing a 3-component triple, after we determine Arch and Env, if the middle component is "none", treat it as OS instead of Vendor. Fixes: llvm#89582.
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 for supplying a quick fix and iterating this, and thanks for waiting for input on the RFC.
libcxx is sorted, and I will write up the release note given that I suggested it and have been fixing some builds myself. |
That were implemented by llvm#89638.
#90734 provided a release note. The |
@wzssyqa thanks for working with us on this. Bare metal is always a wild card but I think in the end we'll all have cleaner builds because of these changes. |
The way in which clang normalizes certain target triples was recently changed: llvm/llvm-project#89638 This has the effect of switching the vendor and OS from "none-unknown" to "unknown-none" in the normalized triple, to better reflect that the bare metal target has no OS, rather than an unknown one. The cmake script and multilib templates have various hardcoded references to triples which now need changing.
The way in which clang normalizes certain target triples was recently changed: llvm/llvm-project#89638 This has the effect of switching the vendor and OS from "none-unknown" to "unknown-none" in the normalized triple, to better reflect that the bare metal target has no OS, rather than an unknown one. The cmake script and multilib templates have various hardcoded references to triples which now need changing.
When parsing a 3-component triple, after we determine Arch and Env, if the middle component is "none", treat it as OS instead of Vendor.
See: https://discourse.llvm.org/t/rfc-baremetal-target-triple-normalization/78524
Fixes: #89582.