Skip to content

Conversation

@jeremyd2019
Copy link
Contributor

@jeremyd2019 jeremyd2019 commented Apr 14, 2025

GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit.

Adjust test to expect this change.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Apr 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 14, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: None (jeremyd2019)

Changes

GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit.

Adjust test to expect this change.

/cc @mstrosjo @mati865


Full diff: https://github.com/llvm/llvm-project/pull/135701.diff

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+2-1)
  • (modified) clang/test/Driver/cxa-atexit.cpp (+4-3)
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"

@jeremyd2019
Copy link
Contributor Author

Noticed while g++ -S to clang++ -S output while tracking another issue.

@github-actions
Copy link

github-actions bot commented Apr 14, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit.

Adjust test to expect this change.

Signed-off-by: Jeremy Drake <[email protected]>
@jeremyd2019 jeremyd2019 force-pushed the clang-cygwin-cxa-atexit branch from e3ff93c to 7ee517d Compare April 14, 2025 23:59
@jeremyd2019
Copy link
Contributor Author

I don't have rights to push/merge. (I seem to remember being asked to mention this in the past)

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mstorsjo mstorsjo merged commit ca3a5d3 into llvm:main Apr 23, 2025
10 of 11 checks passed
@jeremyd2019 jeremyd2019 deleted the clang-cygwin-cxa-atexit branch April 23, 2025 06:49
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit.

Adjust test to expect this change.
jeremyd2019 added a commit to jeremyd2019/llvm-project that referenced this pull request May 14, 2025
GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit.

Adjust test to expect this change.
jeremyd2019 added a commit to jeremyd2019/llvm-project that referenced this pull request May 15, 2025
GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit.

Adjust test to expect this change.
jeremyd2019 added a commit to jeremyd2019/llvm-project that referenced this pull request Aug 9, 2025
GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit.

Adjust test to expect this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants