Skip to content

Commit d8c9a63

Browse files
committed
Triple::normalize: Use none as OS for XX-none-ABI
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: #89582.
1 parent efce8a0 commit d8c9a63

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/docs/Multilib.rst

Lines changed: 2 additions & 2 deletions
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).

llvm/lib/TargetParser/Triple.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,12 @@ std::string Triple::normalize(StringRef Str) {
11511151
}
11521152
}
11531153

1154+
// If "none" is in the middle component in a three-component triple, treat it
1155+
// as the OS (Components[2]) instead of the vendor (Components[1]).
1156+
if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
1157+
Components[1] == "none" && Components[2].empty())
1158+
std::swap(Components[1], Components[2]);
1159+
11541160
// Replace empty components with "unknown" value.
11551161
for (StringRef &C : Components)
11561162
if (C.empty())

0 commit comments

Comments
 (0)