[llvm] [LLVM][Cygwin] Enable conditions that are shared with MinGW (PR #149638)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 18 22:56:34 PDT 2025


https://github.com/jeremyd2019 created https://github.com/llvm/llvm-project/pull/149638

Cygwin and MinGW share the auto import behavior that could result in __stack_check_guard being non-dso-local.  Allow windres to assume a Cygwin target as well as a MinGW one, so defines like _WIN32 would not be present on Cygwin.

>From 798a40ade1e4b026e183d6110a5d4fced379172f Mon Sep 17 00:00:00 2001
From: Jeremy Drake <github at jdrake.com>
Date: Fri, 18 Jul 2025 22:54:05 -0700
Subject: [PATCH] [LLVM][Cygwin] Enable conditions that are shared with MinGW

Cygwin and MinGW share the auto import behavior that could result in
__stack_check_guard being non-dso-local.  Allow windres to assume a
Cygwin target as well as a MinGW one, so defines like _WIN32 would not
be present on Cygwin.
---
 llvm/lib/CodeGen/TargetLoweringBase.cpp | 2 +-
 llvm/tools/llvm-rc/llvm-rc.cpp          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index d4a34555ed820..060ec9d9cf0f7 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -2062,7 +2062,7 @@ void TargetLoweringBase::insertSSPDeclarations(Module &M) const {
 
     // FreeBSD has "__stack_chk_guard" defined externally on libc.so
     if (M.getDirectAccessExternalData() &&
-        !TM.getTargetTriple().isWindowsGNUEnvironment() &&
+        !TM.getTargetTriple().isOSCygMing() &&
         !(TM.getTargetTriple().isPPC64() &&
           TM.getTargetTriple().isOSFreeBSD()) &&
         (!TM.getTargetTriple().isOSDarwin() ||
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 73621543848a1..f623342366515 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -201,7 +201,7 @@ std::string getMingwTriple() {
   Triple T(sys::getDefaultTargetTriple());
   if (!isUsableArch(T.getArch()))
     T.setArch(getDefaultFallbackArch());
-  if (T.isWindowsGNUEnvironment())
+  if (T.isOSCygMing())
     return T.str();
   // Write out the literal form of the vendor/env here, instead of
   // constructing them with enum values (which end up with them in



More information about the llvm-commits mailing list