Skip to content

Commit aafa018

Browse files
committed
Triple::normalize: Use none as OS for XX-none-ABI
When we parse 3-components triples, if the Arch and Env have been parsed successfully, we have to make a choice between Vendor and OS for the unrecoginzed component. Noramlly it is the middle one. In the current code, Vendor is choosed, and then OS is fallbacked to unknown. It is OK for most cases. But if the unrecoginzed component is `none`, it is expected to be OS instead of Vendor. Fixes: #89582.
1 parent e04df69 commit aafa018

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

clang/docs/Multilib.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ For a more comprehensive example see
188188
- Dir: thumb/v6-m
189189
# List of one or more normalized command line options, as generated by Clang
190190
# from the command line options or from Mappings below.
191-
# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
191+
# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
192192
# then this multilib variant will be considered a match.
193-
Flags: [--target=thumbv6m-none-unknown-eabi]
193+
Flags: [--target=thumbv6m-unknown-none-eabi]
194194
195195
# Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
196196
# point unit).

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
@@ -1151,6 +1151,13 @@ std::string Triple::normalize(StringRef Str) {
11511151
}
11521152
}
11531153

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

0 commit comments

Comments
 (0)