This would hopefully fix some comctl32 test failures which started happening after I changed my nightly winetest runs to build Wine with Clang.
From: Rémi Bernon rbernon@codeweavers.com
Instead of the -mwindows / -mconsole flags with MinGW. --- tools/winegcc/winegcc.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 374f7542cf3..8c9bf6b2bb8 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; @@ -196,7 +195,7 @@ static int force_pointer_size; static const char *image_base; static const char *section_align; static const char *file_align; -static const char *subsystem; +static const char *subsystem = "console"; static const char *entry_point; static struct strarray file_args; static struct strarray linker_args; @@ -547,10 +546,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" ); @@ -605,10 +603,8 @@ static struct strarray get_link_args( const char *output_name ) if (image_base) strarray_add( &flags, strmake("-Wl,-base:%s", image_base )); if (entry_point) strarray_add( &flags, strmake( "-Wl,-entry:%s", entry_point ));
- if (subsystem) - strarray_add( &flags, strmake("-Wl,-subsystem:%s", subsystem )); - else - strarray_add( &flags, strmake("-Wl,-subsystem:%s", is_gui_app ? "windows" : "console" )); + strarray_add( &flags, "-Xlinker" ); + strarray_add( &flags, strmake("-subsystem:%s", subsystem) );
for (i = 0; i < output_debug_files.count; i++) { @@ -1147,8 +1143,9 @@ static void build_spec_obj( const char *spec_file, const char *output_file,
if (!is_shared) { + if (!subsystem) subsystem = "console"; strarray_add(&spec_args, "--subsystem"); - strarray_add(&spec_args, is_gui_app ? "windows" : "console"); + strarray_add(&spec_args, subsystem); if (large_address_aware) strarray_add( &spec_args, "--large-address-aware" ); }
@@ -1334,7 +1331,7 @@ static void build(struct strarray input_files, const char *output)
if (!wine_objdir && !nodefaultlibs) { - if (is_gui_app) + if (subsystem && !strncmp( subsystem, "windows", 7 )) { add_library(lib_dirs, &files, "shell32"); add_library(lib_dirs, &files, "comdlg32"); @@ -1794,12 +1791,12 @@ int main(int argc, char **argv) } else if (strcmp("-mwindows", args.str[i]) == 0) { - is_gui_app = true; + subsystem = "windows"; raw_compiler_arg = 0; } else if (strcmp("-mconsole", args.str[i]) == 0) { - is_gui_app = false; + subsystem = "console"; raw_compiler_arg = 0; } else if (strcmp("-municode", args.str[i]) == 0)
From: Rémi Bernon rbernon@codeweavers.com
This is the default value used by MinGW, while Clang uses version 6.0 by default in MSVC mode. This causes some new test failures when tests executables are built with Clang, as subsystem version >= 6.0 changes the default window border sizes. --- tools/winegcc/winegcc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 8c9bf6b2bb8..8247d35f1a1 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -195,7 +195,7 @@ static int force_pointer_size; static const char *image_base; static const char *section_align; static const char *file_align; -static const char *subsystem = "console"; +static const char *subsystem = "console:5.2"; static const char *entry_point; static struct strarray file_args; static struct strarray linker_args; @@ -501,6 +501,7 @@ static struct strarray get_link_args( const char *output_name ) struct strarray link_args = get_translator(); struct strarray flags = empty_strarray; unsigned int i; + char *tmp;
strarray_addall( &link_args, linker_args );
@@ -603,6 +604,7 @@ static struct strarray get_link_args( const char *output_name ) if (image_base) strarray_add( &flags, strmake("-Wl,-base:%s", image_base )); if (entry_point) strarray_add( &flags, strmake( "-Wl,-entry:%s", entry_point ));
+ if ((tmp = strchr( subsystem, ':' ))) subsystem = strmake( "%.*s,%s", (int)(tmp - subsystem), subsystem, tmp + 1 ); strarray_add( &flags, "-Xlinker" ); strarray_add( &flags, strmake("-subsystem:%s", subsystem) );
@@ -1791,12 +1793,12 @@ int main(int argc, char **argv) } else if (strcmp("-mwindows", args.str[i]) == 0) { - subsystem = "windows"; + subsystem = "windows:5.2"; raw_compiler_arg = 0; } else if (strcmp("-mconsole", args.str[i]) == 0) { - subsystem = "console"; + subsystem = "console:5.2"; raw_compiler_arg = 0; } else if (strcmp("-municode", args.str[i]) == 0)
This would hopefully fix some comctl32 test failures which started happening after I changed my nightly winetest runs to build Wine with Clang.
Is there anything valuable in this that we might want to replicate?
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 it's about system properties, it's more manageable. I thought it showed different controls behavior. I don't think it's worth replicating just now, but this MR's comments could serve as documentation notes if we ever need it.
Jacek Caban (@jacek) commented about tools/winegcc/winegcc.c:
if (image_base) strarray_add( &flags, strmake("-Wl,-base:%s", image_base )); if (entry_point) strarray_add( &flags, strmake( "-Wl,-entry:%s", entry_point ));
if (subsystem)
strarray_add( &flags, strmake("-Wl,-subsystem:%s", subsystem ));
else
strarray_add( &flags, strmake("-Wl,-subsystem:%s", is_gui_app ? "windows" : "console" ));
strarray_add( &flags, "-Xlinker" );
Why is this change needed?
I think tests that require a specific subsystem version should be explicit about it. For the default, it might be better to raise it to match what modern Windows uses.
On Mon Sep 22 12:24:38 2025 +0000, Jacek Caban wrote:
Why is this change needed?
Because clang option uses comma to separate subsystem from version, this confuses the compiler `-Wl` option which also uses comma to separate linker arguments, and it passes the version as a separate argument.