perl-5.8 and perl-5.10: fixed build on MacOS X

On MacOS X, we used to use the native perl interpreter from /usr/bin.
Unfortunately, that interpreter fails to build a number of packages
(Subversion, Git, etc. ...), because it assumes knowledge about the
underlying C compiler that is not valid for the compiler used by Nix.
For example, /usr/bin/perl assumes that the compiler can build binaries
for both the ppc and the x86 architecture. /usr/bin/gcc can do that, but
the gcc from Nix can't.

The solution is to compile Perl 5.10 in Nix so that the ./configure
phase can properly detect the system's capabilities. However, note that
the resulting binary is impure: it will find headers in /usr/include and
libraries in /usr/lib. In this respect, the Nix-compiled perl binary is
no different than the native one in /usr/bin -- it's just configured
more accurately.

svn path=/nixpkgs/trunk/; revision=17870
This commit is contained in:
Peter Simons 2009-10-19 09:17:10 +00:00
parent 9e519f0802
commit 1e575d3572
4 changed files with 42 additions and 35 deletions

View File

@ -1,4 +1,6 @@
{stdenv, fetchurl}:
{ stdenv, fetchurl
, impureLibcPath ? null
}:
stdenv.mkDerivation {
name = "perl-5.10.0";
@ -35,8 +37,8 @@ stdenv.mkDerivation {
''
configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3"
if test "$NIX_ENFORCE_PURITY" = "1"; then
GLIBC=$(cat $NIX_GCC/nix-support/orig-libc)
if test "${if impureLibcPath == null then "$NIX_ENFORCE_PURITY" else "1"}" = "1"; then
GLIBC=${if impureLibcPath == null then "$(cat $NIX_GCC/nix-support/orig-libc)" else impureLibcPath}
configureFlags="$configureFlags -Dlocincpth=$GLIBC/include -Dloclibpth=$GLIBC/lib"
fi
'';
@ -44,7 +46,7 @@ stdenv.mkDerivation {
preBuild =
''
# Make Cwd work on NixOS (where we don't have a /bin/pwd).
substituteInPlace lib/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'"
${if stdenv.system == "i686-darwin" then "" else "substituteInPlace lib/Cwd.pm --replace \"'/bin/pwd'\" \"'$(type -tP pwd)'\""}
'';
setupHook = ./setup-hook.sh;

View File

@ -1,22 +0,0 @@
source $stdenv/setup
if test "$NIX_ENFORCE_PURITY" = "1"; then
GLIBC=$(cat $NIX_GCC/nix-support/orig-libc)
extraflags="-Dlocincpth=$GLIBC/include -Dloclibpth=$GLIBC/lib"
fi
configureScript=./Configure
configureFlags="-de -Dcc=gcc -Dprefix=$out -Uinstallusrbinperl $extraflags"
dontAddPrefix=1
preBuild() {
# Make Cwd work on NixOS (where we don't have a /bin/pwd).
substituteInPlace lib/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'"
}
postInstall() {
ensureDir "$out/nix-support"
cp $setupHook $out/nix-support/setup-hook
}
genericBuild

View File

@ -1,9 +1,37 @@
{stdenv, fetchurl}:
{ stdenv, fetchurl
, impureLibcPath ? null
}:
stdenv.mkDerivation {
name = "perl-5.8.8";
builder = ./builder.sh;
builder =
''
source $stdenv/setup
if test "$NIX_ENFORCE_PURITY" = "1"; then
GLIBC=${if impureLibcPath == null then "$(cat $NIX_GCC/nix-support/orig-libc)" else impureLibcPath}
extraflags="-Dlocincpth=$GLIBC/include -Dloclibpth=$GLIBC/lib"
fi
configureScript=./Configure
configureFlags="-de -Dcc=gcc -Dprefix=$out -Uinstallusrbinperl $extraflags"
dontAddPrefix=1
preBuild() {
# Make Cwd work on NixOS (where we don't have a /bin/pwd).
substituteInPlace lib/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'"
}
postInstall() {
ensureDir "$out/nix-support"
cp $setupHook $out/nix-support/setup-hook
}
genericBuild
'';
src = fetchurl {
url = mirror://cpan/src/perl-5.8.8.tar.bz2;
sha256 = "1j8vzc6lva49mwdxkzhvm78dkxyprqs4n4057amqvsh4kh6i92l1";

View File

@ -2341,16 +2341,15 @@ let
inherit (bleedingEdgeRepos) sourceByName;
};
perl = if !stdenv.isLinux then sysPerl else perlReal;
perl58 = if !stdenv.isLinux then sysPerl else
import ../development/interpreters/perl-5.8 {
perl58 = import ../development/interpreters/perl-5.8 {
inherit fetchurl stdenv;
impureLibcPath = if stdenv.isLinux then null else "/usr";
};
perlReal = import ../development/interpreters/perl-5.10 {
fetchurl = fetchurlBoot;
perl = import ../development/interpreters/perl-5.10 {
inherit stdenv;
fetchurl = fetchurlBoot;
impureLibcPath = if stdenv.isLinux then null else "/usr";
};
# FIXME: unixODBC needs patching on Darwin (see darwinports)