Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

building win32 perl using cygwin

by ysth (Canon)
on Jan 04, 2005 at 01:22 UTC ( [id://419122]=perlmeditation: print w/replies, xml ) Need Help??

Cygwin (a linux emulation layer and toolset for Windows) is capable of building a very unix-like perl, but also bundles parts of MinGW to build windows programs that don't use the emulation layer (invoked by using a -mno-cygwin switch to gcc). While there are instructions and support for building a win32 perl using MinGW proper, doing so with cygwin's MinGW wasn't so straightforward. I'm posting here for posterity what I had to do to get it to work.

First of all, the obvious change to makefile.mk. I didn't bother setting CCHOME (so left it set to the nonexistent C:\MinGW). the concept of having to tell a compiler where the standard include files and libraries are seems a little odd to me. If you really had MinGW and cygwin both installed, you would probably need to change it to prevent conflicts.

--- perlwin32/win32/makefile.mk.orig 2004-11-27 09:26:09.000000000 +-0800 +++ perlwin32/win32/makefile.mk 2005-01-03 11:48:40.477425600 -0800 @@ -394,8 +394,8 @@ LINK_FLAGS += -L"$(CCLIBDIR)\Release" .ELIF "$(CCTYPE)" == "GCC" -CC = gcc -LINK32 = g++ +CC = gcc -mno-cygwin +LINK32 = g++ -mno-cygwin LIB32 = ar rc IMPLIB = dlltool RSC = windres
After that, I had problems with the gcc command line for compiling the c files for extensions. gcc would report "no input files". This change to makemaker fixed it. I'd be curious to know if it causes any harm on any other platform. It's possible that this is a bug in cygwin's gcc, since presumably the regular mingw gcc doesn't have this problem.
--- perlwin32/lib/ExtUtils/MM_Unix.pm.orig 2004-12-15 05:11:11.0000 +00000 -0800 +++ perlwin32/lib/ExtUtils/MM_Unix.pm 2005-01-03 12:23:05.206360000 + -0800 @@ -366,8 +366,8 @@ sub const_cccmd { return $self->{CONST_CCCMD} = q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\ $(CCFLAGS) $(OPTIMIZE) \\ - $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\ - $(XS_DEFINE_VERSION)}; + $(PERLTYPE) $(MPOLLUTE) "$(DEFINE_VERSION)" \\ + "$(XS_DEFINE_VERSION)"}; } =item const_config (o)
Final problem was the building of Errno, which failed for two completely different reasons. First, config.sh didn't have the required compiler settings. I'd be interested to see the output of perl -V:ccname from a regular mingw build, since there may be a problem there also.

Second, the preprocessor was outputing the include file names in as cygwin's posix filenames. To find them, the Errno build script needed to convert to windows filenames. (Presumably h2ph may need a similar change, but I've never had need to use h2ph.)

