[clang] [Clang] [Driver] use __cxa_atexit by default on Cygwin. (PR #135701)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 14 16:55:16 PDT 2025
https://github.com/jeremyd2019 created https://github.com/llvm/llvm-project/pull/135701
GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit.
Adjust test to expect this change.
/cc @mstrosjo @mati865
>From e3ff93c0aea6648378e1385cb280236c6d580402 Mon Sep 17 00:00:00 2001
From: Jeremy Drake <github at jdrake.com>
Date: Mon, 14 Apr 2025 14:43:42 -0700
Subject: [PATCH] [Clang] [Driver] use __cxa_atexit by default on Cygwin.
GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit.
Adjust test to expect this change.
Signed-off-by: Jeremy Drake <github at jdrake.com>
---
clang/lib/Driver/ToolChains/Clang.cpp | 3 ++-
clang/test/Driver/cxa-atexit.cpp | 7 ++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 13b7b94424999..aa8954804b48b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7230,7 +7230,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// -fuse-cxa-atexit is default.
if (!Args.hasFlag(
options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
- !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
+ !RawTriple.isOSAIX() && (!RawTriple.isOSWindows() ||
+ RawTriple.isWindowsCygwinEnvironment()) &&
((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
KernelOrKext)
diff --git a/clang/test/Driver/cxa-atexit.cpp b/clang/test/Driver/cxa-atexit.cpp
index 537a11a35f51b..8bfb938e8e8e7 100644
--- a/clang/test/Driver/cxa-atexit.cpp
+++ b/clang/test/Driver/cxa-atexit.cpp
@@ -1,15 +1,15 @@
// RUN: %clang -### -target armv7-unknown-windows-msvc -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
// RUN: %clang -### -target armv7-unknown-windows-itanium -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
// RUN: %clang -### -target armv7-unknown-windows-gnu -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
-// RUN: %clang -### -target armv7-unknown-windows-cygnus -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
+// RUN: %clang -### -target armv7-unknown-windows-cygnus -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CYGWIN
// RUN: %clang -### -target i686-unknown-windows-msvc -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
// RUN: %clang -### -target i686-unknown-windows-itanium -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
// RUN: %clang -### -target i686-unknown-windows-gnu -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
-// RUN: %clang -### -target i686-unknown-windows-cygnus -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
+// RUN: %clang -### -target i686-unknown-windows-cygnus -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CYGWIN
// RUN: %clang -### -target x86_64-unknown-windows-msvc -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
// RUN: %clang -### -target x86_64-unknown-windows-itanium -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
// RUN: %clang -### -target x86_64-unknown-windows-gnu -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
-// RUN: %clang -### -target x86_64-unknown-windows-cygnus -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-WINDOWS
+// RUN: %clang -### -target x86_64-unknown-windows-cygnus -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CYGWIN
// RUN: %clang -### -target hexagon-unknown-none -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-HEXAGON
// RUN: %clang -### -target xcore-unknown-none -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-XCORE
// RUN: %clang -### -target armv7-mti-none -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-MTI
@@ -21,6 +21,7 @@
// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-AIX
// CHECK-WINDOWS: "-fno-use-cxa-atexit"
+// CHECK-CYGWIN-NOT: "-fno-use-cxa-atexit"
// CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit"
// CHECK-HEXAGON-NOT: "-fno-use-cxa-atexit"
// CHECK-XCORE: "-fno-use-cxa-atexit"
More information about the cfe-commits
mailing list