Skip to content

Commit 8dbb0c7

Browse files
committed
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.
1 parent ec062f5 commit 8dbb0c7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

libcxx/utils/ci/run-buildbot

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
217217
"${@}"
218218

219219
${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
220-
mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* "${BUILD_DIR}/install/lib"
220+
mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* "${BUILD_DIR}/install/lib"
221221

222222
check-runtimes
223223
}

llvm/lib/TargetParser/Triple.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,13 @@ std::string Triple::normalize(StringRef Str) {
11491149
}
11501150
}
11511151

1152+
// For 3-component triples, the middle component is used to set Vendor;
1153+
// while if it is "none", we'd prefer to set OS.
1154+
// This is for some baremetal cases, such as "arm-none-elf".
1155+
if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1156+
Components[1].equals("none") && Components[2].empty())
1157+
std::swap(Components[1], Components[2]);
1158+
11521159
// Replace empty components with "unknown" value.
11531160
for (StringRef &C : Components)
11541161
if (C.empty())

0 commit comments

Comments
 (0)