Skip to content

Commit

Permalink
Fix building on Windows with MinGW
Browse files Browse the repository at this point in the history
The flag `--subsystem=windows` is possibly supported by the gnu linker, but
it's not by GCC. So we use `-mwindows` which is supported by GCC. It is
possible that flag also automatically makes GCC link some additional
libraries, but that won't hurt.

Also switch to using `wWinMain`, as the gcc toolchain seems to not accept
a `WinMain` (possibly because of the `-municode` flag). The MSVC toolchain
doesn't seem to mind.

Fixes #4009
  • Loading branch information
PatZim committed Nov 18, 2020
1 parent f0808da commit 200821c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/vm/moar/runner/main.c
Expand Up @@ -202,7 +202,7 @@ int set_std_handle_to_nul(FILE *file, int fd, BOOL read, int std_handle_type) {
#endif

#if defined(_WIN32) && defined(SUBSYSTEM_WINDOWS)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow) {
int wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCmdShow) {
int argc;
LPWSTR *wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
char **argv = MVM_UnicodeToUTF8_argv(argc, wargv);
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/NQP/Config/Rakudo.pm
Expand Up @@ -416,7 +416,7 @@ sub configure_moar_backend {
$nqp_config->{subsystem_win_ld_flags} = '/subsystem:windows';
}
else {
$nqp_config->{subsystem_win_ld_flags} = '--subsystem=windows';
$nqp_config->{subsystem_win_ld_flags} = '-mwindows';
}

push @c_runner_libs, sprintf( $nqp_config->{'moar::ldusr'}, 'Shlwapi' );
Expand Down

0 comments on commit 200821c

Please sign in to comment.