Skip to content

Commit 5aa6eaf

Browse files
authored
v.builder: fix cross compiling from linux to windows with -os windows -subsystem windows (#22487)
1 parent 11551aa commit 5aa6eaf

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

vlib/v/builder/cc.v

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
377377
}
378378
}
379379
if v.pref.os == .windows {
380-
ccoptions.post_args << '-municode'
380+
ccoptions.post_args << v.get_subsystem_flag()
381381
}
382382
cflags := v.get_os_cflags()
383383

@@ -811,6 +811,14 @@ fn (mut b Builder) ensure_freebsdroot_exists(sysroot string) {
811811
}
812812
}
813813

814+
fn (mut b Builder) get_subsystem_flag() string {
815+
return match b.pref.subsystem {
816+
.auto { '-municode' }
817+
.console { '-municode -mconsole' }
818+
.windows { '-municode -mwindows' }
819+
}
820+
}
821+
814822
fn (mut b Builder) cc_linux_cross() {
815823
b.setup_ccompiler_options(b.pref.ccompiler)
816824
b.build_thirdparty_obj_files()
@@ -1014,8 +1022,7 @@ fn (mut c Builder) cc_windows_cross() {
10141022
all_args << debug_options
10151023

10161024
all_args << args
1017-
1018-
all_args << '-municode'
1025+
all_args << c.get_subsystem_flag()
10191026
all_args << c.ccoptions.linker_flags
10201027
all_args << '${c.pref.ldflags}'
10211028
c.dump_c_options(all_args)

0 commit comments

Comments
 (0)