Mac-Carbon Makefile.PL 64-bit Check

pudge on 2009-09-17T18:01:27

I should add a check for 64-bit mode to the Mac-Carbon Makefile.PL. This will save a lot of hassle if I can give a nice error message, with a link to more information, up front.

I can't test this easily, though, since I don't yet have a 10.6 64-bit box (it's only on an original MacBook Pro, which is 32 bits). I will upgrade to Snow Leopard soon. I could try to make my own perl before then, but I don't know it would work the same way. So. If you want to help, now's your chance!

First thought is Config, but we all know Config can be flaky. For example, on my 32-bit box:

$ perl -V:use64bitall
use64bitall='define';


Doesn't really help. I don't know if $Config{intsize} would be 8 on a 64-bit perl. It's 4 on this 10.6 32-bit perl. I do know you should be able to call perl with VERSIONER_PERL_PREFER_32_BIT=yes to give you 32-bit perl, instead of the default 64-bit perl.

So anyway ... if you can figure out a way to know, under 10.6 stock perl, if I am running under 32-bit perl or 64-bit perl, let me know.


Snow Leopard perl is both

tonyc on 2009-09-18T05:05:44

Scarily enough perl in Snow Leopard is compiled as both 32 and 64 bit, and when you build extensions it builds them as both too (and ppc too).

This can be confusing when you have 32-bit libraries installed.

neptune:Imager tony$ export VERSIONER_PERL_PREFER_32_BIT=no
neptune:Imager tony$ perl -V
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=darwin, osvers=10.0, archname=darwin-thread-multi-2level
    uname='darwin neige.apple.com 10.0 darwin kernel version 10.0.0d8: tue may 5 19:29:59 pdt 2009; root:xnu-1437.2~2release_i386 i386 '
    config_args='-ds -e -Dprefix=/usr -Dccflags=-g  -pipe  -Dldflags= -Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc=gcc-4.2'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc-4.2', ccflags ='-arch x86_64 -arch i386 -arch ppc -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include',
    optimize='-Os',
    cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5646)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc-4.2 -mmacosx-version-min=10.6', ldflags ='-arch x86_64 -arch i386 -arch ppc -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-arch x86_64 -arch i386 -arch ppc -bundle -undefined dynamic_lookup -L/usr/local/lib'

Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_64_BIT_ALL
                        USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
                        USE_PERLIO USE_REENTRANT_API
  Locally applied patches:
        /Library/Perl/Updates/<version> comes before system perl directories
        installprivlib and installarchlib points to the Updates directory
  Built under darwin
  Compiled at Jun 24 2009 00:35:27
  @INC:
    /Library/Perl/Updates/5.10.0
    /System/Library/Perl/5.10.0/darwin-thread-multi-2level
    /System/Library/Perl/5.10.0
    /Library/Perl/5.10.0/darwin-thread-multi-2level
    /Library/Perl/5.10.0
    /Network/Library/Perl/5.10.0/darwin-thread-multi-2level
    /Network/Library/Perl/5.10.0
    /Network/Library/Perl
    /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level
    /System/Library/Perl/Extras/5.10.0
    .
