Skip to content

Commit 862f0e4

Browse files
jeffhostetlerGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
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 <[email protected]>
1 parent 424d4b3 commit 862f0e4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compat/vcbuild/scripts/clink.pl

+11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
my @lflags = ();
1616
my $is_linking = 0;
1717
my $is_debug = 0;
18+
my $is_gui = 0;
1819
while (@ARGV) {
1920
my $arg = shift @ARGV;
2021
if ("$arg" eq "-DDEBUG") {
@@ -124,11 +125,21 @@
124125
# let's ignore those
125126
} elsif ("$arg" eq "-fno-stack-protector") {
126127
# eat this
128+
} elsif ("$arg" eq "-mwindows") {
129+
$is_gui = 1;
127130
} else {
128131
push(@args, $arg);
129132
}
130133
}
131134
if ($is_linking) {
135+
if ($is_gui) {
136+
push(@args, "-ENTRY:wWinMainCRTStartup");
137+
push(@args, "-SUBSYSTEM:WINDOWS");
138+
} else {
139+
push(@args, "-ENTRY:wmainCRTStartup");
140+
push(@args, "-SUBSYSTEM:CONSOLE");
141+
}
142+
132143
push(@args, @lflags);
133144
unshift(@args, "link.exe");
134145
} else {

config.mak.uname

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ endif
502502
compat/win32/trace2_win32_process_info.o \
503503
compat/win32/dirent.o
504504
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DENSURE_MSYSTEM_IS_SET -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
505-
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE
505+
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO
506506
# invalidcontinue.obj allows Git's source code to close the same file
507507
# handle twice, or to access the osfhandle of an already-closed stdout
508508
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx

0 commit comments

Comments
 (0)