[llvm] [LLVM][TargetParser] Handle -msys targets the same as -cygwin. (PR #136817)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 22 23:36:47 PDT 2025


https://github.com/jeremyd2019 created https://github.com/llvm/llvm-project/pull/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.

>From 3af974ec92676c8e5e85902d4f3325fd45cfe174 Mon Sep 17 00:00:00 2001
From: Jeremy Drake <github at jdrake.com>
Date: Tue, 22 Apr 2025 23:34:29 -0700
Subject: [PATCH] [LLVM][TargetParser] Handle -msys targets the same as
 -cygwin.

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.
---
 llvm/lib/TargetParser/Triple.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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;



More information about the llvm-commits mailing list