[PATCH] libstdc++: Fix --disable-libstdcxx-verbose abi break [PR115585]

2024-06-22 Thread Shengdun Wang
From: Shengdun Wang 

__glibcxx_assert_fail is not defined when we disable
the libstdcxx-verbose. This causes ABI break when a
binary is compiled with verbose enabled.

libstdc++-v3/ChangeLog:

* src/c++11/assert_fail.cc:
---
 libstdc++-v3/src/c++11/assert_fail.cc | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/src/c++11/assert_fail.cc 
b/libstdc++-v3/src/c++11/assert_fail.cc
index 6d99c7958f3..9ea57ff7e1b 100644
--- a/libstdc++-v3/src/c++11/assert_fail.cc
+++ b/libstdc++-v3/src/c++11/assert_fail.cc
@@ -22,23 +22,28 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
+#include 
+#ifdef _GLIBCXX_VERBOSE_ASSERT
 #include   // for std::fprintf, stderr
+#endif
 #include  // for std::abort
 
-#ifdef _GLIBCXX_VERBOSE_ASSERT
 namespace std
 {
   [[__noreturn__]]
   void
-  __glibcxx_assert_fail(const char* file, int line,
-   const char* function, const char* condition) noexcept
+  __glibcxx_assert_fail( [[maybe_unused]] const char*,
+ [[maybe_unused]] int line,
+[[maybe_unused]] const char* function,
+ [[maybe_unused]] const char* condition) noexcept
   {
+#ifdef _GLIBCXX_VERBOSE_ASSERT
 if (file && function && condition)
   fprintf(stderr, "%s:%d: %s: Assertion '%s' failed.\n",
  file, line, function, condition);
 else if (function)
   fprintf(stderr, "%s: Undefined behavior detected.\n", function);
+#endif
 abort();
   }
 }
-#endif
-- 
2.45.2



[PATCH] libstdc++: Fix --disable-libstdcxx-verbose abi break [PR115585]

2024-06-22 Thread Shengdun Wang
From: Shengdun Wang 

__glibcxx_assert_fail is not defined when we disable
the libstdcxx-verbose. This causes ABI break when a
binary is compiled with verbose enabled.

libstdc++-v3/ChangeLog:

* src/c++11/assert_fail.cc:
---
 libstdc++-v3/src/c++11/assert_fail.cc | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/src/c++11/assert_fail.cc 
b/libstdc++-v3/src/c++11/assert_fail.cc
index 6d99c7958f3..8842bf85cee 100644
--- a/libstdc++-v3/src/c++11/assert_fail.cc
+++ b/libstdc++-v3/src/c++11/assert_fail.cc
@@ -22,23 +22,28 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
+#include 
+#ifdef _GLIBCXX_VERBOSE_ASSERT
 #include   // for std::fprintf, stderr
+#endif
 #include  // for std::abort
 
-#ifdef _GLIBCXX_VERBOSE_ASSERT
 namespace std
 {
   [[__noreturn__]]
   void
-  __glibcxx_assert_fail(const char* file, int line,
-   const char* function, const char* condition) noexcept
+  __glibcxx_assert_fail( [[maybe_unused]] const char*,
+ [[maybe_unused]] int line,
+ [[maybe_unused]] const char* function,
+ [[maybe_unused]] const char* condition) noexcept
   {
+#ifdef _GLIBCXX_VERBOSE_ASSERT
 if (file && function && condition)
   fprintf(stderr, "%s:%d: %s: Assertion '%s' failed.\n",
  file, line, function, condition);
 else if (function)
   fprintf(stderr, "%s: Undefined behavior detected.\n", function);
+#endif
 abort();
   }
 }
-#endif
-- 
2.45.2



[PATCH] libstdc++: Fix --disable-libstdcxx-verbose abi break [PR115585]

2024-06-22 Thread Shengdun Wang
__glibcxx_assert_fail is not defined when we disable
the libstdcxx-verbose. This causes ABI break when a
binary is compiled with verbose enabled.

libstdc++-v3/ChangeLog:

* src/c++11/assert_fail.cc:
---
 libstdc++-v3/src/c++11/assert_fail.cc | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/src/c++11/assert_fail.cc 
b/libstdc++-v3/src/c++11/assert_fail.cc
index 6d99c7958f3..930cabd5ee6 100644
--- a/libstdc++-v3/src/c++11/assert_fail.cc
+++ b/libstdc++-v3/src/c++11/assert_fail.cc
@@ -22,23 +22,28 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // .
 
+#include 
+#ifdef _GLIBCXX_VERBOSE_ASSERT
 #include   // for std::fprintf, stderr
+#endif
 #include  // for std::abort
 
-#ifdef _GLIBCXX_VERBOSE_ASSERT
 namespace std
 {
   [[__noreturn__]]
   void
-  __glibcxx_assert_fail(const char* file, int line,
-   const char* function, const char* condition) noexcept
+  __glibcxx_assert_fail( [[maybe_unused]] const char* file,
+ [[maybe_unused]] int line,
+ [[maybe_unused]] const char* function,
+ [[maybe_unused]] const char* condition) noexcept
   {
+#ifdef _GLIBCXX_VERBOSE_ASSERT
 if (file && function && condition)
   fprintf(stderr, "%s:%d: %s: Assertion '%s' failed.\n",
  file, line, function, condition);
 else if (function)
   fprintf(stderr, "%s: Undefined behavior detected.\n", function);
+#endif
 abort();
   }
 }
