* [PATCH] Fix the exit code of MSVC build scripts on cygwin
@ 2009-10-08 15:33 Ramsay Jones
2009-10-08 20:13 ` Alex Riesen
0 siblings, 1 reply; 4+ messages in thread
From: Ramsay Jones @ 2009-10-08 15:33 UTC (permalink / raw)
To: Junio C Hamano; +Cc: mstormo, GIT Mailing-list
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>
---
Hi *,
I have tried to be conservative with this patch and, although I can
confirm that it works great on cygwin, it should probably be tested
(and Acked) by someone with an MSYS/Mingw installation.
(or whatever Marius has installed :)
ATB,
Ramsay Jones
compat/vcbuild/scripts/clink.pl | 4 +++-
compat/vcbuild/scripts/lib.pl | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl
index 0ffd59f..26aec61 100644
--- a/compat/vcbuild/scripts/clink.pl
+++ b/compat/vcbuild/scripts/clink.pl
@@ -45,4 +45,6 @@ if ($is_linking) {
push(@args, @cflags);
}
#printf("**** @args\n");
-exit system(@args);
+system(@args) == 0
+ or exit 1;
+exit 0;
diff --git a/compat/vcbuild/scripts/lib.pl b/compat/vcbuild/scripts/lib.pl
index 68f6644..c11016d 100644
--- a/compat/vcbuild/scripts/lib.pl
+++ b/compat/vcbuild/scripts/lib.pl
@@ -23,4 +23,6 @@ while (@ARGV) {
}
unshift(@args, "lib.exe");
# printf("**** @args\n");
-exit system(@args);
+system(@args) == 0
+ or exit 1;
+exit 0;
--
1.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix the exit code of MSVC build scripts on cygwin
2009-10-08 15:33 [PATCH] Fix the exit code of MSVC build scripts on cygwin Ramsay Jones
@ 2009-10-08 20:13 ` Alex Riesen
2009-10-09 6:49 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Alex Riesen @ 2009-10-08 20:13 UTC (permalink / raw)
To: Ramsay Jones; +Cc: Junio C Hamano, mstormo, GIT Mailing-list
On Thu, Oct 8, 2009 at 17:33, Ramsay Jones <ramsay@ramsay1.demon.co.uk> wrote:
> diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl
> index 0ffd59f..26aec61 100644
> --- a/compat/vcbuild/scripts/clink.pl
> +++ b/compat/vcbuild/scripts/clink.pl
> @@ -45,4 +45,6 @@ if ($is_linking) {
> push(@args, @cflags);
> }
> #printf("**** @args\n");
> -exit system(@args);
> +system(@args) == 0
> + or exit 1;
> +exit 0;
exit(system(@args) != 0);
Yours looks a little verbose...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix the exit code of MSVC build scripts on cygwin
2009-10-08 20:13 ` Alex Riesen
@ 2009-10-09 6:49 ` Junio C Hamano
2009-10-09 22:04 ` Ramsay Jones
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2009-10-09 6:49 UTC (permalink / raw)
To: Alex Riesen; +Cc: Ramsay Jones, Junio C Hamano, mstormo, GIT Mailing-list
Alex Riesen <raa.lkml@gmail.com> writes:
> On Thu, Oct 8, 2009 at 17:33, Ramsay Jones <ramsay@ramsay1.demon.co.uk> wrote:
>> diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl
>> index 0ffd59f..26aec61 100644
>> --- a/compat/vcbuild/scripts/clink.pl
>> +++ b/compat/vcbuild/scripts/clink.pl
>> @@ -45,4 +45,6 @@ if ($is_linking) {
>> push(@args, @cflags);
>> }
>> #printf("**** @args\n");
>> -exit system(@args);
>> +system(@args) == 0
>> + or exit 1;
>> +exit 0;
>
> exit(system(@args) != 0);
>
> Yours looks a little verbose...
Thanks, will queue with a fixup.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix the exit code of MSVC build scripts on cygwin
2009-10-09 6:49 ` Junio C Hamano
@ 2009-10-09 22:04 ` Ramsay Jones
0 siblings, 0 replies; 4+ messages in thread
From: Ramsay Jones @ 2009-10-09 22:04 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Alex Riesen, mstormo, GIT Mailing-list
Junio C Hamano wrote:
> Alex Riesen <raa.lkml@gmail.com> writes:
>>> -exit system(@args);
>>> +system(@args) == 0
>>> + or exit 1;
>>> +exit 0;
>> exit(system(@args) != 0);
>>
>> Yours looks a little verbose...
>
> Thanks, will queue with a fixup.
>
Thanks! (Alex and Junio)
I had this as my penultimate version, so I'm happy.
[I changed it to be more explicit about the actual exit values
returned by the script. (and thus more verbose :) ]
ATB,
Ramsay Jones
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-10 18:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-08 15:33 [PATCH] Fix the exit code of MSVC build scripts on cygwin Ramsay Jones
2009-10-08 20:13 ` Alex Riesen
2009-10-09 6:49 ` Junio C Hamano
2009-10-09 22:04 ` Ramsay Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).