neptune:Imager tony$ export VERSIONER_PERL_PREFER_32_BIT=yes
neptune:Imager tony$ perl -V
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=darwin, osvers=10.0, archname=darwin-thread-multi-2level
    uname='darwin neige.apple.com 10.0 darwin kernel version 10.0.0d8: tue may 5 19:29:59 pdt 2009; root:xnu-1437.2~2release_i386 i386 '
    config_args='-ds -e -Dprefix=/usr -Dccflags=-g  -pipe  -Dldflags= -Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc=gcc-4.2'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc-4.2', ccflags ='-arch x86_64 -arch i386 -arch ppc -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include',
    optimize='-Os',
    cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5646)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc-4.2 -mmacosx-version-min=10.6', ldflags ='-arch x86_64 -arch i386 -arch ppc -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-arch x86_64 -arch i386 -arch ppc -bundle -undefined dynamic_lookup -L/usr/local/lib'

Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS
                        USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
  Locally applied patches:
        /Library/Perl/Updates/<version> comes before system perl directories
        installprivlib and installarchlib points to the Updates directory
  Built under darwin
  Compiled at Jun 24 2009 00:35:28
  @INC:
    /Library/Perl/Updates/5.10.0
    /System/Library/Perl/5.10.0/darwin-thread-multi-2level
    /System/Library/Perl/5.10.0
    /Library/Perl/5.10.0/darwin-thread-multi-2level
    /Library/Perl/5.10.0
    /Network/Library/Perl/5.10.0/darwin-thread-multi-2level
    /Network/Library/Perl/5.10.0
    /Network/Library/Perl
    /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level
    /System/Library/Perl/Extras/5.10.0
    .
neptune:Imager tony$

Re:Snow Leopard perl is both

pudge on 2009-09-18T05:19:36

Thanks Tony, yeah, it looks like I am going to have to fudge $Config{ccflags} etc. before the Makefile is written, to strip out -arch x86_64. I think this will work.

Maybe I'll put up a test Makefile.PL for people to try out.

Re:Snow Leopard perl is both

pudge on 2009-09-18T07:48:00

Tony, would you mind trying these files out? Drop them in the root Mac-Carbon-0.80 dir, then run `perl Makefile.PL` and `make` and `make test`. They try to remove the -arch x86_64 flags, and give a warning to any user trying to compile with a 64-bit perl.

http://pudge.net/tmp/Makefile.PL

http://pudge.net/tmp/common.pl

Re:Snow Leopard perl is both

tonyc on 2009-09-19T00:22:00

Both URLs return a 403 error.

Re:Snow Leopard perl is both

pudge on 2009-09-19T02:13:19

Ugh. OK, I had to rename them, or reconfigure the server, or put them in an archive. So rename them I did!

http://pudge.net/tmp/Makefile.txt

http://pudge.net/tmp/common.txt

Thanks.

Re:Snow Leopard perl is both

tonyc on 2009-09-19T04:28:30

build log

Re:Snow Leopard perl is both

pudge on 2009-09-19T04:43:06

Awesome, thanks. That dumb creator/type test is failing, I'll look at that again. But other than that, it seems to work for 32-bit.

Could you try one more thing? Do the first part again, running as 64-bit. But before you run make test, export VERSIONER_PERL_PREFER_32_BIT=yes, so you will have built it using the 64-bit perl, but are running the tests as 32-bit perl.

Thanks again.

Re:Snow Leopard perl is both

pudge on 2009-09-19T04:46:58

Oh and, heh, I notice I got the logic backward on the 64-bit test. I reversed it when I was testing it and forgot to put it back before uploading it. Hope that wasn't too confusing.

Re:Snow Leopard perl is both

tonyc on 2009-09-20T06:06:14

build log

I used script to capture the output, so there's a few control characters in there, but the Makefile.PL and make were with VERSIONER_PERL_PREFER_32_BIT=yes and the make test with VERSIONER_PERL_PREFER_32_BIT=no

Re:Snow Leopard perl is both

pudge on 2009-09-20T06:24:48

I used script to capture the output, so there's a few control characters in there, but the Makefile.PL and make were with VERSIONER_PERL_PREFER_32_BIT=yes and the make test with VERSIONER_PERL_PREFER_32_BIT=no

You mean the other way around, right? I don't see make test working under 64-bit. :-)

So it looks like just what I hoped for. It seems buildable no matter if perl is running as 64-bit or 32-bit. Just need to fix that one broken test, and maybe try to find a way to run make test with VERSIONER_PERL_PREFER_32_BIT=yes.

Thanks!

Re:Snow Leopard perl is both

tonyc on 2009-09-20T08:06:24

Yeah, what you said :)