Skip to content

Commit 6900e90

Browse files
authored
[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.
1 parent d664c42 commit 6900e90

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

llvm/lib/TargetParser/Triple.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,8 @@ std::string Triple::normalize(StringRef Str, CanonicalForm Form) {
11501150
OSType OS = UnknownOS;
11511151
if (Components.size() > 2) {
11521152
OS = parseOS(Components[2]);
1153-
IsCygwin = Components[2].starts_with("cygwin");
1153+
IsCygwin = Components[2].starts_with("cygwin") ||
1154+
Components[2].starts_with("msys");
11541155
IsMinGW32 = Components[2].starts_with("mingw");
11551156
}
11561157
EnvironmentType Environment = UnknownEnvironment;
@@ -1195,7 +1196,7 @@ std::string Triple::normalize(StringRef Str, CanonicalForm Form) {
11951196
break;
11961197
case 2:
11971198
OS = parseOS(Comp);
1198-
IsCygwin = Comp.starts_with("cygwin");
1199+
IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys");
11991200
IsMinGW32 = Comp.starts_with("mingw");
12001201
Valid = OS != UnknownOS || IsCygwin || IsMinGW32;
12011202
break;

llvm/unittests/TargetParser/TripleTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,6 +2572,8 @@ TEST(TripleTest, NormalizeWindows) {
25722572
EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32-w64"));
25732573
EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin"));
25742574
EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-cygwin"));
2575+
EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-msys"));
2576+
EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-msys"));
25752577

25762578
EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32"));
25772579
EXPECT_EQ("x86_64-unknown-windows-msvc", Triple::normalize("x86_64-win32"));
@@ -2581,6 +2583,11 @@ TEST(TripleTest, NormalizeWindows) {
25812583
Triple::normalize("x86_64-pc-mingw32-w64"));
25822584
EXPECT_EQ("x86_64-unknown-windows-gnu",
25832585
Triple::normalize("x86_64-mingw32-w64"));
2586+
EXPECT_EQ("x86_64-pc-windows-cygnus", Triple::normalize("x86_64-pc-cygwin"));
2587+
EXPECT_EQ("x86_64-unknown-windows-cygnus",
2588+
Triple::normalize("x86_64-cygwin"));
2589+
EXPECT_EQ("x86_64-pc-windows-cygnus", Triple::normalize("x86_64-pc-msys"));
2590+
EXPECT_EQ("x86_64-unknown-windows-cygnus", Triple::normalize("x86_64-msys"));
25842591

25852592
EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf"));
25862593
EXPECT_EQ("i686-unknown-windows-elf", Triple::normalize("i686-win32-elf"));

0 commit comments

Comments
 (0)