[libcxx-commits] [libcxx] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)
YunQiang Su via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Apr 22 11:03:43 PDT 2024
https://github.com/wzssyqa updated https://github.com/llvm/llvm-project/pull/89638
>From 8dbb0c749b9eec02b95b338dcb2f467194f97967 Mon Sep 17 00:00:00 2001
From: YunQiang Su <syq at gcc.gnu.org>
Date: Tue, 23 Apr 2024 01:36:17 +0800
Subject: [PATCH] Triple::normalize: Set OS for 3-component triple with none as
middle
If 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 `arm64-none-elf`.
In this patch, we will set OS as `none`, if:
1) Arch is found;
2) Env is found;
3) OS is not found and thus is set as empty;
4) Vendor is not found while is set as "none",
we will swap Component[2] and Component[3].
libcxx/utils/ci/run-buildbot: Use this new triple.
Fixes: #89582.
---
libcxx/utils/ci/run-buildbot | 2 +-
llvm/lib/TargetParser/Triple.cpp | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
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())
More information about the libcxx-commits
mailing list