--- perlwin32/win32/config.gc.orig 2005-01-03 12:44:00.261040000 -0 +800 +++ perlwin32/win32/config.gc 2005-01-03 12:58:26.436539200 -0800 @@ -41,12 +41,12 @@ byteorder='1234' c='' castflags='0' cat='type' -cc='~CC~' +cc='~cc~' cccdlflags=' ' ccdlflags=' ' ccflags='-MD -DWIN32' ccflags_uselargefiles='' -ccname='~CC~' +ccname='~cc~' ccsymbols='' ccversion='' cf_by='nobody' @@ -62,14 +62,14 @@ compress='' contains='grep' cp='copy' cpio='' -cpp='gcc -E' +cpp='~cc~ -E' cpp_stuff='42' cppccsymbols='' cppflags='-DWIN32' cpplast='' cppminus='-' -cpprun='gcc -E' -cppstdin='gcc -E' +cpprun='~cc~ -E' +cppstdin='~cc~ -E' cppsymbols='' crypt_r_proto='0' cryptlib='' @@ -672,7 +672,7 @@ ivsize='4' ivtype='long' known_extensions='~static_ext~ ~dynamic_ext~ ~nonxs_ext~' ksh='' -ld='gcc' +ld='~cc~' lddlflags='-mdll ~LINK_FLAGS~' ldflags='~LINK_FLAGS~' ldflags_uselargefiles='' --- perlwin32/ext/Errno/Errno_pm.PL.orig 2004-12-01 06:11:10.000000 +000 -0800 +++ perlwin32/ext/Errno/Errno_pm.PL 2005-01-03 14:38:44.269758400 - +0800 @@ -20,6 +20,12 @@ unlink "errno.c" if -f "errno.c"; sub process_file { my($file) = @_; + # for win32 perl under cygwin, we need to get a windows pathname + if ($^O eq 'MSWin32' && $Config{cc} =~ /\B-mno-cygwin\b/ && + defined($file) && !-f $file) { + chomp($file = `cygpath -w "$file"`); + } + return unless defined $file and -f $file; # warn "Processing $file\n";
Test results, which I haven't had time to look into yet:
Failed Test Stat Wstat Total Fail Failed List of Fail +ed ---------------------------------------------------------------------- +--------- ../lib/Config/Extensions.t 9 2304 88 9 10.23% 11 17 19 23 +41 67 71 73 77

Replies are listed 'Best First'.
Re: building win32 perl using cygwin
by PodMaster (Abbot) on Jan 04, 2005 at 04:27 UTC
    You got that backwards. MinGW is a bundle of Cygwin parts made specifically to play nice with win32. The reason there are no instructions on what you're trying to do is because MinGW "proper" was created for that express purpose. If you want to compile a native Windows perl using GNU tools, just use MinGW, thats what its for.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      That may be the history, but they are now completely separate. The native windows mode of cygwin really is taken from the mingw project, not vice versa. If you ask questions about it on the cygwin lists, you'll be told to buzz off (cough, that is, you'll be politely redirected to the mingw people). And there's no reason to just install multiple megabytes of mingw when I already have the tools to do the job.
Re: building win32 perl using cygwin
by Steve_p (Priest) on Jan 04, 2005 at 14:05 UTC

    Great job! I'll give it a try today. Any plans on getting it added into the current Perl's to give some more options for Perl builds on Win32?

    For everyone's information, most of the ../lib/Config/Extensions.t failures have also been seen on recent Win32 Perl smokes, although, not all of them.

      Yes, adding things into current perl would be the idea. The thing I'm most hesitant about is the makemaker change...it would be nice to hear from someone that it doesn't break other win32 builds (not to mention unix ones, though testing with regular cygwin should expose any problems there).
Re: building win32 perl using cygwin
by Courage (Parson) on Jan 04, 2005 at 20:46 UTC
    You're terrible wrong from many different points simultaneously.

    Firstly, discussing of such information certainly belongs to perl5porters list.

    Secondly, p5p users usually have a number of smoker machines. Do you pretend your configuration better than one they use? Why not inform them?

    Thirdly, you have a patch to win32 subdir of perl source. Why not it go to p5p list? I am certain your patch contains just quirks for your own misconfigured installation but wrong for GCC compiler in general.

    Forthly, suppose (not in this case but lets suppose) you found a bit of wisdom, why not share it to p5p? It is of no use here.

    Wrong, wrong, wrong.
    Sorry, no offence.
    But feel free to '--' me as many times as needed, you'll certainly deserve mine :)

    Best regards,
    Courage, the Cowardly Dog

      Wow, I just don't know where to begin...so I won't even bother. Have a nice day :)
        actually I was incorrect by just talking about error, your patch have good points as well.

        of course your efforts deserve '++' but I was too barking to you because I saw how many times such efforts do not finish at p5p.

        Once again, I was incorrect, but its good no offence happened on either side

        :) :) :)

        Best regards,
        Courage, the Cowardly Dog

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://419122]
Approved by chromatic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found