Skip to content

Commit b5d18b8

Browse files
Ramsay Jonesgitster
authored andcommitted
Fix the exit code of MSVC build scripts on cygwin
During an MSVC build on cygwin, the make program did not notice when the compiler or linker exited with an error. This was caused by the scripts exiting with the value returned by system() directly. On POSIX-like systems, such as cygwin, the return value of system() has the exit code of the executed command encoded in the first byte (ie the value is shifted up by 8 bits). This allows the bottom 7 bits to contain the signal number of a terminated process, while the eighth bit indicates whether a core-dump was produced. (A value of -1 indicates that the command failed to execute.) The make program, however, expects the exit code to be encoded in the bottom byte. Futhermore, it apparently masks off and ignores anything in the upper bytes. However, these scripts are (naturally) intended to be used on the windows platform, where we can not assume POSIX-like semantics from a perl implementation (eg ActiveState). So, in general, we can not assume that shifting the return value right by eight will get us the exit code. In order to improve portability, we assume that a zero return from system() indicates success, whereas anything else indicates failure. Since we don't need to know the exact exit code from the compiler or linker, we simply exit with 0 (success) or 1 (failure). Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f2d50d9 commit b5d18b8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compat/vcbuild/scripts/clink.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@
4545
push(@args, @cflags);
4646
}
4747
#printf("**** @args\n");
48-
exit system(@args);
48+
exit (system(@args) != 0);

compat/vcbuild/scripts/lib.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
}
2424
unshift(@args, "lib.exe");
2525
# printf("**** @args\n");
26-
exit system(@args);
26+
exit (system(@args) != 0);

0 commit comments

Comments
 (0)