git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: MSVC build broken (on cygwin)

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Oct 3, 2009, 19:36 UTC
Message-ID
<4AC7A7BC.5070608@ramsay1.demon.co.uk>
In-Reply-To
<4AC5B4AE.5070307@gmail.com>
Marius Storm-Olsen wrote:
Show 5 quoted lines
> ...
> Clone the git://repo.or.cz/msvcgit.git, and run the 
> setup_32bit_env.cmd script in there, and you should have everything 
> you need to both compile and link Git with MSVC.
> 

Hmm, I'm trying to avoid YASORD (Yet Another Set Of Redundant Dependencies ;-) On my laptop, I currently have 4 zlib installations, 5 openssl installations, 3 iconv's ...

As I said earlier (see below), I'm not so interested in getting the msvc build to work for me, rather than understand why it works for you, since it should not work!

Having said that, I *may* try to get it working on my cygwin installation. However, I'm much more likely to make some changes to the build/Makefile to allow the dependent libraries to be installed in different locations :) There is nothing wrong with my zlib at C:\zlib.

>> Anyway, the point is *not* to get the msvc build to work for me; rather
>> it is to understand why the build *works* for you. ;-)
> 
> First of all, thanks for the thorough report! :)
You're welcome.
> Second, I just recompiled, and it magically works for me. Why is a 
> good question, since I also think it shouldn't at this point. The
Oh, you *really* don't want "magic" to be the answer... :P
> So, obviously, some magic in there is making it work for me. I have a 
> hard time locating the magic in question though. :-/

Which shell are you using? MSYS-bash? Which make are you using? MSYS-GNU? Which Perl are you using? ActiveState? MSYS?

I'm using cygwin 1.5.22, along with the cygwin versions of bash 3.2, GNU make 3.81, perl 5.8.7

I noticed that the clink.pl script was not returning the correct exit code to the Makefile, which is why I ended up snipping 940 lines of output from the earlier #error demonstration; the Makefile does not notice when the compile exits with an error.

In order to fix this issue for me, I made the following change:
-- >8 --
diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl
index 0ffd59f..3e4e501 100644
--- a/compat/vcbuild/scripts/clink.pl
+++ b/compat/vcbuild/scripts/clink.pl
@@ -45,4 +45,18 @@ if ($is_linking) {
 	push(@args, @cflags);
 }
 #printf("**** @args\n");
-exit system(@args);
+
+system(@args);
+
+if ($? == -1) {
+	print "clink.pl: failed to execute: $!\n";
+	exit 1;
+}
+elsif ($? & 127) {
+	printf "clink.pl: child died with signal %d%s\n",
+		($? & 127), ($? & 128) ? ', coredump.' : '.';
+	exit 1;
+}
+
+exit $? >> 8;
+
-- >8 --

See "perldoc -f system" for more explanation of the above. This is
how it works on unix and unix-alike systems, so this may not work
too well on (say) ActiveState Perl; Dunno. Also, according to this
documentation, the form of the call to system() should result in a
call to an exec function, rather than using a shell; this may or
may not be true on other platforms.

Having fixed that problem, I modified clink.pl again so that it
would run args.exe rather than cl.exe; this allowed me to see,
using: make -> perl -> "system()" -> args.exe, just what will be
passed to the compiler.

Just in case you can't guess, create args.exe from:

    $ cat -n args.c
         1	#include <stdio.h>
         2	
         3	int main(int argc, char *argv[])
         4	{
         5		int i;
         6	
         7		for (i=0; i< argc; i++) {
         8			printf("argv[%d] = '%s'\n", i, argv[i]);
         9		}
        10		exit(1);
        11	}
        12	
    $ 

and put it somewhere in your path (~/bin for me).

    $ make MSVC=1
    GIT_VERSION = 1.6.5.rc1.38.gb4f27.dirty
        * new build flags or prefix
        CC fast-import.o
    argv[0] = 'args'
    argv[1] = '-Fofast-import.o'
    argv[2] = '-c'
    argv[3] = '-nologo'
    argv[4] = 'fast-import.c'
    argv[5] = '-I.'
    argv[6] = '-I../zlib'
    argv[7] = '-Icompat/vcbuild'
    argv[8] = '-Icompat/vcbuild/include'
    argv[9] = '-DWIN32-D_CONSOLE'
    [...snipped...]
    argv[56] = '-Icompat/regex'
    make: *** [fast-import.o] Error 1

Perhaps you could try a similar exercise?

Hmm, do you have any funny environment variables set which msvc is
picking up? 
Oh, what about the CL variable?

> That being said, does adding the space between the defines fix the 
> MSVC compilation using Cygwin's GNU Make? It's none-the-less a correct 
> patch, so you get an ack from me. Thanks!
> 
> Acked-by: Marius Storm-Olsen <mstormo@gmail.com>
> 

Thanks!

ATB,
Ramsay Jones
Previous: Marius Storm-Olsen
Message 7 of 7 in “MSVC build broken (on cygwin)”
  1. Ramsay JonesOct 1, 2009
  2. Marius Storm-OlsenOct 2, 2009
  3. Alex RiesenOct 2, 2009
  4. Marius Storm-OlsenOct 2, 2009
  5. Ramsay JonesOct 3, 2009
  6. Marius Storm-OlsenOct 3, 2009
  7. Ramsay JonesOct 3, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.