diff mbox series

Always -lntdll for all cygming targets [PR113501]

Message ID SA1PR11MB71304B07EF142DB6BC4FA61CB2CA2@SA1PR11MB7130.namprd11.prod.outlook.com
State New
Headers show
Series Always -lntdll for all cygming targets [PR113501] | expand

Commit Message

Shengdun Wang June 22, 2024, 9:15 p.m. UTC
From: Shengdun Wang <uwgghhbcad@gmail.com>

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 mbox series

Patch

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