Building Perl for OS X - Architecture-Specific Compile Options
Question
Thanks to a suggestion from Chas. Owens, I have been having fun playing with Perlbrew to have various Perl builds in my home directory. My question is more generally on building a newer Perl under OS X however.
I have OS X 10.6.4 Snow Leopard running on a very recent MacBook Pro. After a small diversion getting gcc properly setup under Snow Leopard, I have built and run Perl 5.12.1 in my home directory just using the default options. It passes the Perl test harness.
Perlbrew allows Perl to be built with OS and platform specific flags. These are the -D -U -A
options to the Perl configure script. The perlmacosx read me file hasn't been updated in 4 years, so that is not very helpful anymore.
I am tempted to just ape Apple's switches used in the system Perl v 5.10.0 (which you can be seen for your particular Perl by typing [path_to_specific_perl]/perl -V
or /usr/bin/perl
for the system in most cases...) Other than the -Dprefix=/usr
which would be different for a different root for the new Perl build, what should I use?
(eyeballing) Here are the main differences between the Apple compilation options and the default:
config_args:
Apple: -ds -e
Default: -de
-D: =======================
Apple: useithreads=define, usemultiplicity=define
Default: useithreads=undef, usemultiplicity=undef
Compiler: =================
Apple: optimize='-Os'
Default: optimize='-O3'
Apple: -arch x86_64 -arch i386 -arch ppc
Default: none specified
Apple: -g -pipe
Default these optimizations are not set
Apple not set
Default -no-cpp-precomp
Linker: ================
Apple: useshrplib=true, libperl=libperl.dylib
Default: useshrplib=false, libperl=libperl.a
Characteristics of libperl: =============
Apple MULTIPLICITY PERL_IMPLICIT_CONTEXT USE_ITHREADS USE_REENTRANT_API
Default PERL_MALLOC_WRAP USE_PERL_ATOF
Another difference is the Apple Perl libperl is a dynaloader, the default build is statically linked.
So, questions:
- Which
-D -U -A
switches should I use to build a local copy of Perl on OS X 10.6+? I don't think I need a fat binary like the Apple version, and I don't know if I should do a dynaloader version. Mainly I am looking for the suggested switches for optimization and suggested characteristics of resulting libperl. - Should I do a dynaloader version? (ie, in the OS X sense of Dynamic Libraries...)
- The system Perl is
/usr/bin/perl
and I don't want to change it. Do I change the sheebang in scripts to point to the Perlbrew version of Perl? That means my sheebang would be `/Users/andrew/perl5/perl.' Do I change my path to point there? What are others doing in this regard? What is considered "best practice"? - When I run Perlbrew, I get the warning
v-string in use/require non-portable at ./perlbrew line 818.
Line 818 in Perlbrew isuse 5.8.0;
Shouldn't that line beuse 5.008_000
?
Edit
Thanks to Jonathan Leffler, I least had some Perls to look at. Rather than get too deep into it, I just took the defaults in most cases, added threads, and it seems to work OK. Now I have Perlbrew's installed with several Perl and I have left the system Perl at 5.10. I use /usr/bin/env perl
on the sheebang to have future-proofish code.
Solution
The best I can offer is the output of 'perl -V' for each of my homebrew collection of 5.1x versions of Perl - some 32-bit, some 64-bit. I've omitted the PowerPC builds (from the days before I had an Intel Mac).
drwxr-xr-x 8 jleffler staff 272 Aug 1 2009 v5.10.0
drwxr-xr-x 8 jleffler staff 272 Nov 8 2009 v5.10.1
drwxr-xr-x 6 jleffler staff 204 Oct 26 2009 v5.10.1-64
drwxr-xr-x 6 jleffler staff 204 Jun 23 09:36 v5.12.1
drwxr-xr-x 5 jleffler staff 170 Jun 17 21:14 v5.12.1-32bit
drwxr-xr-x 5 jleffler staff 170 Aug 30 15:02 v5.13.4
I don't build with threading or for multiplicity. I do build with dynamic loading; I use the dlopen version - it is the default suggested. The machine gets different names depending on where it is connected to the network; this shows up in build machine names.
5.10.0
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
Platform:
osname=darwin, osvers=9.7.0, archname=darwin-64int-2level
uname='darwin osiris.sanjose.ibm.com 9.7.0 darwin kernel version 9.7.0: tue mar 31 22:52:17 pdt 2009; root:xnu-1228.12.14~1release_i386 i386 '
config_args='-Duse64bitint'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/gnu/include -I/usr/GNU/include',
optimize='-O3',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/gnu/include -I/usr/GNU/include'
ccversion='', gccversion='4.0.1 (Apple Inc. build 5493)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -L/usr/local/lib -L/usr/gnu/lib -L/usr/GNU/lib'
libpth=/usr/local/lib /usr/gnu/lib /usr/GNU/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/gnu/lib -L/usr/GNU/lib'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP USE_64_BIT_INT
USE_LARGE_FILES USE_PERLIO
Built under darwin
Compiled at Jul 14 2009 10:09:56
@INC:
/Users/jleffler/perl/v5.10.0/lib/5.10.0/darwin-64int-2level
/Users/jleffler/perl/v5.10.0/lib/5.10.0
/Users/jleffler/perl/v5.10.0/lib/site_perl/5.10.0/darwin-64int-2level
/Users/jleffler/perl/v5.10.0/lib/site_perl/5.10.0
.
5.10.1 (32-bit)
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
Platform:
osname=darwin, osvers=9.8.0, archname=darwin-2level
uname='darwin osiris.local 9.8.0 darwin kernel version 9.8.0: wed jul 15 16:55:01 pdt 2009; root:xnu-1228.15.4~1release_i386 i386 '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc -m32', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/usr/gnu/include',
optimize='-O3',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/usr/gnu/include'
ccversion='', gccversion='4.0.1 (Apple Inc. build 5493)', 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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc -m32', ldflags =' -fstack-protector -L/usr/local/lib -L/usr/gnu/lib'
libpth=/usr/local/lib /usr/gnu/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/gnu/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
USE_LARGE_FILES USE_PERLIO
Built under darwin
Compiled at Sep 3 2009 07:26:44
@INC:
/Users/jleffler/perl/v5.10.1/lib/5.10.1/darwin-2level
/Users/jleffler/perl/v5.10.1/lib/5.10.1
/Users/jleffler/perl/v5.10.1/lib/site_perl/5.10.1/darwin-2level
/Users/jleffler/perl/v5.10.1/lib/site_perl/5.10.1
.
5.10.1 64-bit
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
Platform:
osname=darwin, osvers=9.8.0, archname=darwin-2level
uname='darwin osiris.sanjose.ibm.com 9.8.0 darwin kernel version 9.8.0: wed jul 15 16:55:01 pdt 2009; root:xnu-1228.15.4~1release_i386 i386 '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc -m64', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/usr/gnu/include',
optimize='-O3',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/usr/gnu/include'
ccversion='', gccversion='4.0.1 (Apple Inc. build 5493)', 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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc -m64', ldflags =' -fstack-protector -L/usr/local/lib -L/usr/gnu/lib'
libpth=/usr/local/lib /usr/gnu/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/gnu/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP USE_64_BIT_ALL
USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
Built under darwin
Compiled at Sep 3 2009 10:12:54
@INC:
/Users/jleffler/perl/v5.10.1-64/lib/5.10.1/darwin-2level
/Users/jleffler/perl/v5.10.1-64/lib/5.10.1
/Users/jleffler/perl/v5.10.1-64/lib/site_perl/5.10.1/darwin-2level
/Users/jleffler/perl/v5.10.1-64/lib/site_perl/5.10.1
.
5.12.1 64-bit
Summary of my perl5 (revision 5 version 12 subversion 1) configuration:
Platform:
osname=darwin, osvers=10.3.0, archname=darwin-2level
uname='darwin dyn744040.sanjose.ibm.com 10.3.0 darwin kernel version 10.3.0: fri feb 26 11:58:09 pst 2010; root:xnu-1504.3.12~1release_i386 i386 '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/usr/gnu/include -I/usr/GNU/include',
optimize='-O3',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/usr/gnu/include -I/usr/GNU/include'
ccversion='', gccversion='4.2.1 (Apple Inc. build 5659)', 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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib -L/usr/gnu/lib'
libpth=/usr/local/lib /usr/gnu/lib /usr/lib
libs=-ldbm -ldb -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/gnu/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP USE_64_BIT_ALL
USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
USE_PERL_ATOF
Built under darwin
Compiled at Jun 8 2010 15:36:47
@INC:
/Users/jleffler/Perl/v5.12.1/lib/perl5/site_perl/5.12.1/darwin-2level
/Users/jleffler/Perl/v5.12.1/lib/perl5/site_perl/5.12.1
/Users/jleffler/Perl/v5.12.1/lib/perl5/5.12.1/darwin-2level
/Users/jleffler/Perl/v5.12.1/lib/perl5/5.12.1
.
5.12.1 32-bit
Summary of my perl5 (revision 5 version 12 subversion 1) configuration:
Platform:
osname=darwin, osvers=10.4.0, archname=darwin-2level
uname='darwin osiris-2.local 10.4.0 darwin kernel version 10.4.0: fri apr 23 18:28:53 pdt 2010; root:xnu-1504.7.4~1release_i386 i386 '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc -m32', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/usr/gnu/include -I/usr/GNU/include',
optimize='-O3',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/usr/gnu/include -I/usr/GNU/include'
ccversion='', gccversion='4.2.1 (Apple Inc. build 5659)', 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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc -m32', ldflags =' -fstack-protector -L/usr/local/lib -L/usr/gnu/lib -L/usr/GNU/lib'
libpth=/usr/local/lib /usr/gnu/lib /usr/GNU/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/gnu/lib -L/usr/GNU/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF
Built under darwin
Compiled at Jun 17 2010 20:48:50
@INC:
/Users/jleffler/Perl/v5.12.1-32bit/lib/perl5/site_perl/5.12.1/darwin-2level
/Users/jleffler/Perl/v5.12.1-32bit/lib/perl5/site_perl/5.12.1
/Users/jleffler/Perl/v5.12.1-32bit/lib/perl5/5.12.1/darwin-2level
/Users/jleffler/Perl/v5.12.1-32bit/lib/perl5/5.12.1
.
5.13.4 64-bit
Summary of my perl5 (revision 5 version 13 subversion 4) configuration:
Platform:
osname=darwin, osvers=10.4.0, archname=darwin-2level
uname='darwin dyn9043040112.sanjose.ibm.com 10.4.0 darwin kernel version 10.4.0: fri apr 23 18:28:53 pdt 2010; root:xnu-1504.7.4~1release_i386 i386 '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc -m64', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/gnu64/include -I/usr/local/include',
optimize='-O3',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/gnu64/include -I/usr/local/include'
ccversion='', gccversion='4.2.1 (Apple Inc. build 5664)', 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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-fstack-protector -L/usr/gnu64/lib -L/usr/local/lib'
libpth=/usr/gnu64/lib /usr/lib /usr/local/lib
libs=-ldbm -ldb -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/gnu64/lib -L/usr/local/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP USE_64_BIT_ALL
USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
USE_PERL_ATOF
Built under darwin
Compiled at Aug 30 2010 14:36:39
@INC:
/Users/jleffler/perl/v5.13.4/lib/site_perl/5.13.4/darwin-2level
/Users/jleffler/perl/v5.13.4/lib/site_perl/5.13.4
/Users/jleffler/perl/v5.13.4/lib/5.13.4/darwin-2level
/Users/jleffler/perl/v5.13.4/lib/5.13.4
.