[llvm] 6900e90 - [LLVM][TargetParser] Handle -msys targets the same as -cygwin. (#136817)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 24 03:28:31 PDT 2025
Author: jeremyd2019
Date: 2025-04-24T13:28:27+03:00
New Revision: 6900e9026516963ae625b28dded2cdf0bd16e590
URL: https://github.com/llvm/llvm-project/commit/6900e9026516963ae625b28dded2cdf0bd16e590
DIFF: https://github.com/llvm/llvm-project/commit/6900e9026516963ae625b28dded2cdf0bd16e590.diff
LOG: [LLVM][TargetParser] Handle -msys targets the same as -cygwin. (#136817)
MSYS2 uses i686-pc-msys and x86_64-pc-msys as target, and is a fork of
Cygwin. There's an effort underway to try to switch as much as possible
to use -pc-cygwin targets, but the -msys target will be hanging around
for the forseeable future.
Added:
Modified:
llvm/lib/TargetParser/Triple.cpp
llvm/unittests/TargetParser/TripleTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index e9e6f130f757c..74363f8d71b65 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1150,7 +1150,8 @@ std::string Triple::normalize(StringRef Str, CanonicalForm Form) {
OSType OS = UnknownOS;
if (Components.size() > 2) {
OS = parseOS(Components[2]);
- IsCygwin = Components[2].starts_with("cygwin");
+ IsCygwin = Components[2].starts_with("cygwin") ||
+ Components[2].starts_with("msys");
IsMinGW32 = Components[2].starts_with("mingw");
}
EnvironmentType Environment = UnknownEnvironment;
@@ -1195,7 +1196,7 @@ std::string Triple::normalize(StringRef Str, CanonicalForm Form) {
break;
case 2:
OS = parseOS(Comp);
- IsCygwin = Comp.starts_with("cygwin");
+ IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
IsMinGW32 = Comp.starts_with("mingw");
Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
break;
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
index 61b3637bb48e2..e409a3b6a62c5 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -2572,6 +2572,8 @@ TEST(TripleTest, NormalizeWindows) {
EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32-w64"));
EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin"));
EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-cygwin"));
+ EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-msys"));
+ EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-msys"));
EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32"));
EXPECT_EQ("x86_64-unknown-windows-msvc", Triple::normalize("x86_64-win32"));
@@ -2581,6 +2583,11 @@ TEST(TripleTest, NormalizeWindows) {
Triple::normalize("x86_64-pc-mingw32-w64"));
EXPECT_EQ("x86_64-unknown-windows-gnu",
Triple::normalize("x86_64-mingw32-w64"));
+ EXPECT_EQ("x86_64-pc-windows-cygnus", Triple::normalize("x86_64-pc-cygwin"));
+ EXPECT_EQ("x86_64-unknown-windows-cygnus",
+ Triple::normalize("x86_64-cygwin"));
+ EXPECT_EQ("x86_64-pc-windows-cygnus", Triple::normalize("x86_64-pc-msys"));
+ EXPECT_EQ("x86_64-unknown-windows-cygnus", Triple::normalize("x86_64-msys"));
EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf"));
EXPECT_EQ("i686-unknown-windows-elf", Triple::normalize("i686-win32-elf"));
More information about the llvm-commits
mailing list