[PATCH] mingw: Remove outdated /mingw stuff

Zhongteng Gui <[email protected]> Mon, 3 Aug 2026 09:46:11 +0800
Newsgroups gmane.comp.gcc.patches
Message-ID <SL2P216MB22717114111DEAE1B3B84454EFD52@SL2P216MB2271.KORP216.PROD.OUTLOOK.COM>
/mingw is only used by MSYS 1, which has been obsolete for a long time.
The current users of target *-w64-mingw32 either uses their own prefix
(MSYS2 and its derivatives, w64devkit, etc.), or use the default prefix
/usr (Cross-compiling on linux, e.g. Conda-forge).

Native mingw users usually use --sysroot=<prefix>, so don't hardcode
NATIVE_SYSTEM_HEADER_DIR to /mingw/include, but use the default
/usr/include (and can be overridden by --with-native-system-header-dir).
Similar logic for STANDARD_STARTFILE_PREFIX_{1,2}, but since
STANDARD_STARTFILE_PREFIX_2 can not be overridden from configure, we set
it to empty for native builds because /usr/lib is not used for native
builds. Cross-compiling users can still use the default /usr/lib.

local_include_dir is previously set to <prefix>/include in
config/i386/x-mingw32, which forbids distributions to set their own
local include dir, so we use the value from --with-local-prefix instead.

ChangeLog:

	PR target/126608
	* configure.ac (x86_64-*mingw* | *-w64-mingw*): Do not use
	/mingw symlink.

gcc/ChangeLog:

	PR target/126608
	* config.gcc (-mingw*): Don't hardcode native_system_header_dir
	to /mingw/include.
	* config/mingw/mingw32.h: Don't hardcode /mingw stuff.
	(STANDARD_STARTFILE_PREFIX_1): Use the default /lib.
	(STANDARD_STARTFILE_PREFIX_2): Set to empty for native builds,
	use the default /usr/lib for cross-compiling.
	(NATIVE_SYSTEM_HEADER_DIR): Don't hardcode /mingw/include, use
	value from --with-native-system-header-dir.
	* config/i386/x-mingw32: Don't force changing local_include_dir,
	honor values from --with-local-prefix.

Signed-off-by: Zhongteng Gui <[email protected]>
---
 configure.ac               |  5 ++---
 gcc/config.gcc             |  2 --
 gcc/config/i386/x-mingw32  |  4 ----
 gcc/config/mingw/mingw32.h | 12 ++----------
 4 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index c5de225b0ac..135ed3c5bda 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3948,9 +3948,8 @@ esac
 
 case "$target" in
   x86_64-*mingw* | *-w64-mingw*)
-  # MinGW-w64 does not use newlib, nor does it use winsup. It may,
-  # however, use a symlink named 'mingw' in ${prefix} .
-    FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L${prefix}/${target}/lib -L${prefix}/mingw/lib -isystem ${prefix}/${target}/include -isystem ${prefix}/mingw/include'
+  # MinGW-w64 does not use newlib, nor does it use winsup.
+    FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L${prefix}/${target}/lib -L${prefix}/lib -isystem ${prefix}/${target}/include -isystem ${prefix}/include'
     ;;
   *-mingw*)
   # MinGW can't be handled as Cygwin above since it does not use newlib.
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 8fe99616f82..55339363c6c 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1331,7 +1331,6 @@ aarch64-*-mingw*)
 	tm_file="${tm_file} mingw/winnt-dll.h"
 	tmake_file="${tmake_file} aarch64/t-aarch64"
 	tmake_file="${tmake_file} aarch64/t-aarch64-mingw"
-        native_system_header_dir=/mingw/include
 	target_gtfiles="$target_gtfiles \$(srcdir)/config/mingw/winnt.cc"
 	target_gtfiles="$target_gtfiles \$(srcdir)/config/mingw/winnt-dll.cc"
 	extra_options="${extra_options} mingw/cygming.opt mingw/mingw.opt"
@@ -2339,7 +2338,6 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 			tmake_file="${tmake_file} i386/t-mingw-w32"
 			;;
 	esac
-        native_system_header_dir=/mingw/include
 	target_gtfiles="$target_gtfiles \$(srcdir)/config/mingw/winnt.cc"
 	target_gtfiles="$target_gtfiles \$(srcdir)/config/mingw/winnt-dll.cc"
 	extra_options="${extra_options} mingw/cygming.opt mingw/mingw.opt"
diff --git a/gcc/config/i386/x-mingw32 b/gcc/config/i386/x-mingw32
index 3ac2ba57631..5a0d8b8ec4a 100644
--- a/gcc/config/i386/x-mingw32
+++ b/gcc/config/i386/x-mingw32
@@ -16,10 +16,6 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 #
-#
-# Make local_includedir relative to EXEC_PREFIX 
-#
-local_includedir=$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include
 
 # Add Windows socket library.
 LIBS += -lws2_32
diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h
index 1d319b77bf8..3afbee65974 100644
--- a/gcc/config/mingw/mingw32.h
+++ b/gcc/config/mingw/mingw32.h
@@ -231,17 +231,9 @@ along with GCC; see the file COPYING3.  If not see
   crtend.o%s"
 
 /* Override startfile prefix defaults.  */
-#ifndef STANDARD_STARTFILE_PREFIX_1
-#define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
+#if !defined(STANDARD_STARTFILE_PREFIX_2) && !defined(CROSS_DIRECTORY_STRUCTURE)
+#define STANDARD_STARTFILE_PREFIX_2 "" /* MSYS2 doesn't use /usr/lib for MINGW */
 #endif
-#ifndef STANDARD_STARTFILE_PREFIX_2
-#define STANDARD_STARTFILE_PREFIX_2 ""
-#endif
-
-/* For native mingw-version we need to take care that NATIVE_SYSTEM_HEADER_DIR
-   macro contains POSIX-style path.  See bug 52947.  */
-#undef NATIVE_SYSTEM_HEADER_DIR
-#define NATIVE_SYSTEM_HEADER_DIR "/mingw/include"
 
 /* Output STRING, a string representing a filename, to FILE.
    We canonicalize it to be in Unix format (backslashes are replaced
-- 
2.55.0.windows.3
OpenPGP_0xDC9AEB3A3BE8A3D2.asc (application/pgp-keys, 1 KB)
-----BEGIN PGP PUBLIC KEY BLOCK-----

xjMEaQXagBYJKwYBBAHaRw8BAQdAzlrSWrA5Fc8ErcYHvC10N4Isz5jiHDB+8ht7
u4wbMQfNKWRyYWdvbi1hcmNoZXIgPGRyYWdvbi1hcmNoZXJAb3V0bG9vay5jb20+
wp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wWB5u8hYKJ3tmQA=
=CNJC
-----END PGP SIGNATURE-----