clink.pl: move default linker options for MSVC=1 builds

Move the default `-ENTRY` and `-SUBSYSTEM` arguments for
MSVC=1 builds from `config.mak.uname` into `clink.pl`.
These args are constant for console-mode executables.

Add support to `clink.pl` for generating a Win32 GUI application
using the `-mwindows` argument (to match how GCC does it).  This
changes the `-ENTRY` and `-SUBSYSTEM` arguments accordingly.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This commit is contained in:
Jeff Hostetler
2021-04-05 14:39:33 -04:00
committed by Johannes Schindelin
parent 4a2e42ab88
commit a127f482d5
2 changed files with 12 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ my @cflags = ();
my @lflags = ();
my $is_linking = 0;
my $is_debug = 0;
my $is_gui = 0;
while (@ARGV) {
my $arg = shift @ARGV;
if ("$arg" eq "-DDEBUG") {
@@ -124,11 +125,21 @@ while (@ARGV) {
# let's ignore those
} elsif ("$arg" eq "-fno-stack-protector") {
# eat this
} elsif ("$arg" eq "-mwindows") {
$is_gui = 1;
} else {
push(@args, $arg);
}
}
if ($is_linking) {
if ($is_gui) {
push(@args, "-ENTRY:wWinMainCRTStartup");
push(@args, "-SUBSYSTEM:WINDOWS");
} else {
push(@args, "-ENTRY:wmainCRTStartup");
push(@args, "-SUBSYSTEM:CONSOLE");
}
push(@args, @lflags);
unshift(@args, "link.exe");
} else {