-#endif
-- 
2.45.2



[PATCH] Always -lntdll for all cygming targets [PR113501]

2024-06-22 Thread Shengdun Wang
From: Shengdun Wang 

The mcf thread has already linked to -lntdll, and it's confirmed that even 
Windows 95 includes ntdll.dll. Additionally, if users do not use any functions 
from ntdll directly, the inclusion of -lntdll does not result in linking to it. 
Therefore, I propose making it a default toggle to simplify compilation for 
Windows.

On windows 95, if we do -lntdll, it won't still run. I have tried and confirmed 
it.

gcc/ChangeLog:

* config/i386/cygwin.h:
* config/i386/mingw-w64.h:
* config/mingw/mingw32.h:

libgcc/ChangeLog:

* config/i386/t-cygwin:
* config/i386/t-mingw32:
---
 gcc/config/i386/cygwin.h | 2 +-
 gcc/config/i386/mingw-w64.h  | 2 +-
 gcc/config/mingw/mingw32.h   | 4 ++--
 libgcc/config/i386/t-cygwin  | 2 +-
 libgcc/config/i386/t-mingw32 | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h
index 63de10c17d4..8655c9cff43 100644
--- a/gcc/config/i386/cygwin.h
+++ b/gcc/config/i386/cygwin.h
@@ -89,7 +89,7 @@ along with GCC; see the file COPYING3.  If not see
   %{mwindows:-lgdi32 -lcomdlg32} \
   %{fvtable-verify=preinit:-lvtv -lpsapi; \
 fvtable-verify=std:-lvtv -lpsapi} \
-  -ladvapi32 -lshell32 -luser32 -lkernel32"
+  -ladvapi32 -lshell32 -luser32 -lkernel32 -lntdll"
 
 /* To implement C++ function replacement we always wrap the cxx
malloc-like operators.  See N2800 #17.6.4.6 [replacement.functions] */
diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
index dde26413e22..b3d0c94ca5f 100644
--- a/gcc/config/i386/mingw-w64.h
+++ b/gcc/config/i386/mingw-w64.h
@@ -68,7 +68,7 @@ along with GCC; see the file COPYING3.  If not see
 "%{mwindows:-lgdi32 -lcomdlg32} " \
  "%{fvtable-verify=preinit:-lvtv -lpsapi; \
 fvtable-verify=std:-lvtv -lpsapi} " \
-"-ladvapi32 -lshell32 -luser32 -lkernel32"
+"-ladvapi32 -lshell32 -luser32 -lkernel32 -lntdll"
 
 #undef SPEC_32
 #undef SPEC_64
diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h
index fa6e307476c..95353394328 100644
--- a/gcc/config/mingw/mingw32.h
+++ b/gcc/config/mingw/mingw32.h
@@ -117,7 +117,7 @@ along with GCC; see the file COPYING3.  If not see
 "%{mwindows:-lgdi32 -lcomdlg32} " \
  "%{fvtable-verify=preinit:-lvtv -lpsapi; \
 fvtable-verify=std:-lvtv -lpsapi} " \
- "-ladvapi32 -lshell32 -luser32 -lkernel32"
+ "-ladvapi32 -lshell32 -luser32 -lkernel32 -lntdll"
 
 /* Weak symbols do not get resolved if using a Windows dll import lib.
Make the unwind registration references strong undefs.  */
@@ -204,7 +204,7 @@ along with GCC; see the file COPYING3.  If not see
" SHARED_LIBGCC_SPEC " \
%{mcrtdll=crtdll*:-lcoldname} %{!mcrtdll=crtdll*:-lmoldname} \
-lmingwex %{!mcrtdll=*:-lmsvcrt} %{mcrtdll=*:-l%*} \
-   -lkernel32 " MCFGTHREAD_SPEC
+   -lkernel32 -lntdll " MCFGTHREAD_SPEC
 
 #undef STARTFILE_SPEC
 #define STARTFILE_SPEC " \
diff --git a/libgcc/config/i386/t-cygwin b/libgcc/config/i386/t-cygwin
index f85ec24220e..4118534e5f6 100644
--- a/libgcc/config/i386/t-cygwin
+++ b/libgcc/config/i386/t-cygwin
@@ -5,7 +5,7 @@ LIBGCC2_INCLUDES += -I$(srcdir)/../winsup/include \
-I$(srcdir)/../winsup/cygwin/include
 
 # Cygwin-specific parts of LIB_SPEC
-SHLIB_LC = -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32
+SHLIB_LC = -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32 -lntdll
 
 # We have already included one of the t-{dw2,sjlj}-eh fragments for EH_MODEL
 SHLIB_EH_EXTENSION = $(subst -dw2,,-$(EH_MODEL))
diff --git a/libgcc/config/i386/t-mingw32 b/libgcc/config/i386/t-mingw32
index bfdef6723ce..aee08b541cf 100644
--- a/libgcc/config/i386/t-mingw32
+++ b/libgcc/config/i386/t-mingw32
@@ -1,2 +1,2 @@
 # MinGW-specific parts of LIB_SPEC
-SHLIB_LC = -lmingwthrd -lmingw32 -lmingwex -lmoldname -lmsvcrt -ladvapi32 
-lshell32 -luser32 -lkernel32
+SHLIB_LC = -lmingwthrd -lmingw32 -lmingwex -lmoldname -lmsvcrt -ladvapi32 
-lshell32 -luser32 -lkernel32 -lntdll
-- 
2.45.2