From f2d50d937bd17eb413cb78ccb37c17c2d933f76d Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 8 Oct 2009 16:21:44 +0100 Subject: [PATCH 1/2] Fix MSVC build on cygwin In the MSVC section of the Makefile, BASIC_CFLAGS is set to a value which contains the string "-DWIN32-D_CONSOLE". This results in a (single) malformed -Define being passed to the compiler. At least on my cygwin installation, the msvc compiler seems to ignore this parameter, without issuing an error or warning, and results in the WIN32 and _CONSOLE macros being undefined. This breaks the build. In order to fix the build, we simply insert a space between the two -Define parameters, "-DWIN32" and "-D_CONSOLE", as originally intended. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 12defd4c97..ae9bb03382 100644 --- a/Makefile +++ b/Makefile @@ -914,7 +914,7 @@ ifdef MSVC CC = compat/vcbuild/scripts/clink.pl AR = compat/vcbuild/scripts/lib.pl CFLAGS = - BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32-D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE + BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE COMPAT_OBJS = compat/msvc.o compat/fnmatch/fnmatch.o compat/winansi.o COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -DSTRIP_EXTENSION=\".exe\" BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib From b5d18b8e6f68746a85edfea08e9aff3351d7e891 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 8 Oct 2009 16:33:31 +0100 Subject: [PATCH 2/2] 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 Signed-off-by: Junio C Hamano --- compat/vcbuild/scripts/clink.pl | 2 +- compat/vcbuild/scripts/lib.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl index 0ffd59f9fb..f9528c0ea1 100644 --- a/compat/vcbuild/scripts/clink.pl +++ b/compat/vcbuild/scripts/clink.pl @@ -45,4 +45,4 @@ if ($is_linking) { push(@args, @cflags); } #printf("**** @args\n"); -exit system(@args); +exit (system(@args) != 0); diff --git a/compat/vcbuild/scripts/lib.pl b/compat/vcbuild/scripts/lib.pl index 68f66446ea..d8054e469f 100644 --- a/compat/vcbuild/scripts/lib.pl +++ b/compat/vcbuild/scripts/lib.pl @@ -23,4 +23,4 @@ while (@ARGV) { } unshift(@args, "lib.exe"); # printf("**** @args\n"); -exit system(@args); +exit (system(@args) != 0);