diff options
Diffstat (limited to 'pkgs/stdenv')
| -rw-r--r-- | pkgs/stdenv/darwin/default.nix | 16 | ||||
| -rw-r--r-- | pkgs/stdenv/darwin/make-bootstrap-tools.nix | 103 | ||||
| -rw-r--r-- | pkgs/stdenv/darwin/unpack-bootstrap-tools.sh | 39 | ||||
| -rw-r--r-- | pkgs/stdenv/default.nix | 10 | ||||
| -rw-r--r-- | pkgs/stdenv/generic/default.nix | 6 | ||||
| -rw-r--r-- | pkgs/stdenv/generic/setup.sh | 12 | ||||
| -rw-r--r-- | pkgs/stdenv/native/default.nix | 2 |
7 files changed, 130 insertions, 58 deletions
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 09d9ed23b3f8..1bc983d63129 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -6,14 +6,14 @@ # Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools , bootstrapFiles ? let fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> { - url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/4f07c88d467216d9692fefc951deb5cd3c4cc722/${file}"; + url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/33f59c9d11b8d5014dfd18cc11a425f6393c884a/${file}"; inherit sha256 system executable; }; in { - sh = fetch { file = "sh"; sha256 = "1siix3wakzil31r2cydmh3v8a1nyq4605dwiabqc5lx73j4xzrzi"; }; - bzip2 = fetch { file = "bzip2"; sha256 = "0zvqm977k11b5cl4ixxb5h0ds24g6z0f8m28z4pqxzpa353lqbla"; }; - mkdir = fetch { file = "mkdir"; sha256 = "13frk8lsfgzlb65p9l26cvxf06aag43yjk7vg9msn7ix3v8cmrg1"; }; - cpio = fetch { file = "cpio"; sha256 = "0ms5i9m1vdksj575sf1djwgm7zhnvfrrb44dxnfh9avr793rc2w4"; }; - tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "1lz1b0grl4642h6n635xvi6imf0yyy1zyzdr9ing5aphzz0z5iic"; executable = false; }; + sh = fetch { file = "sh"; sha256 = "1rx4kg6358xdj05z0m139a0zn4f4zfmq4n4vimlmnwyfiyn4x7wk"; }; + bzip2 = fetch { file = "bzip2"; sha256 = "104qnhzk79vkbp2yi0kci6lszgfppvrwk3rgxhry842ly1xz2r7l"; }; + mkdir = fetch { file = "mkdir"; sha256 = "0d91c19xjzmqisncvldv79d7ddzai9l7vcmajhwlwwv74g6da5yl"; }; + cpio = fetch { file = "cpio"; sha256 = "0lw057bmcqls96j0gv1n3mgl66q31mba7i413cbkkaf0rfzz3dxj"; }; + tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "13ihbj002pis3fgy1d9c4fi7flca21z9brjsjkklm82h5b4nlwxl"; executable = false; }; } }: @@ -29,7 +29,7 @@ in rec { export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}" export NIX_IGNORE_LD_THROUGH_GCC=1 stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" - export MACOSX_DEPLOYMENT_TARGET=10.7 + export MACOSX_DEPLOYMENT_TARGET=10.10 export SDKROOT= export CMAKE_OSX_ARCHITECTURES=x86_64 # Workaround for https://openradar.appspot.com/22671534 on 10.11. @@ -128,7 +128,7 @@ in rec { ln -s ${bootstrapTools}/include/c++ $out/include/c++ ''; linkCxxAbi = false; - setupHook = ../../development/compilers/llvm/3.6/libc++/setup-hook.sh; + setupHook = ../../development/compilers/llvm/3.9/libc++/setup-hook.sh; }; libcxxabi = stdenv.mkDerivation { diff --git a/pkgs/stdenv/darwin/make-bootstrap-tools.nix b/pkgs/stdenv/darwin/make-bootstrap-tools.nix index 41c94bd16745..10d2b4decddd 100644 --- a/pkgs/stdenv/darwin/make-bootstrap-tools.nix +++ b/pkgs/stdenv/darwin/make-bootstrap-tools.nix @@ -1,8 +1,10 @@ -{ system ? builtins.currentSystem }: +{ pkgspath ? ../../.., test-pkgspath ? pkgspath, system ? builtins.currentSystem }: -with import ../../.. { inherit system; }; +with import pkgspath { inherit system; }; -rec { +let + llvmPackages = llvmPackages_37; +in rec { coreutils_ = coreutils.override (args: { # We want coreutils without ACL support. aclSupport = false; @@ -19,17 +21,15 @@ rec { buildInputs = [nukeReferences cpio]; buildCommand = '' - mkdir -p $out/bin $out/lib + mkdir -p $out/bin $out/lib $out/lib/system - # Our (fake) loader - cp -d ${darwin.dyld}/lib/dyld $out/lib/ - - # C standard library stuff - cp -d ${darwin.Libsystem}/lib/*.o $out/lib/ - cp -d ${darwin.Libsystem}/lib/*.dylib $out/lib/ + # We're not going to bundle the actual libSystem.dylib; instead we reconstruct it on + # the other side. See the notes in stdenv/darwin/default.nix for more information. + # We also need the .o files for various low-level boot stuff. + cp -d ${darwin.Libsystem}/lib/*.o $out/lib + cp -d ${darwin.Libsystem}/lib/system/*.dylib $out/lib/system # Resolv is actually a link to another package, so let's copy it properly - rm $out/lib/libresolv.9.dylib cp -L ${darwin.Libsystem}/lib/libresolv.9.dylib $out/lib cp -rL ${darwin.Libsystem}/include $out @@ -78,11 +78,11 @@ rec { cp -rL ${llvmPackages.clang-unwrapped}/lib/clang $out/lib - cp -d ${libcxx}/lib/libc++*.dylib $out/lib - cp -d ${libcxxabi}/lib/libc++abi*.dylib $out/lib + cp -d ${llvmPackages.libcxx}/lib/libc++*.dylib $out/lib + cp -d ${llvmPackages.libcxxabi}/lib/libc++abi*.dylib $out/lib mkdir $out/include - cp -rd ${libcxx}/include/c++ $out/include + cp -rd ${llvmPackages.libcxx}/include/c++ $out/include cp -d ${icu.out}/lib/libicu*.dylib $out/lib cp -d ${zlib.out}/lib/libz.* $out/lib @@ -107,33 +107,26 @@ rec { done } - fix_dyld() { - # This is clearly a hack. Once we have an install_name_tool-alike that can patch dyld, this will be nicer. - ${perl}/bin/perl -i -0777 -pe 's/\/nix\/store\/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-dyld-239\.4\/lib\/dyld/\/usr\/lib\/dyld\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00/sg' "$1" - } - # Strip executables even further for i in $out/bin/*; do if test -x $i -a ! -L $i; then chmod +w $i - - fix_dyld $i strip $i || true fi done for i in $out/bin/* $out/lib/*.dylib $out/lib/clang/*/lib/darwin/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do - if test -x $i -a ! -L $i; then + if test -x "$i" -a ! -L "$i"; then echo "Adding rpath to $i" rpathify $i fi done nuke-refs $out/lib/* + nuke-refs $out/lib/system/* nuke-refs $out/lib/clang/*/lib/darwin/* nuke-refs $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation - set -x mkdir $out/.pack mv $out/* $out/.pack mv $out/.pack $out/pack @@ -148,10 +141,6 @@ rec { strip $out/on-server/* nuke-refs $out/on-server/* - for i in $out/on-server/*; do - fix_dyld $i - done - (cd $out/pack && (find | cpio -o -H newc)) | bzip2 > $out/on-server/bootstrap-tools.cpio.bz2 ''; @@ -208,14 +197,49 @@ rec { fi done + install_name_tool \ + -id $out/lib/system/libsystem_c.dylib \ + $out/lib/system/libsystem_c.dylib + + install_name_tool \ + -id $out/lib/system/libsystem_kernel.dylib \ + $out/lib/system/libsystem_kernel.dylib + + # TODO: this logic basically duplicates similar logic in the Libsystem expression. Deduplicate them! + libs=$(otool -arch x86_64 -L /usr/lib/libSystem.dylib | tail -n +3 | awk '{ print $1 }') + + for i in $libs; do + if [ "$i" != "/usr/lib/system/libsystem_kernel.dylib" ] && [ "$i" != "/usr/lib/system/libsystem_c.dylib" ]; then + args="$args -reexport_library $i" + fi + done + + ld -macosx_version_min 10.7 \ + -arch x86_64 \ + -dylib \ + -o $out/lib/libSystem.B.dylib \ + -compatibility_version 1.0 \ + -current_version 1226.10.1 \ + -reexport_library $out/lib/system/libsystem_c.dylib \ + -reexport_library $out/lib/system/libsystem_kernel.dylib \ + $args + + ln -s libSystem.B.dylib $out/lib/libSystem.dylib + + for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do + ln -s libSystem.dylib $out/lib/lib$name.dylib + done + + ln -s libresolv.9.dylib $out/lib/libresolv.dylib + for i in $out/lib/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do - if ! test -L $i; then - echo patching $i + if test ! -L "$i" -a "$i" != "$out/lib/libSystem*.dylib"; then + echo "Patching $i" id=$(otool -D "$i" | tail -n 1) install_name_tool -id "$(dirname $i)/$(basename $id)" $i - libs=$(otool -L "$i" | tail -n +2 | grep -v Libsystem | cat) + libs=$(otool -L "$i" | tail -n +2 | grep -v libSystem | cat) if [ -n "$libs" ]; then install_name_tool -add_rpath $out/lib $i fi @@ -225,9 +249,24 @@ rec { ln -s bash $out/bin/sh ln -s bzip2 $out/bin/bunzip2 + # Provide a gunzip script. + cat > $out/bin/gunzip <<EOF + #!$out/bin/sh + exec $out/bin/gzip -d "\$@" + EOF + chmod +x $out/bin/gunzip + + # Provide fgrep/egrep. + echo "#! $out/bin/sh" > $out/bin/egrep + echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep + echo "#! $out/bin/sh" > $out/bin/fgrep + echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep + cat >$out/bin/dsymutil << EOF #!$out/bin/sh EOF + + chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/dsymutil ''; allowedReferences = [ "out" ]; @@ -294,8 +333,8 @@ rec { # The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it test-pkgs = let - stdenv = import ./. { inherit system bootstrapFiles; }; - in import ../../.. { + stdenv = import (test-pkgspath + "/pkgs/stdenv/darwin") { inherit system bootstrapFiles; }; + in import test-pkgspath { inherit system; bootStdenv = stdenv.stdenvDarwin; }; diff --git a/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh b/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh index 8033c7004d93..66c4e9ebeda9 100644 --- a/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh +++ b/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh @@ -17,9 +17,44 @@ for i in $out/bin/*; do fi done +install_name_tool \ + -id $out/lib/system/libsystem_c.dylib \ + $out/lib/system/libsystem_c.dylib + +install_name_tool \ + -id $out/lib/system/libsystem_kernel.dylib \ + $out/lib/system/libsystem_kernel.dylib + +# TODO: this logic basically duplicates similar logic in the Libsystem expression. Deduplicate them! +libs=$(otool -arch x86_64 -L /usr/lib/libSystem.dylib | tail -n +3 | awk '{ print $1 }') + +for i in $libs; do + if [ "$i" != "/usr/lib/system/libsystem_kernel.dylib" ] && [ "$i" != "/usr/lib/system/libsystem_c.dylib" ]; then + args="$args -reexport_library $i" + fi +done + +ld -macosx_version_min 10.7 \ + -arch x86_64 \ + -dylib \ + -o $out/lib/libSystem.B.dylib \ + -compatibility_version 1.0 \ + -current_version 1226.10.1 \ + -reexport_library $out/lib/system/libsystem_c.dylib \ + -reexport_library $out/lib/system/libsystem_kernel.dylib \ + $args + +ln -s libSystem.B.dylib $out/lib/libSystem.dylib + +for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do + ln -s libSystem.dylib $out/lib/lib$name.dylib +done + +ln -s libresolv.9.dylib $out/lib/libresolv.dylib + for i in $out/lib/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do - if ! test -L $i; then - echo patching $i + if test ! -L "$i" -a "$i" != "$out/lib/libSystem*.dylib"; then + echo "Patching $i" id=$(otool -D "$i" | tail -n 1) install_name_tool -id "$(dirname $i)/$(basename $id)" $i diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 96f07ae9fc6f..3035d87e1fc5 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -16,9 +16,7 @@ rec { # i.e., the stuff in /bin, /usr/bin, etc. This environment should # be used with care, since many Nix packages will not build properly # with it (e.g., because they require GNU Make). - stdenvNative = (import ./native { - inherit system allPackages config; - }).stdenv; + inherit (import ./native { inherit system allPackages config; }) stdenvNative; stdenvNativePkgs = allPackages { bootStdenv = stdenvNative; @@ -33,12 +31,12 @@ rec { pkgs = stdenvNativePkgs; }; - stdenvFreeBSD = (import ./freebsd { inherit system allPackages platform config; }).stdenvFreeBSD; + inherit (import ./freebsd { inherit system allPackages platform config; }) stdenvFreeBSD; # Linux standard environment. - stdenvLinux = (import ./linux { inherit system allPackages platform config lib; }).stdenvLinux; + inherit (import ./linux { inherit system allPackages platform config lib; }) stdenvLinux; - stdenvDarwin = (import ./darwin { inherit system allPackages platform config;}).stdenvDarwin; + inherit (import ./darwin { inherit system allPackages platform config;}) stdenvDarwin; # Select the appropriate stdenv for the platform `system'. stdenv = diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 372fd3cfa526..edd5c2785dcf 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -44,7 +44,7 @@ let throw "whitelistedLicenses and blacklistedLicenses are not mutually exclusive."; hasLicense = attrs: - builtins.hasAttr "meta" attrs && builtins.hasAttr "license" attrs.meta; + attrs ? meta.license; hasWhitelistedLicense = assert areLicenseListsValid; attrs: hasLicense attrs && builtins.elem attrs.meta.license whitelist; @@ -128,8 +128,7 @@ let throwEvalHelp = { reason, errormsg }: # uppercase the first character of string s let up = s: with lib; - let cs = lib.stringToCharacters s; - in concatStrings (singleton (toUpper (head cs)) ++ tail cs); + (toUpper (substring 0 1 s)) + (substring 1 (stringLength s) s); in assert builtins.elem reason ["unfree" "broken" "blacklisted"]; @@ -235,6 +234,7 @@ let outputs = outputs'; } else { })))) ( { + overrideAttrs = f: mkDerivation (attrs // (f attrs)); # The meta attribute is passed in the resulting attribute set, # but it's not part of the actual derivation, i.e., it's not # passed to the builder and is not a dependency. But since we diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index feb82fd92266..154fdefd789c 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -490,12 +490,14 @@ dumpVars() { } -# Utility function: return the base name of the given path, with the +# Utility function: echo the base name of the given path, with the # prefix `HASH-' removed, if present. stripHash() { - strippedName=$(basename $1); + local strippedName="$(basename "$1")"; if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then - strippedName=$(echo "$strippedName" | cut -c34-) + echo "$strippedName" | cut -c34- + else + echo "$strippedName" fi } @@ -506,12 +508,10 @@ _defaultUnpack() { if [ -d "$fn" ]; then - stripHash "$fn" - # We can't preserve hardlinks because they may have been # introduced by store optimization, which might break things # in the build. - cp -pr --reflink=auto "$fn" $strippedName + cp -pr --reflink=auto "$fn" "$(stripHash "$fn")" else diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index 291ef5a5079f..fcd0805275be 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -141,5 +141,5 @@ rec { }; - stdenv = stdenvBoot2; + stdenvNative = stdenvBoot2; } |
