Am 19.01.2026 um 13:47 schrieb LIU Hao:
My point is that if make starts in the CRT subdirectory before
_mingw_ddk.h is created, it may cause compilers to pick up the system
header. Worse case is that make starts when _mingw_ddk.h is being
created, then the compiler may read an incomplete file.
Maybe it's possible to generate it earlier with configure, by adding
it into `AC_CONFIG_FILES`.
Thanks for the clarification. I think I got your point now.
That should be addressed in the attached patch series by letting the
configure script generate that file like you suggested.
I inserted an additional patch after the first one that should make sure
that the configure script is re-run if necessary on incremental `make`.
Still unsure about the last patch in the series.
Markus
From 22e6bd86d4129f95d40ff534552954b3c93abe32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20M=C3=BCtzel?= <[email protected]>
Date: Mon, 19 Jan 2026 14:48:47 +0100
Subject: [PATCH 1/4] Generate crt/sdks/_mingw_ddk.h with configure script.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The header `_mingw_ddk.h` is included as `sdks/_mingw_ddk.h` from `_mingw.h`
and it must be available before any other target is built.
Generate it using the configure script in the correct relative location to
that header.
Signed-off-by: Markus Mützel <[email protected]>
---
mingw-w64-headers/Makefile.am | 4 ----
mingw-w64-headers/configure.ac | 1 +
mingw-w64-headers/crt/sdks/_mingw_ddk.h.in | 2 +-
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/mingw-w64-headers/Makefile.am b/mingw-w64-headers/Makefile.am
index 6ebeda477..af260e795 100644
--- a/mingw-w64-headers/Makefile.am
+++ b/mingw-w64-headers/Makefile.am
@@ -21,7 +21,6 @@ gdiplushead_HEADERS = @GDIPLUSHEAD_LIST@
wrlhead_HEADERS = @WRLHEAD_LIST@
wrlwrappershead_HEADERS = @WRLWRAPPERSHEAD_LIST@
mingwhelperhead_HEADERS = @MINGWHELPERHEAD_LIST@
-nodist_sdkshead_HEADERS = _mingw_ddk.h
noinst_HEADERS = crt/sdks/_mingw_ddk.h.in
ddkheaddir = $(baseheaddir)/ddk
@@ -413,6 +412,3 @@ include/prsht.h: ;
include/wincrypt.h: ;
endif
-
-_mingw_ddk.h: $(srcdir)/crt/sdks/_mingw_ddk.h.in
- $(SED) s/MINGW_HAS_DDK$$/@MINGW_HAS_DDK@/ $< > $@
diff --git a/mingw-w64-headers/configure.ac b/mingw-w64-headers/configure.ac
index 3211fbd18..bb2d1455d 100644
--- a/mingw-w64-headers/configure.ac
+++ b/mingw-w64-headers/configure.ac
@@ -199,6 +199,7 @@ AC_SUBST([DEFAULT_MSVCRT_VERSION])
AC_CONFIG_FILES([
Makefile
crt/_mingw.h
+ crt/sdks/_mingw_ddk.h
])
AC_OUTPUT
diff --git a/mingw-w64-headers/crt/sdks/_mingw_ddk.h.in
b/mingw-w64-headers/crt/sdks/_mingw_ddk.h.in
index 0978eddeb..564e2e8ac 100644
--- a/mingw-w64-headers/crt/sdks/_mingw_ddk.h.in
+++ b/mingw-w64-headers/crt/sdks/_mingw_ddk.h.in
@@ -1,6 +1,6 @@
#ifndef MINGW_DDK_H
#define MINGW_DDK_H
-#if MINGW_HAS_DDK
+#if @MINGW_HAS_DDK@
#define MINGW_HAS_DDK_H 1
#endif
#endif
--
2.51.0.windows.2
From 7d3133c89ec1617d3749630f69533b162e0648b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20M=C3=BCtzel?= <[email protected]>
Date: Mon, 19 Jan 2026 15:05:25 +0100
Subject: [PATCH 2/4] Trigger a re-run of the configure scripts on incremental
make if needed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Some files are generated from sources when the configure script is run.
Let `make` re-run the corresponding configure script if some of these source
files changed.
Signed-off-by: Markus Mützel <[email protected]>
---
Makefile.am | 8 ++++++++
mingw-w64-crt/Makefile.am | 2 ++
mingw-w64-headers/Makefile.am | 2 ++
mingw-w64-libraries/libmangle/Makefile.am | 2 ++
mingw-w64-libraries/pseh/Makefile.am | 2 ++
mingw-w64-libraries/winpthreads/Makefile.am | 2 ++
mingw-w64-libraries/winstorecompat/Makefile.am | 2 ++
mingw-w64-tools/gendef/Makefile.am | 2 ++
mingw-w64-tools/genidl/Makefile.am | 2 ++
mingw-w64-tools/genpeimg/Makefile.am | 2 ++
mingw-w64-tools/widl/Makefile.am | 2 ++
11 files changed, 28 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index 308b6fd9d..f55ecd929 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,29 +1,37 @@
+CONFIGURE_DEPENDENCIES = Makefile.in
if HEADER
MAYBE_HEADER = mingw-w64-headers
+ CONFIGURE_DEPENDENCIES += $(MAYBE_HEADER)/Makefile.in
$(MAYBE_HEADER)/crt/_mingw.h.in $(MAYBE_HEADER)/crt/sdks/_mingw_ddk.h.in
endif
if CRT
MAYBE_CRT = mingw-w64-crt
+ CONFIGURE_DEPENDENCIES += $(MAYBE_CRT)/Makefile.in
endif
if LIBRARIES_MANGLE
MAYBE_LIBRARIES_MANGLE = mingw-w64-libraries/libmangle
+ CONFIGURE_DEPENDENCIES += $(MAYBE_LIBRARIES_MANGLE)/Makefile.in
endif
if LIBRARIES_PSEH
MAYBE_LIBRARIES_PSEH = mingw-w64-libraries/pseh
+ CONFIGURE_DEPENDENCIES += $(MAYBE_LIBRARIES_PSEH)/Makefile.in
endif
if LIBRARIES_WINPTHREADS
MAYBE_LIBRARIES_WINPTHREADS = mingw-w64-libraries/winpthreads
+ CONFIGURE_DEPENDENCIES += $(MAYBE_LIBRARIES_WINPTHREADS)/Makefile.in
endif
if TOOLS_GENDEF
MAYBE_TOOLS_GENDEF = mingw-w64-tools/gendef
+ CONFIGURE_DEPENDENCIES += $(MAYBE_TOOLS_GENDEF)/Makefile.in
endif
if TOOLS_GENIDL
MAYBE_TOOLS_GENIDL = mingw-w64-tools/genidl
+ CONFIGURE_DEPENDENCIES += $(MAYBE_TOOLS_GENIDL)/Makefile.in
endif
SUBDIRS = $(MAYBE_HEADER) $(MAYBE_CRT) $(MAYBE_LIBRARIES_MANGLE)
$(MAYBE_LIBRARIES_PSEH) $(MAYBE_LIBRARIES_WINPTHREADS) $(MAYBE_TOOLS_GENDEF)
$(MAYBE_TOOLS_GENIDL)
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 74f35ea12..3691a75f2 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -11,6 +11,8 @@
#AUTOMAKE_OPTIONS = color-tests
+CONFIGURE_DEPENDENCIES = Makefile.in testcases/Makefile.in
+
if WITHSYSROOT
sysincludes="-I@TARGET_SYSTEM_ROOT@/include"
withsys="--with-sysroot=@TARGET_SYSTEM_ROOT@"
diff --git a/mingw-w64-headers/Makefile.am b/mingw-w64-headers/Makefile.am
index af260e795..2dcbce950 100644
--- a/mingw-w64-headers/Makefile.am
+++ b/mingw-w64-headers/Makefile.am
@@ -31,6 +31,8 @@ idlhead_HEADERS = @IDLHEAD_LIST@
CLEANFILES = $(nodist_sdkshead_HEADERS)
+CONFIGURE_DEPENDENCIES = Makefile.in crt/_mingw.h.in crt/sdks/_mingw_ddk.h.in
+
DISTCHECK_CONFIGURE_FLAGS = --enable-crt --enable-sdk=all --enable-idl
EXTRA_DIST = $(srcdir)/ChangeLog.* include crt ddk tlb
diff --git a/mingw-w64-libraries/libmangle/Makefile.am
b/mingw-w64-libraries/libmangle/Makefile.am
index 42c332cf5..be2b64c6f 100644
--- a/mingw-w64-libraries/libmangle/Makefile.am
+++ b/mingw-w64-libraries/libmangle/Makefile.am
@@ -1,3 +1,5 @@
+CONFIGURE_DEPENDENCIES = Makefile.in
+
lib_LIBRARIES = libmangle.a
libmangle_a_SOURCES = \
diff --git a/mingw-w64-libraries/pseh/Makefile.am
b/mingw-w64-libraries/pseh/Makefile.am
index ff34dad60..3f2a4a845 100644
--- a/mingw-w64-libraries/pseh/Makefile.am
+++ b/mingw-w64-libraries/pseh/Makefile.am
@@ -1,5 +1,7 @@
AUTOMAKE_OPTIONS = foreign subdir-objects
+CONFIGURE_DEPENDENCIES = Makefile.in
+
AM_CPPFLAGS = -I$(srcdir)/include
AM_CFLAGS = -Wall -Wstrict-aliasing=2 -pedantic
diff --git a/mingw-w64-libraries/winpthreads/Makefile.am
b/mingw-w64-libraries/winpthreads/Makefile.am
index d602e6c64..888b034d4 100644
--- a/mingw-w64-libraries/winpthreads/Makefile.am
+++ b/mingw-w64-libraries/winpthreads/Makefile.am
@@ -1,4 +1,6 @@
+CONFIGURE_DEPENDENCIES = Makefile.in
+
SUBDIRS = . tests
AM_CFLAGS =
diff --git a/mingw-w64-libraries/winstorecompat/Makefile.am
b/mingw-w64-libraries/winstorecompat/Makefile.am
index 22a9eea8c..08a2b07b1 100644
--- a/mingw-w64-libraries/winstorecompat/Makefile.am
+++ b/mingw-w64-libraries/winstorecompat/Makefile.am
@@ -1,5 +1,7 @@
AUTOMAKE_OPTIONS = foreign subdir-objects
+CONFIGURE_DEPENDENCIES = Makefile.in
+
AM_CFLAGS = -Wall -Wstrict-aliasing=2 -pedantic
lib_LIBRARIES = libwinstorecompat.a \
diff --git a/mingw-w64-tools/gendef/Makefile.am
b/mingw-w64-tools/gendef/Makefile.am
index bcd85664c..ae634bb65 100644
--- a/mingw-w64-tools/gendef/Makefile.am
+++ b/mingw-w64-tools/gendef/Makefile.am
@@ -1,3 +1,5 @@
+CONFIGURE_DEPENDENCIES = Makefile.in
+
bin_PROGRAMS = gendef
AM_LDFLAGS = @GENDEF_LDFLAGS@
AM_CPPFLAGS = @GENDEF_CPPFLAGS@
diff --git a/mingw-w64-tools/genidl/Makefile.am
b/mingw-w64-tools/genidl/Makefile.am
index b7c77dc38..2c4709acb 100644
--- a/mingw-w64-tools/genidl/Makefile.am
+++ b/mingw-w64-tools/genidl/Makefile.am
@@ -1,3 +1,5 @@
+CONFIGURE_DEPENDENCIES = Makefile.in
+
bin_PROGRAMS = genidl
genidl_SOURCES = \
diff --git a/mingw-w64-tools/genpeimg/Makefile.am
b/mingw-w64-tools/genpeimg/Makefile.am
index 3f5219b00..bb44164e1 100644
--- a/mingw-w64-tools/genpeimg/Makefile.am
+++ b/mingw-w64-tools/genpeimg/Makefile.am
@@ -1,3 +1,5 @@
+CONFIGURE_DEPENDENCIES = Makefile.in
+
bin_PROGRAMS = genpeimg
genpeimg_SOURCES = src/img.h src/img.c src/img_pe.c src/genpeimg.c
genpeimg_CPPFLAGS = -Isrc
diff --git a/mingw-w64-tools/widl/Makefile.am b/mingw-w64-tools/widl/Makefile.am
index 75558b068..9f0afe0a3 100644
--- a/mingw-w64-tools/widl/Makefile.am
+++ b/mingw-w64-tools/widl/Makefile.am
@@ -1,3 +1,5 @@
+CONFIGURE_DEPENDENCIES = Makefile.in
+
bin_PROGRAMS = widl
widl_SOURCES = src/widl.h \
--
2.51.0.windows.2
From 1983b925fcc6a6900d37369282d4fd8c0c001b5c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20M=C3=BCtzel?= <[email protected]>
Date: Mon, 19 Jan 2026 15:08:29 +0100
Subject: [PATCH 3/4] Prefer headers in the source tree and generated headers
over installed ones
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add `-I` flags to the preprocessor flags that prefer headers in the source
tree or headers the have been generated over ones that are installed.
Signed-off-by: Markus Mützel <[email protected]>
---
mingw-w64-crt/Makefile.am | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 3691a75f2..7ad8aa0c1 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -13,11 +13,11 @@
CONFIGURE_DEPENDENCIES = Makefile.in testcases/Makefile.in
+sysincludes=-I$(top_srcdir)/../mingw-w64-headers/include
-I$(top_srcdir)/../mingw-w64-headers/crt
-I$(top_builddir)/../mingw-w64-headers/crt
if WITHSYSROOT
- sysincludes="-I@TARGET_SYSTEM_ROOT@/include"
+ sysincludes += "-I@TARGET_SYSTEM_ROOT@/include"
withsys="--with-sysroot=@TARGET_SYSTEM_ROOT@"
else
- sysincludes=
withsys=
endif
--
2.51.0.windows.2
From 756a34ef2fe4be32a05f63dec80b30f71cc91f8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20M=C3=BCtzel?= <[email protected]>
Date: Mon, 19 Jan 2026 15:11:46 +0100
Subject: [PATCH 4/4] Use in-tree and generated headers and built libraries in
tests.
---
mingw-w64-crt/testcases/Makefile.am | 28 +++++++++++++++++++--
mingw-w64-crt/testcases/complex/Makefile.am | 6 +++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-crt/testcases/Makefile.am
b/mingw-w64-crt/testcases/Makefile.am
index 45a61d6dc..6f3006e3e 100644
--- a/mingw-w64-crt/testcases/Makefile.am
+++ b/mingw-w64-crt/testcases/Makefile.am
@@ -1,6 +1,30 @@
+sysincludes=-I$(top_srcdir)/../mingw-w64-headers/include
-I$(top_srcdir)/../mingw-w64-headers/crt
-I$(top_builddir)/../mingw-w64-headers/crt
+if WITHSYSROOT
+ sysincludes += "-I@TARGET_SYSTEM_ROOT@/include"
+ withsys="--with-sysroot=@TARGET_SYSTEM_ROOT@"
+else
+ withsys=
+endif
+
TEST_CFLAGS=-Wno-format -Wno-unused-parameter -Wno-error=unused-function
-AM_CFLAGS=@ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@ $(TEST_CFLAGS)
-Wno-missing-prototypes
-AM_CXXFLAGS=@ADD_C_CXX_WARNING_FLAGS@ @ADD_CXX_ONLY_WARNING_FLAGS@
$(TEST_CFLAGS)
+AM_CFLAGS=$(sysincludes) @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
$(TEST_CFLAGS) -Wno-missing-prototypes
+AM_CXXFLAGS=$(sysincludes) @ADD_C_CXX_WARNING_FLAGS@
@ADD_CXX_ONLY_WARNING_FLAGS@ $(TEST_CFLAGS)
+if LIB64
+AM_LDFLAGS=-L$(top_builddir)/lib64
+else
+if LIB32
+AM_LDFLAGS=-L$(top_builddir)/lib32
+else
+if LIBARM64
+AM_LDFLAGS=-L$(top_builddir)/libarm64
+else
+if LIBARM32
+AM_LDFLAGS=-L$(top_builddir)/libarm32
+endif
+endif
+endif
+endif
+
# Testsuite options
#
diff --git a/mingw-w64-crt/testcases/complex/Makefile.am
b/mingw-w64-crt/testcases/complex/Makefile.am
index 013758e22..173259dbe 100644
--- a/mingw-w64-crt/testcases/complex/Makefile.am
+++ b/mingw-w64-crt/testcases/complex/Makefile.am
@@ -46,6 +46,11 @@
# Due to automake limitations, references are relative to the top level,
# and not the subdirectory in which this resides.
+CPPFLAGS32 ?= $(AM_CPPFLAGS)
+CPPFLAGS64 ?= $(AM_CPPFLAGS)
+LDFLAGS32 ?= $(AM_LDFLAGS)
+LDFLAGS64 ?= $(AM_LDFLAGS)
+
# Complex library check sources.
check_complex_lib_sources = \
complex/complex_test.h \
@@ -244,6 +249,7 @@ endif LIB32
# 64 bit tests.
if LIB64
+
# Complex library support libs.
newcomplex_test_lib64 = \
tests64/libnewcomplextestsf.a \
--
2.51.0.windows.2
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public