lol
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 18.03-beta 171 lines 6.3 kB view raw
1{ lib, stdenv, fetchurlBoot, buildPackages, enableThreading ? stdenv ? glibc, fetchpatch }: 2 3with lib; 4 5# We can only compile perl with threading on platforms where we have a 6# real glibc in the stdenv. 7# 8# Instead of silently building an unthreaded perl if this is not the 9# case, we force callers to disableThreading explicitly, therefore 10# documenting the platforms where the perl is not threaded. 11# 12# In the case of stdenv linux boot stage1 it's not possible to use 13# threading because of the simpleness of the bootstrap glibc, so we 14# use enableThreading = false there. 15assert enableThreading -> (stdenv ? glibc); 16 17let 18 19 libc = if stdenv.cc.libc or null != null then stdenv.cc.libc else "/usr"; 20 libcInc = lib.getDev libc; 21 libcLib = lib.getLib libc; 22 crossCompiling = stdenv.buildPlatform != stdenv.hostPlatform; 23 common = { version, sha256 }: stdenv.mkDerivation (rec { 24 name = "perl-${version}"; 25 26 src = fetchurlBoot { 27 url = "mirror://cpan/src/5.0/${name}.tar.gz"; 28 inherit sha256; 29 }; 30 31 # TODO: Add a "dev" output containing the header files. 32 outputs = [ "out" "man" "devdoc" ]; 33 setOutputFlags = false; 34 35 patches = 36 [ ] 37 # Do not look in /usr etc. for dependencies. 38 ++ optional (versionOlder version "5.26") ./no-sys-dirs.patch 39 ++ optional (versionAtLeast version "5.26") ./no-sys-dirs-5.26.patch 40 ++ optional (versionAtLeast version "5.24") ( 41 # Fix parallel building: https://rt.perl.org/Public/Bug/Display.html?id=132360 42 fetchurlBoot { 43 url = "https://rt.perl.org/Public/Ticket/Attachment/1502646/807252/0001-Fix-missing-build-dependency-for-pods.patch"; 44 sha256 = "1bb4mldfp8kq1scv480wm64n2jdsqa3ar46cjp1mjpby8h5dr2r0"; 45 }) 46 ++ optional stdenv.isSunOS ./ld-shared.patch 47 ++ optional stdenv.isDarwin ./cpp-precomp.patch 48 ++ optional (stdenv.isDarwin && versionAtLeast version "5.24") ./sw_vers.patch; 49 50 postPatch = '' 51 pwd="$(type -P pwd)" 52 substituteInPlace dist/PathTools/Cwd.pm \ 53 --replace "/bin/pwd" "$pwd" 54 '' + stdenv.lib.optionalString crossCompiling '' 55 substituteInPlace cnf/configure_tool.sh --replace "cc -E -P" "cc -E" 56 ''; 57 58 # Build a thread-safe Perl with a dynamic libperls.o. We need the 59 # "installstyle" option to ensure that modules are put under 60 # $out/lib/perl5 - this is the general default, but because $out 61 # contains the string "perl", Configure would select $out/lib. 62 # Miniperl needs -lm. perl needs -lrt. 63 configureFlags = 64 (if crossCompiling 65 then [ "-Dlibpth=\"\"" "-Dglibpth=\"\"" ] 66 else [ "-de" "-Dcc=cc" ]) 67 ++ [ 68 "-Uinstallusrbinperl" 69 "-Dinstallstyle=lib/perl5" 70 "-Duseshrplib" 71 "-Dlocincpth=${libcInc}/include" 72 "-Dloclibpth=${libcLib}/lib" 73 ] 74 ++ optional stdenv.isSunOS "-Dcc=gcc" 75 ++ optional enableThreading "-Dusethreads"; 76 77 configureScript = stdenv.lib.optionalString (!crossCompiling) "${stdenv.shell} ./Configure"; 78 79 dontAddPrefix = !crossCompiling; 80 81 enableParallelBuilding = !crossCompiling; 82 83 preConfigure = optionalString (!crossCompiling) '' 84 configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3" 85 '' + optionalString (stdenv.isArm || stdenv.isMips) '' 86 configureFlagsArray=(-Dldflags="-lm -lrt") 87 '' + optionalString stdenv.isDarwin '' 88 substituteInPlace hints/darwin.sh --replace "env MACOSX_DEPLOYMENT_TARGET=10.3" "" 89 '' + optionalString (!enableThreading) '' 90 # We need to do this because the bootstrap doesn't have a static libpthread 91 sed -i 's,\(libswanted.*\)pthread,\1,g' Configure 92 ''; 93 94 preBuild = optionalString (!(stdenv ? cc && stdenv.cc.nativeTools)) 95 '' 96 # Make Cwd work on NixOS (where we don't have a /bin/pwd). 97 substituteInPlace dist/PathTools/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'" 98 ''; 99 100 setupHook = ./setup-hook.sh; 101 102 passthru.libPrefix = "lib/perl5/site_perl"; 103 104 # TODO: it seems like absolute paths to some coreutils is required. 105 postInstall = 106 '' 107 # Remove dependency between "out" and "man" outputs. 108 rm "$out"/lib/perl5/*/*/.packlist 109 110 # Remove dependencies on glibc and gcc 111 sed "/ *libpth =>/c libpth => ' '," \ 112 -i "$out"/lib/perl5/*/*/Config.pm 113 # TODO: removing those paths would be cleaner than overwriting with nonsense. 114 substituteInPlace "$out"/lib/perl5/*/*/Config_heavy.pl \ 115 --replace "${libcInc}" /no-such-path \ 116 --replace "${ 117 if stdenv.cc.cc or null != null then stdenv.cc.cc else "/no-such-path" 118 }" /no-such-path \ 119 --replace "$man" /no-such-path 120 ''; # */ 121 122 meta = { 123 homepage = https://www.perl.org/; 124 description = "The standard implementation of the Perl 5 programmming language"; 125 maintainers = [ maintainers.eelco ]; 126 platforms = platforms.all; 127 }; 128 } // stdenv.lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) rec { 129 crossVersion = "1.1.8"; 130 131 perl-cross-src = fetchurlBoot { 132 url = "https://github.com/arsv/perl-cross/releases/download/${crossVersion}/perl-cross-${crossVersion}.tar.gz"; 133 sha256 = "072j491rpz2qx2sngbg4flqh4lx5865zyql7b9lqm6s1kknjdrh8"; 134 }; 135 136 # https://github.com/arsv/perl-cross/issues/60 137 perl-cross-gcc7-patch = fetchpatch { 138 url = "https://github.com/arsv/perl-cross/commit/07208bc1707b8be3ea170c62c59120020cf0f87f.patch"; 139 sha256 = "1gh8w9m5if2s0lrx2x8f8grp74d1l6d46m8jglpjm5a1kf55j810"; 140 }; 141 142 depsBuildBuild = [ buildPackages.stdenv.cc ]; 143 144 postUnpack = '' 145 unpackFile ${perl-cross-src} 146 cd perl-cross-* 147 patch -Np1 -i ${perl-cross-gcc7-patch} 148 cd .. 149 cp -R perl-cross-${crossVersion}/* perl-${version}/ 150 ''; 151 152 configurePlatforms = [ "build" "host" "target" ]; 153 }); 154in rec { 155 perl = perl524; 156 157 perl522 = common { 158 version = "5.22.4"; 159 sha256 = "1yk1xn4wmnrf2ph02j28khqarpyr24qwysjzkjnjv7vh5dygb7ms"; 160 }; 161 162 perl524 = common { 163 version = "5.24.3"; 164 sha256 = "1m2px85kq2fyp2d4rx3bw9kg3car67qfqwrs5vlv96dx0x8rl06b"; 165 }; 166 167 perl526 = common { 168 version = "5.26.1"; 169 sha256 = "1p81wwvr5jb81m41d07kfywk5gvbk0axdrnvhc2aghcdbr4alqz7"; 170 }; 171}