diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2019-11-25 00:23:07 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2019-11-25 00:23:07 +0000 |
commit | 6bc456c91c6a556e905852d9a13034ed1932ea3d (patch) | |
tree | 69df19159e5e7df77ae939041f8f6e941c5ef056 /pkgs/stdenv | |
parent | ea9a2c5ec21bf088bbdef036238fa67cdc85b073 (diff) | |
parent | 4273a6adcc9327b9dc0e09e9fe205b4861c15679 (diff) |
Merge remote-tracking branch 'upstream/master' into ghcjs-cross-without-cc
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/adapters.nix | 1 | ||||
-rw-r--r-- | pkgs/stdenv/cygwin/rebase-i686.sh | 2 | ||||
-rw-r--r-- | pkgs/stdenv/cygwin/rebase-x86_64.sh | 2 | ||||
-rw-r--r-- | pkgs/stdenv/generic/check-meta.nix | 6 | ||||
-rw-r--r-- | pkgs/stdenv/generic/setup.sh | 133 | ||||
-rw-r--r-- | pkgs/stdenv/linux/make-bootstrap-tools.nix | 29 |
6 files changed, 74 insertions, 99 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 8f62bd24dda10..041964bcacc28 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -62,7 +62,6 @@ rec { ]; mesonFlags = (args.mesonFlags or []) ++ [ "-Ddefault_library=static" ]; }); - static = true; }; diff --git a/pkgs/stdenv/cygwin/rebase-i686.sh b/pkgs/stdenv/cygwin/rebase-i686.sh index 091c9044d93f1..6b8ec441ca7f9 100644 --- a/pkgs/stdenv/cygwin/rebase-i686.sh +++ b/pkgs/stdenv/cygwin/rebase-i686.sh @@ -1,7 +1,7 @@ fixupOutputHooks+=(_cygwinFixAutoImageBase) _cygwinFixAutoImageBase() { - if [ "$dontRebase" == 1 ] || [ ! -d "$prefix" ]; then + if [ "${dontRebase-}" == 1 ] || [ ! -d "$prefix" ]; then return fi find "$prefix" -name "*.dll" -type f | while read DLL; do diff --git a/pkgs/stdenv/cygwin/rebase-x86_64.sh b/pkgs/stdenv/cygwin/rebase-x86_64.sh index 4c8f8ebd7eb2f..6dccdc40c7221 100644 --- a/pkgs/stdenv/cygwin/rebase-x86_64.sh +++ b/pkgs/stdenv/cygwin/rebase-x86_64.sh @@ -1,7 +1,7 @@ fixupOutputHooks+=(_cygwinFixAutoImageBase) _cygwinFixAutoImageBase() { - if [ "$dontRebase" == 1 ] || [ ! -d "$prefix" ]; then + if [ "${dontRebase-}" == 1 ] || [ ! -d "$prefix" ]; then return fi find "$prefix" -name "*.dll" -type f | while read DLL; do diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index b754230b0be95..6bd6a9bf41eff 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -36,10 +36,10 @@ let attrs ? meta.license; hasWhitelistedLicense = assert areLicenseListsValid; attrs: - hasLicense attrs && builtins.elem attrs.meta.license whitelist; + hasLicense attrs && lib.lists.any (l: builtins.elem l whitelist) (lib.lists.toList attrs.meta.license); hasBlacklistedLicense = assert areLicenseListsValid; attrs: - hasLicense attrs && builtins.elem attrs.meta.license blacklist; + hasLicense attrs && lib.lists.any (l: builtins.elem l blacklist) (lib.lists.toList attrs.meta.license); allowBroken = config.allowBroken or false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1"; @@ -75,7 +75,7 @@ let allowInsecurePredicate attrs || builtins.getEnv "NIXPKGS_ALLOW_INSECURE" == "1"; - showLicense = license: license.shortName or "unknown"; + showLicense = license: toString (map (l: l.shortName or "unknown") (lib.lists.toList license)); pos_str = meta: meta.position or "«unknown-file»"; diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 311292169ecde..5b8fdde579612 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -17,9 +17,6 @@ fi # code). The hooks for <hookName> are the shell function or variable # <hookName>, and the values of the shell array ‘<hookName>Hooks’. runHook() { - local oldOpts="$(shopt -po nounset)" - set -u # May be called from elsewhere, so do `set -u`. - local hookName="$1" shift local hooksSlice="${hookName%Hook}Hooks[@]" @@ -29,10 +26,8 @@ runHook() { # undefined. for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; do _eval "$hook" "$@" - set -u # To balance `_eval` done - eval "${oldOpts}" return 0 } @@ -40,9 +35,6 @@ runHook() { # Run all hooks with the specified name, until one succeeds (returns a # zero exit code). If none succeed, return a non-zero exit code. runOneHook() { - local oldOpts="$(shopt -po nounset)" - set -u # May be called from elsewhere, so do `set -u`. - local hookName="$1" shift local hooksSlice="${hookName%Hook}Hooks[@]" @@ -54,10 +46,8 @@ runOneHook() { ret=0 break fi - set -u # To balance `_eval` done - eval "${oldOpts}" return "$ret" } @@ -68,24 +58,17 @@ runOneHook() { # environment variables) and from shell scripts (as functions). If you # want to allow multiple hooks, use runHook instead. _callImplicitHook() { - set -u local def="$1" local hookName="$2" - case "$(type -t "$hookName")" in - (function|alias|builtin) - set +u - "$hookName";; - (file) - set +u - source "$hookName";; - (keyword) :;; - (*) if [ -z "${!hookName:-}" ]; then - return "$def"; - else - set +u - eval "${!hookName}" - fi;; - esac + if declare -F "$hookName" > /dev/null; then + "$hookName" + elif type -p "$hookName" > /dev/null; then + source "$hookName" + elif [ -n "${!hookName:-}" ]; then + eval "${!hookName}" + else + return "$def" + fi # `_eval` expects hook to need nounset disable and leave it # disabled anyways, so Ok to to delegate. The alternative of a # return trap is no good because it would affect nested returns. @@ -96,14 +79,11 @@ _callImplicitHook() { # hooks exits the hook, not the caller. Also will only pass args if # command can take them _eval() { - if [ "$(type -t "$1")" = function ]; then - set +u + if declare -F "$1" > /dev/null 2>&1; then "$@" # including args else - set +u eval "$1" fi - # `run*Hook` reenables `set -u` } @@ -191,12 +171,12 @@ addToSearchPath() { # so it is defined here but tried after the hook. _addRpathPrefix() { if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then - export NIX_LDFLAGS="-rpath $1/lib $NIX_LDFLAGS" + export NIX_LDFLAGS="-rpath $1/lib ${NIX_LDFLAGS-}" if [ -n "${NIX_LIB64_IN_SELF_RPATH:-}" ]; then - export NIX_LDFLAGS="-rpath $1/lib64 $NIX_LDFLAGS" + export NIX_LDFLAGS="-rpath $1/lib64 ${NIX_LDFLAGS-}" fi if [ -n "${NIX_LIB32_IN_SELF_RPATH:-}" ]; then - export NIX_LDFLAGS="-rpath $1/lib32 $NIX_LDFLAGS" + export NIX_LDFLAGS="-rpath $1/lib32 ${NIX_LDFLAGS-}" fi fi } @@ -212,18 +192,6 @@ isELF() { if [ "$magic" = $'\177ELF' ]; then return 0; else return 1; fi } -# Return success if the specified file is an ELF object -# and its e_type is ET_EXEC (executable file) -isELFExec() { - grep -ao -P '^\177ELF.{11}\x00\x02' "$1" >/dev/null -} - -# Return success if the specified file is an ELF object -# and its e_type is ET_DYN (shared object file) -isELFDyn() { - grep -ao -P '^\177ELF.{11}\x00\x03' "$1" >/dev/null -} - # Return success if the specified file is a script (i.e. starts with # "#!"). isScript() { @@ -280,6 +248,8 @@ for i in $initialPath; do fi done +unset i + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "initial path: $PATH" fi @@ -309,11 +279,11 @@ declare -a pkgsBuildBuild pkgsBuildHost pkgsBuildTarget declare -a pkgsHostHost pkgsHostTarget declare -a pkgsTargetTarget -declare -ra pkgBuildAccumVars=(pkgsBuildBuild pkgsBuildHost pkgsBuildTarget) -declare -ra pkgHostAccumVars=(pkgsHostHost pkgsHostTarget) -declare -ra pkgTargetAccumVars=(pkgsTargetTarget) +declare -a pkgBuildAccumVars=(pkgsBuildBuild pkgsBuildHost pkgsBuildTarget) +declare -a pkgHostAccumVars=(pkgsHostHost pkgsHostTarget) +declare -a pkgTargetAccumVars=(pkgsTargetTarget) -declare -ra pkgAccumVarVars=(pkgBuildAccumVars pkgHostAccumVars pkgTargetAccumVars) +declare -a pkgAccumVarVars=(pkgBuildAccumVars pkgHostAccumVars pkgTargetAccumVars) # Hooks @@ -322,11 +292,11 @@ declare -a envBuildBuildHooks envBuildHostHooks envBuildTargetHooks declare -a envHostHostHooks envHostTargetHooks declare -a envTargetTargetHooks -declare -ra pkgBuildHookVars=(envBuildBuildHook envBuildHostHook envBuildTargetHook) -declare -ra pkgHostHookVars=(envHostHostHook envHostTargetHook) -declare -ra pkgTargetHookVars=(envTargetTargetHook) +declare -a pkgBuildHookVars=(envBuildBuildHook envBuildHostHook envBuildTargetHook) +declare -a pkgHostHookVars=(envHostHostHook envHostTargetHook) +declare -a pkgTargetHookVars=(envTargetTargetHook) -declare -ra pkgHookVarVars=(pkgBuildHookVars pkgHostHookVars pkgTargetHookVars) +declare -a pkgHookVarVars=(pkgBuildHookVars pkgHostHookVars pkgTargetHookVars) # Add env hooks for all sorts of deps with the specified host offset. addEnvHooks() { @@ -342,26 +312,26 @@ addEnvHooks() { # Propagated dep files -declare -ra propagatedBuildDepFiles=( +declare -a propagatedBuildDepFiles=( propagated-build-build-deps propagated-native-build-inputs # Legacy name for back-compat propagated-build-target-deps ) -declare -ra propagatedHostDepFiles=( +declare -a propagatedHostDepFiles=( propagated-host-host-deps propagated-build-inputs # Legacy name for back-compat ) -declare -ra propagatedTargetDepFiles=( +declare -a propagatedTargetDepFiles=( propagated-target-target-deps ) -declare -ra propagatedDepFilesVars=( +declare -a propagatedDepFilesVars=( propagatedBuildDepFiles propagatedHostDepFiles propagatedTargetDepFiles ) # Platform offsets: build = -1, host = 0, target = 1 -declare -ra allPlatOffsets=(-1 0 1) +declare -a allPlatOffsets=(-1 0 1) # Mutually-recursively find all build inputs. See the dependency section of the @@ -401,6 +371,7 @@ findInputs() { # The current package's host and target offset together # provide a <=-preserving homomorphism from the relative # offsets to current offset + local -i mapOffsetResult function mapOffset() { local -ri inputOffset="$1" if (( "$inputOffset" <= 0 )); then @@ -408,7 +379,7 @@ findInputs() { else local -ri outputOffset="$inputOffset - 1 + $targetOffset" fi - echo "$outputOffset" + mapOffsetResult="$outputOffset" } # Host offset relative to that of the package whose immediate @@ -420,8 +391,8 @@ findInputs() { # Host offset relative to the package currently being # built---as absolute an offset as will be used. - local -i hostOffsetNext - hostOffsetNext="$(mapOffset relHostOffset)" + mapOffset relHostOffset + local -i hostOffsetNext="$mapOffsetResult" # Ensure we're in bounds relative to the package currently # being built. @@ -439,8 +410,8 @@ findInputs() { # Target offset relative to the package currently being # built. - local -i targetOffsetNext - targetOffsetNext="$(mapOffset relTargetOffset)" + mapOffset relTargetOffset + local -i targetOffsetNext="$mapOffsetResult" # Once again, ensure we're in bounds relative to the # package currently being built. @@ -449,7 +420,8 @@ findInputs() { [[ -f "$pkg/nix-support/$file" ]] || continue local pkgNext - for pkgNext in $(< "$pkg/nix-support/$file"); do + read -r -d '' pkgNext < "$pkg/nix-support/$file" || true + for pkgNext in $pkgNext; do findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext" done done @@ -500,10 +472,7 @@ activatePackage() { (( "$hostOffset" <= "$targetOffset" )) || exit -1 if [ -f "$pkg" ]; then - local oldOpts="$(shopt -po nounset)" - set +u source "$pkg" - eval "$oldOpts" fi # Only dependencies whose host platform is guaranteed to match the @@ -522,10 +491,7 @@ activatePackage() { fi if [[ -f "$pkg/nix-support/setup-hook" ]]; then - local oldOpts="$(shopt -po nounset)" - set +u source "$pkg/nix-support/setup-hook" - eval "$oldOpts" fi } @@ -605,6 +571,13 @@ _addToEnv() { _addToEnv +# Unset setup-specific declared variables +unset allPlatOffsets +unset pkgBuildAccumVars pkgHostAccumVars pkgTargetAccumVars pkgAccumVarVars +unset pkgBuildHookVars pkgHostHookVars pkgTargetHookVars pkgHookVarVars +unset propagatedDepFilesVars + + _addRpathPrefix "$out" @@ -814,14 +787,17 @@ dumpVars() { # Utility function: echo the base name of the given path, with the # prefix `HASH-' removed, if present. stripHash() { - local strippedName + local strippedName casematchOpt=0 # On separate line for `set -e` - strippedName="$(basename "$1")" - if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then - echo "$strippedName" | cut -c34- + strippedName="$(basename -- "$1")" + shopt -q nocasematch && casematchOpt=1 + shopt -u nocasematch + if [[ "$strippedName" =~ ^[a-z0-9]{32}- ]]; then + echo "${strippedName:33}" else echo "$strippedName" fi + if (( casematchOpt )); then shopt -s nocasematch; fi } @@ -1273,17 +1249,11 @@ showPhaseHeader() { genericBuild() { if [ -f "${buildCommandPath:-}" ]; then - local oldOpts="$(shopt -po nounset)" - set +u source "$buildCommandPath" - eval "$oldOpts" return fi if [ -n "${buildCommand:-}" ]; then - local oldOpts="$(shopt -po nounset)" - set +u eval "$buildCommand" - eval "$oldOpts" return fi @@ -1313,10 +1283,7 @@ genericBuild() { # Evaluate the variable named $curPhase if it exists, otherwise the # function named $curPhase. - local oldOpts="$(shopt -po nounset)" - set +u eval "${!curPhase:-$curPhase}" - eval "$oldOpts" if [ "$curPhase" = unpackPhase ]; then cd "${sourceRoot:-.}" diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix index 8d513625df21d..0c285f9661e09 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix @@ -33,6 +33,15 @@ in with pkgs; rec { ''; }; + bootGCC = gcc.cc.override { enableLTO = false; }; + bootBinutils = binutils.bintools.override { + withAllTargets = false; + # Don't need two linkers, disable whatever's not primary/default. + gold = false; + # bootstrap is easier w/static + enableShared = false; + }; + build = stdenv.mkDerivation { @@ -109,12 +118,12 @@ in with pkgs; rec { cp -d ${gnugrep.pcre.out}/lib/libpcre*.so* $out/lib # needed by grep # Copy what we need of GCC. - cp -d ${gcc.cc.out}/bin/gcc $out/bin - cp -d ${gcc.cc.out}/bin/cpp $out/bin - cp -d ${gcc.cc.out}/bin/g++ $out/bin - cp -d ${gcc.cc.lib}/lib/libgcc_s.so* $out/lib - cp -d ${gcc.cc.lib}/lib/libstdc++.so* $out/lib - cp -rd ${gcc.cc.out}/lib/gcc $out/lib + cp -d ${bootGCC.out}/bin/gcc $out/bin + cp -d ${bootGCC.out}/bin/cpp $out/bin + cp -d ${bootGCC.out}/bin/g++ $out/bin + cp -d ${bootGCC.lib}/lib/libgcc_s.so* $out/lib + cp -d ${bootGCC.lib}/lib/libstdc++.so* $out/lib + cp -rd ${bootGCC.out}/lib/gcc $out/lib chmod -R u+w $out/lib rm -f $out/lib/gcc/*/*/include*/linux rm -f $out/lib/gcc/*/*/include*/sound @@ -122,11 +131,11 @@ in with pkgs; rec { rm -f $out/lib/gcc/*/*/include-fixed/asm rm -rf $out/lib/gcc/*/*/plugin #rm -f $out/lib/gcc/*/*/*.a - cp -rd ${gcc.cc.out}/libexec/* $out/libexec + cp -rd ${bootGCC.out}/libexec/* $out/libexec chmod -R u+w $out/libexec rm -rf $out/libexec/gcc/*/*/plugin mkdir -p $out/include - cp -rd ${gcc.cc.out}/include/c++ $out/include + cp -rd ${bootGCC.out}/include/c++ $out/include chmod -R u+w $out/include rm -rf $out/include/c++/*/ext/pb_ds rm -rf $out/include/c++/*/ext/parallel @@ -148,7 +157,7 @@ in with pkgs; rec { # Copy binutils. for i in as ld ar ranlib nm strip readelf objdump; do - cp ${binutils.bintools.out}/bin/$i $out/bin + cp ${bootBinutils.out}/bin/$i $out/bin done cp '${lib.getLib binutils.bintools}'/lib/* "$out/lib/" @@ -172,7 +181,7 @@ in with pkgs; rec { mv $out/.pack $out/pack mkdir $out/on-server - XZ_OPT=-9 tar cvJf $out/on-server/bootstrap-tools.tar.xz --hard-dereference --sort=name --numeric-owner --owner=0 --group=0 --mtime=@1 -C $out/pack . + XZ_OPT="-9 -e" tar cvJf $out/on-server/bootstrap-tools.tar.xz --hard-dereference --sort=name --numeric-owner --owner=0 --group=0 --mtime=@1 -C $out/pack . cp ${busyboxMinimal}/bin/busybox $out/on-server chmod u+w $out/on-server/busybox nuke-refs $out/on-server/busybox |