MSYS2-packages/gcc/0008-Cygwin-__cxa-atexit.patch
مهدي شينون (Mehdi Chinoune) 152f0c1987 gcc: update to 15.1.0
2025-06-26 09:34:37 +02:00

52 lines
1.5 KiB
Diff

From 6207948a02e9a116a7c64866235473e89be2edb5 Mon Sep 17 00:00:00 2001
From: Jonathan Yong <10walls@gmail.com>
Date: Thu, 30 Oct 2014 17:15:02 +0800
Subject: [PATCH 08/12] Cygwin: __cxa-atexit
---
gcc/config.gcc | 1 +
libgcc/config/i386/cygming-crtbegin.c | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 5725704e06b..96a8bc2a882 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2843,6 +2843,7 @@ mipstx39-*-elf* | mipstx39el-*-elf*)
mmix-knuth-mmixware)
tm_file="${tm_file} newlib-stdint.h"
use_gcc_stdint=wrap
+ default_use_cxa_atexit=yes
;;
mn10300-*-*)
tm_file="elfos.h newlib-stdint.h ${tm_file}"
diff --git a/libgcc/config/i386/cygming-crtbegin.c b/libgcc/config/i386/cygming-crtbegin.c
index f742a3be2cd..ec4616fbc78 100644
--- a/libgcc/config/i386/cygming-crtbegin.c
+++ b/libgcc/config/i386/cygming-crtbegin.c
@@ -103,6 +103,9 @@ void *__dso_handle = &__ImageBase;
void *__dso_handle = 0;
#endif
+/* see atexit.c in newlib Cygwin */
+extern int __cxa_atexit(void (*)(void *), void *, void *);
+
#endif /* __CYGWIN__ */
@@ -145,7 +148,11 @@ __gcc_register_frame (void)
/* If we use the __cxa_atexit method to register C++ dtors
at object construction, also use atexit to register eh frame
info cleanup. */
+#ifdef __CYGWIN__
+ __cxa_atexit((void *)__gcc_deregister_frame, NULL, (void *)&__dso_handle);
+#else
atexit(__gcc_deregister_frame);
+#endif /* __CYGWIN__ */
#endif /* DEFAULT_USE_CXA_ATEXIT */
}
--
2.45.1