]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Fix the exit code of MSVC build scripts on cygwin
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>
Thu, 8 Oct 2009 15:33:31 +0000 (16:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Oct 2009 05:53:12 +0000 (22:53 -0700)
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 <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/vcbuild/scripts/clink.pl
compat/vcbuild/scripts/lib.pl

index 0ffd59f9fb12e711ff415df8cf9d3be1a1c3988f..f9528c0ea10db41f948e6d24b84125d2d54f6dda 100644 (file)
@@ -45,4 +45,4 @@ if ($is_linking) {
        push(@args, @cflags);
 }
 #printf("**** @args\n");
-exit system(@args);
+exit (system(@args) != 0);
index 68f66446ea5232f3180d8ce74ccb7eae5f3bc93f..d8054e469fe81cff7ac18c436c57e253ec1112ec 100644 (file)
@@ -23,4 +23,4 @@ while (@ARGV) {
 }
 unshift(@args, "lib.exe");
 # printf("**** @args\n");
-exit system(@args);
+exit (system(@args) != 0);