https://github.com/wzssyqa updated
https://github.com/llvm/llvm-project/pull/89638
>From d8c9a636b3fbcdcfef6f934780e6cb042a84b23b Mon Sep 17 00:00:00 2001
From: YunQiang Su
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] 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.
---
clang/docs/Multilib.rst | 4 ++--
llvm/lib/TargetParser/Triple.cpp | 6 ++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
- Dir: thumb/v6-m
# List of one or more normalized command line options, as generated by
Clang
# from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
# then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
# Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
# point unit).
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..f3f244c814e7ee 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,12 @@ std::string Triple::normalize(StringRef Str) {
}
}
+ // If "none" is in the middle component in a three-component triple, treat it
+ // as the OS (Components[2]) instead of the vendor (Components[1]).
+ if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+ Components[1] == "none" && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
// Replace empty components with "unknown" value.
for (StringRef : Components)
if (C.empty())
>From 8128b3c6a911b60b7be2dfd93e42b2c726eaa4b1 Mon Sep 17 00:00:00 2001
From: YunQiang Su
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures
---
clang/test/Driver/arm-ias-Wa.s| 2 +-
clang/test/Driver/arm-triple.c| 10 +--
.../Driver/baremetal-multilib-layered.yaml| 2 +-
clang/test/Driver/baremetal-multilib.yaml | 64 +--
clang/test/Driver/baremetal-sysroot.cpp | 2 +-
clang/test/Driver/baremetal.cpp | 2 +-
.../test/Driver/print-multi-selection-flags.c | 14 ++--
.../IncrementalCompilerBuilderTest.cpp| 2 +-
llvm/unittests/TargetParser/TripleTest.cpp| 2 +-
9 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
// RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
// RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
// RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
// RUN: %clang -print-effective-triple \
// RUN: --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
// RUN: | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
// RUN: %clang -print-effective-triple \
// RUN: --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
// RUN: %clang -print-effective-triple \
// RUN: --target=arm-none-eabi -mbig-endian \
// RUN: | FileCheck %s --check-prefix=CHECK-EB
-// CHECK-EB: armebv4t-none-unknown-eabi
+// CHECK-EB: armebv4t-unknown-none-eabi
// RUN: %clang -print-effective-triple \
// RUN: --target=arm-none-eabihf -march=armv4t \
@@ -23,7 +23,7 @@
// RUN: %clang -print-effective-triple \
// RUN: --target=arm-none-eabi -mfloat-abi=hard \
// RUN: | FileCheck %s --check-prefix=CHECK-HF
-// CHECK-HF: armv4t-none-unknown-eabihf
+// CHECK-HF: armv4t-unknown-none-eabihf
// RUN: %clang -print-effective-triple \
// RUN: --target=armeb-none-eabihf -march=armv4t \
@@ -37,7 +37,7 @@
// RUN: %clang -print-effective-triple \
// RUN: --target=arm-none-eabi -mbig-endian -mfloat-abi=hard \
// RUN: | FileCheck %s --check-prefix=CHECK-EB-HF
-// CHECK-EB-HF: armebv4t-none-unknown-eabihf
+// CHECK-EB-HF: armebv4t-unknown-none-eabihf
// RUN: %clang -print-effective-triple \
// RUN: --target=arm-none-eabi