On Sat, 21 Jun 2025, Pali Rohár wrote:

AM_CFLAGS contains cflags required to build the mingw-w64 CRT source code.
They are not intended to compile applications (including those used in
mingw-w64 testsuite). Setting per-target <target>_CFLAGS variable
overwrites the AM_CFLAGS. So for every testcase sets the custom
<target>_CFLAGS variable. This ensures that the testcase would not be
compiled with -D_CRTBLD or -D__MSVCRT_VERSION__=0x600 which is unsuitable
when the mingw-w64 uses the UCRT by default.
---
Should be applied on top of the:
- "crt: Improve LFS 64-bit functions"
- "crt: Improve LFS 64-bit functions (part 2)"
- crt: Fix _*stat32 and _*stat32i64 functions for 64-bit msvcrt.dll builds
---
mingw-w64-crt/Makefile.am                   | 73 +++++++++++++++++++--
mingw-w64-crt/testcases/complex/Makefile.am | 50 ++++++++++++++
2 files changed, 116 insertions(+), 7 deletions(-)

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 4582a23ecab1..ef5f636cf7ca 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -4433,17 +4433,76 @@ testcase_progs = \
  testcases/t_wreaddir \
  testcases/t_fseeko64

-testcases_tstmaincpp_SOURCES = testcases/tstmaincpp.cpp
-testcases_t_trycatch_SOURCES = testcases/t_trycatch.cpp
-testcases_t_intrinc_CFLAGS = -std=c99
+testcaseunicode_progs = \
+  testcases/t_municode \
+  testcases/t_tmain \
+  testcases/t__wstat_all

if ENABLE_TESTS_UNICODE
-  testcase_progs += testcases/t_municode testcases/t_tmain 
testcases/t__wstat_all
-  testcases_t_municode_CFLAGS = -municode
-  testcases_t_tmain_CFLAGS = -municode -D_UNICODE
-  testcases_t__wstat_all = -municode
+  testcase_progs += $(testcaseunicode_progs)
endif

+# Overwrite all CRT specific build flags which are in AM_CFLAGS
+# Setting the target specific *_CFLAGS variable overrides AM_CFLAGS
+testcase_CFLAGS = @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
+testcaseunicode_CFLAGS = $(testcase_CFLAGS) -municode
+
+# Every non-unicode test has to set its CFLAGS to $(testcase_CFLAGS)
+testcases_tstmainc_CFLAGS = $(testcase_CFLAGS)
+testcases_tstmaincpp_CFLAGS = $(testcase_CFLAGS)
+testcases_tstmain_sys_xxx_CFLAGS = $(testcase_CFLAGS)

This feels quite annoying to have to list/repeat all the targets like this. (I do see we have even more verbose things for the complex tests below as well.) Is it possible to have this expanded automatically via some make level loop, like $(foreach) or so? I'm not entirely sure...

// Martin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to