 
            This would hopefully fix some comctl32 test failures which started happening after I changed my nightly winetest runs to build Wine with Clang.
-- v5: winegcc: Set the default console and windows subsystems version to 6.0. user32/tests: Force console subsystem version 5.2. quartz/tests: Force console subsystem version 5.2. dxgi/tests: Force console subsystem version 5.2. comctl32/tests: Force console subsystem version 5.2. winegcc: Consistently use the subsystem option with Clang and MinGW. winegcc: Support subsystem version number in link.exe-style cmdline.
 
            From: Rémi Bernon rbernon@codeweavers.com
--- tools/winegcc/winegcc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 7322feaaf80..aed4f28616c 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -496,6 +496,7 @@ static struct strarray get_link_args( const char *output_name ) { struct strarray link_args = get_translator(); struct strarray flags = empty_strarray; + char *version;
strarray_addall( &link_args, linker_args );
@@ -601,7 +602,11 @@ static struct strarray get_link_args( const char *output_name ) if (entry_point) strarray_add( &flags, strmake( "-Wl,-entry:%s", entry_point ));
if (subsystem) - strarray_add( &flags, strmake("-Wl,-subsystem:%s", subsystem )); + { + if ((version = strchr( subsystem, ':' ))) subsystem = strmake( "%.*s,%s", (int)(version - subsystem), subsystem, version + 1 ); + strarray_add( &flags, "-Xlinker" ); + strarray_add( &flags, strmake( "-subsystem:%s", subsystem ) ); + } else strarray_add( &flags, strmake("-Wl,-subsystem:%s", is_gui_app ? "windows" : "console" ));
 
            From: Rémi Bernon rbernon@codeweavers.com
Instead of the -mwindows / -mconsole flags with MinGW, effectively setting subsystem to be "console" by default. --- tools/winegcc/winegcc.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index aed4f28616c..ed27279e67b 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -170,7 +170,6 @@ enum file_type { file_na, file_other, file_obj, file_res, file_rc, file_arh, fil static bool is_pe; static bool is_static; static bool is_shared; -static bool is_gui_app; static bool is_unicode_app; static bool is_win16_app; static bool is_arm64x; @@ -542,10 +541,9 @@ static struct strarray get_link_args( const char *output_name ) strarray_add( &flags, "-shared" ); strarray_add( &flags, "-Wl,--kill-at" ); } - else strarray_add( &flags, is_gui_app ? "-mwindows" : "-mconsole" );
if (is_unicode_app) strarray_add( &flags, "-municode" ); - if (subsystem) strarray_add( &flags, strmake("-Wl,--subsystem,%s", subsystem )); + strarray_add( &flags, strmake( "-Wl,--subsystem,%s", subsystem ) );
strarray_add( &flags, "-Wl,--exclude-all-symbols" ); strarray_add( &flags, "-Wl,--nxcompat" ); @@ -601,14 +599,9 @@ static struct strarray get_link_args( const char *output_name )
if (entry_point) strarray_add( &flags, strmake( "-Wl,-entry:%s", entry_point ));
- if (subsystem) - { - if ((version = strchr( subsystem, ':' ))) subsystem = strmake( "%.*s,%s", (int)(version - subsystem), subsystem, version + 1 ); - strarray_add( &flags, "-Xlinker" ); - strarray_add( &flags, strmake( "-subsystem:%s", subsystem ) ); - } - else - strarray_add( &flags, strmake("-Wl,-subsystem:%s", is_gui_app ? "windows" : "console" )); + if ((version = strchr( subsystem, ':' ))) subsystem = strmake( "%.*s,%s", (int)(version - subsystem), subsystem, version + 1 ); + strarray_add( &flags, "-Xlinker" ); + strarray_add( &flags, strmake( "-subsystem:%s", subsystem ) );
STRARRAY_FOR_EACH( file, &output_debug_files ) { @@ -1142,12 +1135,10 @@ static void build_spec_obj( const char *spec_file, const char *output_file, strarray_add(&spec_args, output_name); }
- if (!is_shared) - { - strarray_add(&spec_args, "--subsystem"); - strarray_add(&spec_args, is_gui_app ? "windows" : "console"); - if (large_address_aware) strarray_add( &spec_args, "--large-address-aware" ); - } + strarray_add( &spec_args, "--subsystem" ); + strarray_add( &spec_args, subsystem ); + + if (!is_shared && large_address_aware) strarray_add( &spec_args, "--large-address-aware" );
if (target.platform == PLATFORM_WINDOWS && target.cpu == CPU_i386) strarray_add(&spec_args, "--safeseh"); @@ -1158,12 +1149,6 @@ static void build_spec_obj( const char *spec_file, const char *output_file, strarray_add(&spec_args, entry_point); }
- if (subsystem) - { - strarray_add(&spec_args, "--subsystem"); - strarray_add(&spec_args, subsystem); - } - if (!is_pe) STRARRAY_FOR_EACH( imp, &delayimports ) strarray_add(&spec_args, strmake("-d%s", imp));
strarray_addall( &spec_args, resources ); @@ -1323,7 +1308,7 @@ static void build(struct strarray input_files, const char *output)
if (!wine_objdir && !nodefaultlibs) { - if (is_gui_app) + if (!strncmp( subsystem, "windows", 7 )) { add_library(lib_dirs, &files, "shell32"); add_library(lib_dirs, &files, "comdlg32"); @@ -1353,7 +1338,7 @@ static void build(struct strarray input_files, const char *output) /* set default entry point, if needed */ if (!entry_point) { - if (subsystem && !strcmp( subsystem, "native" )) + if (!strcmp( subsystem, "native" )) entry_point = (is_pe && target.cpu == CPU_i386) ? "DriverEntry@8" : "DriverEntry"; else if (use_msvcrt && !is_shared && !is_win16_app) entry_point = is_unicode_app ? "wmainCRTStartup" : "mainCRTStartup"; @@ -1627,6 +1612,7 @@ int main(int argc, char **argv) int i, c, next_is_arg = 0; int raw_compiler_arg, raw_linker_arg, raw_winebuild_arg; struct strarray args = empty_strarray; + bool is_gui_app = false; const char* option_arg; char* str;
@@ -2058,6 +2044,8 @@ int main(int argc, char **argv) error( "Non-PE builds are not supported on this platform. You need to use something like '--target=%s-windows'.\n", target.cpu == CPU_ARM ? "arm" : "aarch64" );
+ if (!subsystem) subsystem = is_gui_app ? "windows" : "console"; + if (!winebuild) { if (wine_objdir) winebuild = strmake( "%s/tools/winebuild/winebuild%s", wine_objdir, EXEEXT );
 
            From: Rémi Bernon rbernon@codeweavers.com
--- dlls/comctl32/tests/Makefile.in | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/comctl32/tests/Makefile.in b/dlls/comctl32/tests/Makefile.in index ee7fe6527fe..9c17acd77d7 100644 --- a/dlls/comctl32/tests/Makefile.in +++ b/dlls/comctl32/tests/Makefile.in @@ -1,5 +1,6 @@ TESTDLL = comctl32.dll IMPORTS = ole32 user32 gdi32 advapi32 imm32 uxtheme oleacc oleaut32 +EXTRADLLFLAGS = -Wl,--subsystem,console:5.2
SOURCES = \ animate.c \
 
            From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dxgi/tests/Makefile.in | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/dxgi/tests/Makefile.in b/dlls/dxgi/tests/Makefile.in index 43c7a55a88c..add3803ca40 100644 --- a/dlls/dxgi/tests/Makefile.in +++ b/dlls/dxgi/tests/Makefile.in @@ -1,5 +1,6 @@ TESTDLL = dxgi.dll IMPORTS = d3d10_1 dxgi user32 +EXTRADLLFLAGS = -Wl,--subsystem,console:5.2
SOURCES = \ dxgi.c
 
            From: Rémi Bernon rbernon@codeweavers.com
--- dlls/quartz/tests/Makefile.in | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/quartz/tests/Makefile.in b/dlls/quartz/tests/Makefile.in index c3b96272fbf..1dd25efd19f 100644 --- a/dlls/quartz/tests/Makefile.in +++ b/dlls/quartz/tests/Makefile.in @@ -1,5 +1,6 @@ TESTDLL = quartz.dll IMPORTS = strmbase advapi32 d3d9 ddraw dsound msdmo msvfw32 ole32 oleaut32 user32 uuid winmm +EXTRADLLFLAGS = -Wl,--subsystem,console:5.2
SOURCES = \ acmwrapper.c \
 
            From: Rémi Bernon rbernon@codeweavers.com
--- dlls/user32/tests/Makefile.in | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/user32/tests/Makefile.in b/dlls/user32/tests/Makefile.in index bff53de7713..4bc7172bdb9 100644 --- a/dlls/user32/tests/Makefile.in +++ b/dlls/user32/tests/Makefile.in @@ -1,5 +1,6 @@ TESTDLL = user32.dll IMPORTS = user32 gdi32 advapi32 hid imm32 setupapi +EXTRADLLFLAGS = -Wl,--subsystem,console:5.2
testdll_IMPORTS = user32
 
            From: Rémi Bernon rbernon@codeweavers.com
Modern windows uses 10.0, but compiling a program with this version prevents it from running on Windows with STATUS_INVALID_IMAGE_FORMAT. --- tools/winegcc/winegcc.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index ed27279e67b..7458fb08773 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -2045,6 +2045,8 @@ int main(int argc, char **argv) target.cpu == CPU_ARM ? "arm" : "aarch64" );
if (!subsystem) subsystem = is_gui_app ? "windows" : "console"; + if (!strcmp( subsystem, "windows" ) || !strcmp( subsystem, "console" )) + subsystem = strmake( "%s:6.0", subsystem );
if (!winebuild) {
 
            v3: Keep the -mwindows / -mconsole parsing, move initializing subsystem defaults after the argument parsing.
 
            This merge request was approved by Jacek Caban.
 
            The difference seems to be that subsystem >= 6.0 return 4 from GetSystemMetrics(SM_CXSIZEFRAME) while 5.2 returns 8, or something like that. I don't know if it's worth replicating, but with this MR we should be able to select a specific version for some test executable.
If this is the difference, then I'd argue we should probably fix the tests to not depend on that, especially something higher level like dxgi or quartz. What do the failures look like?
 
            On Tue Oct 21 17:34:58 2025 +0000, Elizabeth Figura wrote:
The difference seems to be that subsystem >= 6.0 return 4 from
GetSystemMetrics(SM_CXSIZEFRAME) while 5.2 returns 8, or something like that. I don't know if it's worth replicating, but with this MR we should be able to select a specific version for some test executable. If this is the difference, then I'd argue we should probably fix the tests to not depend on that, especially something higher level like dxgi or quartz. What do the failures look like?
That would be much more work, and it can be done later fairly easily by removing the EXTRADLLFLAGS.
This MR aims at making the compilation consistent between MinGW and Clang and this will make testing easier as it won't depend on the compiler defaults anymore.
See https://test.winehq.org/data/d62035da4aa91327c6e38a2c8a66b829eb0983ed/win22H... for the dxgi failures.



