Merge branch 'master' into fix/man-in-outputsToInstall

This commit is contained in:
Matthew Bauer
2019-01-26 10:51:12 -05:00
committed by GitHub
13823 changed files with 610678 additions and 340640 deletions

View File

@@ -31,14 +31,23 @@ rec {
# Return a modified stdenv that tries to build statically linked
# binaries.
makeStaticBinaries = stdenv: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args // {
NIX_CFLAGS_LINK = "-static";
configureFlags =
toString args.configureFlags or ""
+ " --disable-shared"; # brrr...
makeStaticBinaries = stdenv:
let stdenv' = if stdenv.hostPlatform.libc != "glibc" then stdenv else
stdenv.override (prev: {
extraBuildInputs = prev.extraBuildInputs or [] ++ [
stdenv.glibc.static
];
});
in stdenv' //
{ mkDerivation = args:
if stdenv'.hostPlatform.isDarwin
then throw "Cannot build fully static binaries on Darwin/macOS"
else stdenv'.mkDerivation (args // {
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -static";
configureFlags = (args.configureFlags or []) ++ [
"--disable-shared" # brrr...
];
});
isStatic = true;
};
@@ -47,61 +56,13 @@ rec {
makeStaticLibraries = stdenv: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args // {
dontDisableStatic = true;
configureFlags =
toString args.configureFlags or ""
+ " --enable-static --disable-shared";
configureFlags = (args.configureFlags or []) ++ [
"--enable-static"
"--disable-shared"
];
});
};
# Return a modified stdenv that adds a cross compiler to the
# builds.
makeStdenvCross = { stdenv
, cc
, buildPlatform, hostPlatform, targetPlatform
, # Prior overrides are surely not valid as packages built
# with this run on a different platform, so disable by
# default.
overrides ? _: _: {}
} @ overrideArgs: let
stdenv = overrideArgs.stdenv.override {
inherit
buildPlatform hostPlatform targetPlatform
cc overrides;
allowedRequisites = null;
extraBuildInputs = [ ]; # Old ones run on wrong platform
};
in stdenv // {
mkDerivation =
{ nativeBuildInputs ? []
, selfNativeBuildInput ? args.crossAttrs.selfNativeBuildInput or false
, ...
} @ args:
let
# *BuildInputs exists temporarily as another name for
# *HostInputs.
# The base stdenv already knows that nativeBuildInputs and
# buildInputs should be built with the usual gcc-wrapper
# And the same for propagatedBuildInputs.
nativeDrv = stdenv.mkDerivation args;
in
stdenv.mkDerivation (args // {
nativeBuildInputs = nativeBuildInputs
++ stdenv.lib.optional selfNativeBuildInput nativeDrv
# without proper `file` command, libtool sometimes fails
# to recognize 64-bit DLLs
++ stdenv.lib.optional (hostPlatform.config == "x86_64-w64-mingw32") pkgs.file
++ stdenv.lib.optional (hostPlatform.isAarch64 || hostPlatform.libc == "musl") pkgs.updateAutotoolsGnuConfigScriptsHook
;
crossConfig = hostPlatform.config;
} // args.crossAttrs or {});
};
/* Modify a stdenv so that the specified attributes are added to
every derivation returned by its mkDerivation function.
@@ -219,4 +180,19 @@ rec {
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -fuse-ld=gold";
});
};
/* Modify a stdenv so that it builds binaries optimized specifically
for the machine they are built on.
WARNING: this breaks purity! */
impureUseNativeOptimizations = stdenv: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args // {
NIX_CFLAGS_COMPILE = toString (args.NIX_CFLAGS_COMPILE or "") + " -march=native";
NIX_ENFORCE_NO_NATIVE = false;
preferLocalBuild = true;
allowSubstitutes = false;
});
};
}

View File

@@ -1,24 +1,34 @@
{ lib
, localSystem, crossSystem, config, overlays
, localSystem, crossSystem, config, overlays, crossOverlays ? []
}:
let
bootStages = import ../. {
inherit lib localSystem overlays;
crossSystem = null;
crossSystem = localSystem;
crossOverlays = [];
# Ignore custom stdenvs when cross compiling for compatability
config = builtins.removeAttrs config [ "replaceStdenv" ];
};
in bootStages ++ [
in lib.init bootStages ++ [
# Build Packages
# Regular native packages
(somePrevStage: lib.last bootStages somePrevStage // {
# It's OK to change the built-time dependencies
allowCustomOverrides = true;
})
# Build tool Packages
(vanillaPackages: {
inherit config overlays;
selfBuild = false;
stdenv =
assert vanillaPackages.hostPlatform == localSystem;
assert vanillaPackages.targetPlatform == localSystem;
assert vanillaPackages.stdenv.buildPlatform == localSystem;
assert vanillaPackages.stdenv.hostPlatform == localSystem;
assert vanillaPackages.stdenv.targetPlatform == localSystem;
vanillaPackages.stdenv.override { targetPlatform = crossSystem; };
# It's OK to change the built-time dependencies
allowCustomOverrides = true;
@@ -26,17 +36,38 @@ in bootStages ++ [
# Run Packages
(buildPackages: {
inherit config overlays;
inherit config;
overlays = overlays ++ crossOverlays;
selfBuild = false;
stdenv = buildPackages.makeStdenvCross {
inherit (buildPackages) stdenv;
stdenv = buildPackages.stdenv.override (old: rec {
buildPlatform = localSystem;
hostPlatform = crossSystem;
targetPlatform = crossSystem;
cc = if crossSystem.useiOSCross or false
then buildPackages.darwin.ios-cross
# Prior overrides are surely not valid as packages built with this run on
# a different platform, and so are disabled.
overrides = _: _: {};
extraBuildInputs = [ ]; # Old ones run on wrong platform
allowedRequisites = null;
cc = if crossSystem.useiOSPrebuilt or false
then buildPackages.darwin.iosSdkPkgs.clang
else if crossSystem.useAndroidPrebuilt or false
then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".gcc
else buildPackages.gcc;
};
extraNativeBuildInputs = old.extraNativeBuildInputs
++ lib.optionals
(hostPlatform.isLinux && !buildPlatform.isLinux)
[ buildPackages.patchelf ]
++ lib.optional
(let f = p: !p.isx86 || p.libc == "musl"; in f hostPlatform && !(f buildPlatform))
buildPackages.updateAutotoolsGnuConfigScriptsHook
# without proper `file` command, libtool sometimes fails
# to recognize 64-bit DLLs
++ lib.optional (hostPlatform.config == "x86_64-w64-mingw32") buildPackages.file
;
});
})
]

View File

@@ -1,8 +1,8 @@
{ lib
, localSystem, crossSystem, config, overlays
, localSystem, crossSystem, config, overlays, crossOverlays ? []
}:
assert crossSystem == null;
assert crossSystem == localSystem;
let
bootStages = import ../. {

View File

@@ -8,7 +8,7 @@ _cygwinFixAutoImageBase() {
if [ -f /etc/rebasenix.nextbase ]; then
NEXTBASE="$(</etc/rebasenix.nextbase)"
fi
NEXTBASE=${NEXTBASE:-0x200000000}
NEXTBASE=${NEXTBASE:-0x200000001}
REBASE=(`/bin/rebase -i $DLL`)
BASE=${REBASE[2]}

View File

@@ -1,5 +1,5 @@
{ lib
, localSystem, crossSystem, config, overlays
, localSystem, crossSystem, config, overlays, crossOverlays ? []
# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools
, bootstrapFiles ? let
@@ -16,7 +16,7 @@
}
}:
assert crossSystem == null;
assert crossSystem == localSystem;
let
inherit (localSystem) system platform;
@@ -61,12 +61,14 @@ in rec {
libcxx,
allowedRequisites ? null}:
let
name = "bootstrap-stage${toString step}";
buildPackages = lib.optionalAttrs (last ? stdenv) {
inherit (last) stdenv;
};
coreutils = { name = "coreutils-9.9.9"; outPath = bootstrapTools; };
gnugrep = { name = "gnugrep-9.9.9"; outPath = bootstrapTools; };
coreutils = { name = "${name}-coreutils"; outPath = bootstrapTools; };
gnugrep = { name = "${name}-gnugrep"; outPath = bootstrapTools; };
bintools = import ../../build-support/bintools-wrapper {
inherit shell;
@@ -76,7 +78,7 @@ in rec {
nativeLibc = false;
inherit buildPackages coreutils gnugrep;
libc = last.pkgs.darwin.Libsystem;
bintools = { name = "binutils-9.9.9"; outPath = bootstrapTools; };
bintools = { name = "${name}-binutils"; outPath = bootstrapTools; };
};
cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper {
@@ -90,17 +92,17 @@ in rec {
inherit buildPackages coreutils gnugrep bintools;
libc = last.pkgs.darwin.Libsystem;
isClang = true;
cc = { name = "clang-9.9.9"; outPath = bootstrapTools; };
cc = { name = "${name}-clang"; outPath = bootstrapTools; };
};
thisStdenv = import ../generic {
name = "${name}-stdenv-darwin";
inherit config shell extraNativeBuildInputs extraBuildInputs;
allowedRequisites = if allowedRequisites == null then null else allowedRequisites ++ [
cc.expand-response-params cc.bintools
];
name = "stdenv-darwin-boot-${toString step}";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
@@ -146,7 +148,7 @@ in rec {
overrides = self: super: with stage0; rec {
darwin = super.darwin // {
Libsystem = stdenv.mkDerivation {
name = "bootstrap-Libsystem";
name = "bootstrap-stage0-Libsystem";
buildCommand = ''
mkdir -p $out
ln -s ${bootstrapTools}/lib $out/lib
@@ -156,26 +158,27 @@ in rec {
dyld = bootstrapTools;
};
libcxx = stdenv.mkDerivation {
name = "bootstrap-libcxx";
phases = [ "installPhase" "fixupPhase" ];
installPhase = ''
mkdir -p $out/lib $out/include
ln -s ${bootstrapTools}/lib/libc++.dylib $out/lib/libc++.dylib
ln -s ${bootstrapTools}/include/c++ $out/include/c++
'';
linkCxxAbi = false;
setupHook = ../../development/compilers/llvm/3.9/libc++/setup-hook.sh;
};
llvmPackages_5 = {
libcxx = stdenv.mkDerivation {
name = "bootstrap-stage0-libcxx";
phases = [ "installPhase" "fixupPhase" ];
installPhase = ''
mkdir -p $out/lib $out/include
ln -s ${bootstrapTools}/lib/libc++.dylib $out/lib/libc++.dylib
ln -s ${bootstrapTools}/include/c++ $out/include/c++
'';
linkCxxAbi = false;
setupHook = ../../development/compilers/llvm/3.9/libc++/setup-hook.sh;
};
libcxxabi = stdenv.mkDerivation {
name = "bootstrap-libcxxabi";
buildCommand = ''
mkdir -p $out/lib
ln -s ${bootstrapTools}/lib/libc++abi.dylib $out/lib/libc++abi.dylib
'';
libcxxabi = stdenv.mkDerivation {
name = "bootstrap-stage0-libcxxabi";
buildCommand = ''
mkdir -p $out/lib
ln -s ${bootstrapTools}/lib/libc++abi.dylib $out/lib/libc++abi.dylib
'';
};
};
};
extraNativeBuildInputs = [];
@@ -184,7 +187,21 @@ in rec {
};
stage1 = prevStage: let
persistent = _: super: { python = super.python.override { configd = null; }; };
persistent = self: super: with prevStage; {
cmake = super.cmake.override {
isBootstrap = true;
useSharedLibraries = false;
};
python = super.callPackage ../../development/interpreters/python/cpython/2.7/boot.nix {
CF = null; # use CoreFoundation from bootstrap-tools
configd = null;
};
python2 = self.python;
ninja = super.ninja.override { buildDocs = false; };
darwin = super.darwin // { cctools = super.darwin.cctools.override { llvm = null; }; };
};
in with prevStage; stageFun 1 prevStage {
extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\"";
extraNativeBuildInputs = [];
@@ -203,11 +220,12 @@ in rec {
zlib patchutils m4 scons flex perl bison unifdef unzip openssl python
libxml2 gettext sharutils gmp libarchive ncurses pkg-config libedit groff
openssh sqlite sed serf openldap db cyrus-sasl expat apr-util subversion xz
findfreetype libssh curl cmake autoconf automake libtool ed cpio coreutils;
findfreetype libssh curl cmake autoconf automake libtool ed cpio coreutils
libssh2 nghttp2 libkrb5 python2 ninja;
darwin = super.darwin // {
inherit (darwin)
dyld Libsystem xnu configd ICU libdispatch libclosure launchd;
dyld Libsystem xnu configd ICU libdispatch libclosure launchd CF;
};
};
in with prevStage; stageFun 2 prevStage {
@@ -221,7 +239,10 @@ in rec {
allowedRequisites =
[ bootstrapTools ] ++
(with pkgs; [ xz.bin xz.out libcxx libcxxabi ]) ++
(with pkgs; [
xz.bin xz.out libcxx libcxxabi zlib libxml2.out curl.out openssl.out libssh2.out
nghttp2.lib libkrb5
]) ++
(with pkgs.darwin; [ dyld Libsystem CF ICU locale ]);
overrides = persistent;
@@ -234,7 +255,16 @@ in rec {
gettext sharutils libarchive pkg-config groff bash subversion
openssh sqlite sed serf openldap db cyrus-sasl expat apr-util
findfreetype libssh curl cmake autoconf automake libtool cpio
libcxx libcxxabi;
libssh2 nghttp2 libkrb5 python2 ninja;
# Avoid pulling in a full python and its extra dependencies for the llvm/clang builds.
libxml2 = super.libxml2.override { pythonSupport = false; };
llvmPackages_5 = super.llvmPackages_5 // (let
libraries = super.llvmPackages_5.libraries.extend (_: _: {
inherit (llvmPackages_5) libcxx libcxxabi;
});
in { inherit libraries; } // libraries);
darwin = super.darwin // {
inherit (darwin)
@@ -259,7 +289,10 @@ in rec {
allowedRequisites =
[ bootstrapTools ] ++
(with pkgs; [ xz.bin xz.out bash libcxx libcxxabi ]) ++
(with pkgs; [
xz.bin xz.out bash libcxx libcxxabi zlib libxml2.out curl.out openssl.out libssh2.out
nghttp2.lib libkrb5
]) ++
(with pkgs.darwin; [ dyld ICU Libsystem locale ]);
overrides = persistent;
@@ -269,17 +302,35 @@ in rec {
persistent = self: super: with prevStage; {
inherit
gnumake gzip gnused bzip2 gawk ed xz patch bash
libcxxabi libcxx ncurses libffi zlib gmp pcre gnugrep
coreutils findutils diffutils patchutils;
ncurses libffi zlib gmp pcre gnugrep
coreutils findutils diffutils patchutils ninja;
llvmPackages = let llvmOverride = llvmPackages.llvm.override { inherit libcxxabi; };
in super.llvmPackages // {
llvm = llvmOverride;
clang-unwrapped = llvmPackages.clang-unwrapped.override { llvm = llvmOverride; };
};
# Hack to make sure we don't link ncurses in bootstrap tools. The proper
# solution is to avoid passing -L/nix-store/...-bootstrap-tools/lib,
# quite a sledgehammer just to get the C runtime.
gettext = super.gettext.overrideAttrs (drv: {
configureFlags = drv.configureFlags ++ [
"--disable-curses"
];
});
darwin = super.darwin // {
llvmPackages_5 = super.llvmPackages_5 // (let
tools = super.llvmPackages_5.tools.extend (llvmSelf: _: {
inherit (llvmPackages_5) llvm clang-unwrapped;
});
libraries = super.llvmPackages_5.libraries.extend (llvmSelf: _: {
inherit (llvmPackages_5) libcxx libcxxabi compiler-rt;
});
in { inherit tools libraries; } // tools // libraries);
darwin = super.darwin // rec {
inherit (darwin) dyld Libsystem libiconv locale;
libxml2-nopython = super.libxml2.override { pythonSupport = false; };
CF = super.darwin.CF.override {
libxml2 = libxml2-nopython;
python = prevStage.python;
};
};
};
in with prevStage; stageFun 4 prevStage {
@@ -291,16 +342,7 @@ in rec {
extraPreHook = ''
export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
'';
overrides = self: super: (persistent self super) // {
# Hack to make sure we don't link ncurses in bootstrap tools. The proper
# solution is to avoid passing -L/nix-store/...-bootstrap-tools/lib,
# quite a sledgehammer just to get the C runtime.
gettext = super.gettext.overrideAttrs (old: {
configureFlags = old.configureFlags ++ [
"--disable-curses"
];
});
};
overrides = persistent;
};
stdenvDarwin = prevStage: let
@@ -308,28 +350,44 @@ in rec {
persistent = self: super: with prevStage; {
inherit
gnumake gzip gnused bzip2 gawk ed xz patch bash
libcxxabi libcxx ncurses libffi zlib llvm gmp pcre gnugrep
ncurses libffi zlib llvm gmp pcre gnugrep
coreutils findutils diffutils patchutils;
llvmPackages = super.llvmPackages // {
inherit (llvmPackages) llvm clang-unwrapped;
};
llvmPackages_5 = super.llvmPackages_5 // (let
tools = super.llvmPackages_5.tools.extend (_: super: {
inherit (llvmPackages_5) llvm clang-unwrapped;
});
libraries = super.llvmPackages_5.libraries.extend (_: _: {
inherit (llvmPackages_5) compiler-rt libcxx libcxxabi;
});
in { inherit tools libraries; } // tools // libraries);
# N.B: the important thing here is to ensure that python == python2
# == python27 or you get weird issues with inconsistent package sets.
# In a particularly subtle bug, I overrode python2 instead of python27
# here, and it caused gnome-doc-utils to complain about:
# "PyThreadState_Get: no current thread". This is because Python gets
# really unhappy if you have Python A which loads a native python lib
# which was linked against Python B, which in our case was happening
# because we didn't override python "deeply enough". Anyway, this works
# and I'm just leaving this blurb here so people realize why it matters
python27 = super.python27.override { CF = prevStage.darwin.CF; };
darwin = super.darwin // {
inherit (darwin) dyld ICU Libsystem libiconv;
} // lib.optionalAttrs (super.targetPlatform == localSystem) {
inherit (darwin) cctools;
} // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
inherit (darwin) binutils binutils-unwrapped cctools;
};
} // lib.optionalAttrs (super.targetPlatform == localSystem) {
} // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
# Need to get rid of these when cross-compiling.
inherit binutils binutils-raw;
inherit binutils binutils-unwrapped;
};
in import ../generic rec {
name = "stdenv-darwin";
inherit config;
inherit (pkgs.stdenv) fetchurlBoot;
name = "stdenv-darwin";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
@@ -345,19 +403,8 @@ in rec {
initialPath = import ../common-path.nix { inherit pkgs; };
shell = "${pkgs.bash}/bin/bash";
cc = lib.callPackageWith {} ../../build-support/cc-wrapper {
inherit (pkgs) stdenvNoCC;
inherit shell;
nativeTools = false;
nativeLibc = false;
buildPackages = {
inherit (prevStage) stdenv;
};
inherit (pkgs) coreutils gnugrep;
cc = pkgs.llvmPackages.clang-unwrapped;
bintools = pkgs.darwin.binutils;
libc = pkgs.darwin.Libsystem;
extraPackages = [ pkgs.libcxx ];
cc = pkgs.llvmPackages.libcxxClang.override {
cc = pkgs.llvmPackages.clang-unwrapped;
};
extraNativeBuildInputs = [];
@@ -374,25 +421,26 @@ in rec {
allowedRequisites = (with pkgs; [
xz.out xz.bin libcxx libcxxabi gmp.out gnumake findutils bzip2.out
bzip2.bin llvmPackages.llvm llvmPackages.llvm.lib zlib.out zlib.dev libffi.out coreutils ed diffutils gnutar
bzip2.bin llvmPackages.llvm llvmPackages.llvm.lib llvmPackages.compiler-rt llvmPackages.compiler-rt.dev
zlib.out zlib.dev libffi.out coreutils ed diffutils gnutar
gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk
gnugrep llvmPackages.clang-unwrapped llvmPackages.clang-unwrapped.lib patch pcre.out gettext
binutils-raw.bintools binutils binutils.bintools
binutils.bintools darwin.binutils darwin.binutils.bintools
curl.out openssl.out libssh2.out nghttp2.lib libkrb5
cc.expand-response-params
]) ++ (with pkgs.darwin; [
dyld Libsystem CF cctools ICU libiconv locale
dyld Libsystem CF cctools ICU libiconv locale libxml2-nopython.out
]);
overrides = self: super:
let persistent' = persistent self super; in persistent' // {
clang = cc;
llvmPackages = persistent'.llvmPackages // { clang = cc; };
inherit cc;
overrides = lib.composeExtensions persistent (self: super: {
clang = cc;
llvmPackages = super.llvmPackages // { clang = cc; };
inherit cc;
darwin = super.darwin // {
xnu = super.darwin.xnu.override { python = super.python.override { configd = null; }; };
};
darwin = super.darwin // {
xnu = super.darwin.xnu.override { python = super.python.override { configd = null; }; };
};
});
};
stagesDarwin = [

View File

@@ -3,7 +3,7 @@
with import pkgspath { inherit system; };
let
llvmPackages = llvmPackages_4;
llvmPackages = llvmPackages_5;
in rec {
coreutils_ = coreutils.override (args: {
# We want coreutils without ACL support.
@@ -12,6 +12,10 @@ in rec {
singleBinary = false;
});
# We want a version of cctools without LLVM, because the LTO support ends up making
# the bootstrap tools huge and isn't really necessary for bootstrap
cctools_ = darwin.cctools.override { llvm = null; };
# Avoid debugging larger changes for now.
bzip2_ = bzip2.override (args: { linkStatic = true; });
@@ -73,6 +77,7 @@ in rec {
cp -d ${gettext}/lib/libintl*.dylib $out/lib
chmod +x $out/lib/libintl*.dylib
cp -d ${ncurses.out}/lib/libncurses*.dylib $out/lib
cp -d ${libxml2.out}/lib/libxml2*.dylib $out/lib
# Copy what we need of clang
cp -d ${llvmPackages.clang-unwrapped}/bin/clang $out/bin
@@ -93,8 +98,8 @@ in rec {
cp -d ${xz.out}/lib/liblzma*.* $out/lib
# Copy binutils.
for i in as ld ar ranlib nm strip otool install_name_tool dsymutil lipo; do
cp ${darwin.cctools}/bin/$i $out/bin
for i in as ld ar ranlib nm strip otool install_name_tool lipo; do
cp ${cctools_}/bin/$i $out/bin
done
cp -rd ${pkgs.darwin.CF}/Library $out
@@ -104,9 +109,9 @@ in rec {
nuke-refs $out/bin/*
rpathify() {
local libs=$(${darwin.cctools}/bin/otool -L "$1" | tail -n +2 | grep -o "$NIX_STORE.*-\S*") || true
local libs=$(${cctools_}/bin/otool -L "$1" | tail -n +2 | grep -o "$NIX_STORE.*-\S*") || true
for lib in $libs; do
${darwin.cctools}/bin/install_name_tool -change $lib "@rpath/$(basename $lib)" "$1"
${cctools_}/bin/install_name_tool -change $lib "@rpath/$(basename $lib)" "$1"
done
}
@@ -178,6 +183,9 @@ in rec {
unpack = stdenv.mkDerivation (bootstrapFiles // {
name = "unpack";
reexportedLibrariesFile =
../../os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries;
# This is by necessity a near-duplicate of unpack-bootstrap-tools.sh. If we refer to it directly,
# we can't make any changes to it due to our testing stdenv depending on it. Think of this as the
# unpack-bootstrap-tools.sh for the next round of bootstrap tools.
@@ -209,7 +217,7 @@ in rec {
$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 }')
libs=$(cat $reexportedLibrariesFile | grep -v '^#')
for i in $libs; do
if [ "$i" != "/usr/lib/system/libsystem_kernel.dylib" ] && [ "$i" != "/usr/lib/system/libsystem_c.dylib" ]; then

View File

@@ -0,0 +1,12 @@
# Make /nix/store/...-libSystem “portable” for static built binaries.
# This just rewrites everything in $1/bin to use the
# /usr/lib/libSystem.B.dylib that is provided on every macOS system.
fixupOutputHooks+=('fixLibsystemRefs $prefix')
fixLibsystemRefs() {
if [ -d "$1/bin" ]; then
find "$1/bin" -exec \
install_name_tool -change @libsystem@ /usr/lib/libSystem.B.dylib {} \;
fi
}

View File

@@ -7,7 +7,7 @@
{ # Args just for stdenvs' usage
lib
# Args to pass on to the pkgset builder, too
, localSystem, crossSystem, config, overlays
, localSystem, crossSystem, config, overlays, crossOverlays ? []
} @ args:
let
@@ -36,7 +36,7 @@ let
# Select the appropriate stages for the platform `system'.
in
if crossSystem != null then stagesCross
if crossSystem != localSystem || crossOverlays != [] then stagesCross
else if config ? replaceStdenv then stagesCustom
else { # switch
"i686-linux" = stagesLinux;
@@ -45,8 +45,9 @@ in
"armv6l-linux" = stagesLinux;
"armv7l-linux" = stagesLinux;
"aarch64-linux" = stagesLinux;
"mips64el-linux" = stagesLinux;
"mipsel-linux" = stagesLinux;
"powerpc-linux" = /* stagesLinux */ stagesNative;
"powerpc64le-linux" = stagesLinux;
"x86_64-darwin" = stagesDarwin;
"x86_64-solaris" = stagesNix;
"i686-cygwin" = stagesNative;

View File

@@ -2,7 +2,7 @@
, localSystem, crossSystem, config, overlays
}:
assert crossSystem == null;
assert crossSystem == localSystem;
let inherit (localSystem) system; in

View File

@@ -1,16 +1,19 @@
# Checks derivation meta and attrs for problems (like brokenness,
# licenses, etc).
{ lib, config, system, meta, derivationArg, mkDerivationArg }:
{ lib, config, hostPlatform, meta }:
let
attrs = mkDerivationArg; # TODO: probably get rid of passing this one
# If we're in hydra, we can dispense with the more verbose error
# messages and make problems easier to spot.
inHydra = config.inHydra or false;
# See discussion at https://github.com/NixOS/nixpkgs/pull/25304#issuecomment-298385426
# for why this defaults to false, but I (@copumpkin) want to default it to true soon.
shouldCheckMeta = config.checkMeta or false;
allowUnfree = config.allowUnfree or false || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1";
allowUnfree = config.allowUnfree or false
|| builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1";
whitelist = config.whitelistedLicenses or [];
blacklist = config.blacklistedLicenses or [];
@@ -37,12 +40,13 @@ let
hasBlacklistedLicense = assert areLicenseListsValid; attrs:
hasLicense attrs && builtins.elem attrs.meta.license blacklist;
allowBroken = config.allowBroken or false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1";
allowBroken = config.allowBroken or false
|| builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1";
allowUnsupportedSystem = config.allowUnsupportedSystem or false;
allowUnsupportedSystem = config.allowUnsupportedSystem or false
|| builtins.getEnv "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" == "1";
isUnfree = licenses: lib.lists.any (l:
!l.free or true || l == "unfree" || l == "unfree-redistributable") licenses;
isUnfree = licenses: lib.lists.any (l: !l.free or true) licenses;
# Alow granular checks to allow only some unfree packages
# Example:
@@ -55,7 +59,7 @@ let
# Check whether unfree packages are allowed and if not, whether the
# package has an unfree license and is not explicitely allowed by the
# `allowUNfreePredicate` function.
# `allowUnfreePredicate` function.
hasDeniedUnfreeLicense = attrs:
!allowUnfree &&
hasLicense attrs &&
@@ -77,8 +81,10 @@ let
remediation = {
unfree = remediate_whitelist "Unfree";
broken = remediate_whitelist "Broken";
unsupported = remediate_whitelist "UnsupportedSystem";
blacklisted = x: "";
insecure = remediate_insecure;
broken-outputs = remediateOutputsToInstall;
unknown-meta = x: "";
};
remediate_whitelist = allow_attr: attrs:
@@ -123,12 +129,28 @@ let
'';
handleEvalIssue = { reason , errormsg ? "" }:
let
msg = ''
Package ${attrs.name or "«name-missing»"} in ${pos_str} ${errormsg}, refusing to evaluate.
remediateOutputsToInstall = attrs: let
expectedOutputs = attrs.meta.outputsToInstall or [];
actualOutputs = attrs.outputs or [ "out" ];
missingOutputs = builtins.filter (output: ! builtins.elem output actualOutputs) expectedOutputs;
in ''
The package ${attrs.name} has set meta.outputsToInstall to: ${builtins.concatStringsSep ", " expectedOutputs}
'' + (builtins.getAttr reason remediation) attrs;
however ${attrs.name} only has the outputs: ${builtins.concatStringsSep ", " actualOutputs}
and is missing the following ouputs:
${lib.concatStrings (builtins.map (output: " - ${output}\n") missingOutputs)}
'';
handleEvalIssue = attrs: { reason , errormsg ? "" }:
let
msg = if inHydra
then "Failed to evaluate ${attrs.name or "«name-missing»"}: «${reason}»: ${errormsg}"
else ''
Package ${attrs.name or "«name-missing»"} in ${pos_str} ${errormsg}, refusing to evaluate.
'' + (builtins.getAttr reason remediation) attrs;
handler = if config ? "handleEvalIssue"
then config.handleEvalIssue reason
@@ -144,11 +166,22 @@ let
homepage = either (listOf str) str;
downloadPage = str;
license = either (listOf lib.types.attrs) (either lib.types.attrs str);
maintainers = listOf str;
maintainers = listOf (attrsOf str);
priority = int;
platforms = listOf str;
platforms = listOf (either str lib.systems.parsedPlatform.types.system);
hydraPlatforms = listOf str;
broken = bool;
# TODO: refactor once something like Profpatsch's types-simple will land
# This is currently dead code due to https://github.com/NixOS/nix/issues/2532
tests = attrsOf (mkOptionType {
name = "test";
check = x: x == {} || ( # Accept {} for tests that are unsupported
isDerivation x &&
x ? meta.timeout
);
merge = lib.options.mergeOneOption;
});
timeout = int;
# Weirder stuff that doesn't appear in the documentation?
knownVulnerabilities = listOf str;
@@ -167,6 +200,7 @@ let
isFcitxEngine = bool;
isIbusEngine = bool;
isGutenprint = bool;
badPlatforms = platforms;
};
checkMetaAttr = k: v:
@@ -175,6 +209,19 @@ let
else "key '${k}' is unrecognized; expected one of: \n\t [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]";
checkMeta = meta: if shouldCheckMeta then lib.remove null (lib.mapAttrsToList checkMetaAttr meta) else [];
checkPlatform = attrs: let
anyMatch = lib.any (lib.meta.platformMatch hostPlatform);
in anyMatch (attrs.meta.platforms or lib.platforms.all) &&
! anyMatch (attrs.meta.badPlatforms or []);
checkOutputsToInstall = attrs: let
expectedOutputs = attrs.meta.outputsToInstall or [];
actualOutputs = attrs.outputs or [ "out" ];
missingOutputs = builtins.filter (output: ! builtins.elem output actualOutputs) expectedOutputs;
in if shouldCheckMeta
then builtins.length missingOutputs > 0
else false;
# Check if a derivation is valid, that is whether it passes checks for
# e.g brokenness or license.
#
@@ -188,19 +235,23 @@ let
{ valid = false; reason = "blacklisted"; errormsg = "has a blacklisted license (${showLicense attrs.meta.license})"; }
else if !allowBroken && attrs.meta.broken or false then
{ valid = false; reason = "broken"; errormsg = "is marked as broken"; }
else if !allowUnsupportedSystem && !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem system attrs.meta.platforms then
{ valid = false; reason = "broken"; errormsg = "is not supported on ${system}"; }
else if !allowUnsupportedSystem && !(checkPlatform attrs) then
{ valid = false; reason = "unsupported"; errormsg = "is not supported on ${hostPlatform.config}"; }
else if !(hasAllowedInsecure attrs) then
{ valid = false; reason = "insecure"; errormsg = "is marked as insecure"; }
else if checkOutputsToInstall attrs then
{ valid = false; reason = "broken-outputs"; errormsg = "has invalid meta.outputsToInstall"; }
else let res = checkMeta (attrs.meta or {}); in if res != [] then
{ valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; }
else { valid = true; };
validity = checkValidity attrs;
assertValidity = attrs: let
validity = checkValidity attrs;
in validity // {
# Throw an error if trying to evaluate an non-valid derivation
handled = if !validity.valid
then handleEvalIssue attrs (removeAttrs validity ["valid"])
else true;
};
in validity // {
# Throw an error if trying to evaluate an non-valid derivation
handled = if !validity.valid
then handleEvalIssue (removeAttrs validity ["valid"])
else true;
}
in assertValidity

View File

@@ -90,9 +90,14 @@ let
'' + lib.optionalString hostPlatform.isDarwin ''
export NIX_DONT_SET_RPATH=1
export NIX_NO_SELF_RPATH=1
'' + lib.optionalString targetPlatform.isDarwin ''
export NIX_TARGET_DONT_SET_RPATH=1
'';
''
# TODO this should be uncommented, but it causes stupid mass rebuilds. I
# think the best solution would just be to fixup linux RPATHs so we don't
# need to set `-rpath` anywhere.
# + lib.optionalString targetPlatform.isDarwin ''
# export NIX_TARGET_DONT_SET_RPATH=1
# ''
;
inherit initialPath shell
defaultNativeBuildInputs defaultBuildInputs;
@@ -116,11 +121,14 @@ let
# Utility flags to test the type of platform.
inherit (hostPlatform)
isDarwin isLinux isSunOS isHurd isCygwin isFreeBSD isOpenBSD
isi686 isx86_64 is64bit isArm isAarch64 isMips isBigEndian;
isDarwin isLinux isSunOS isCygwin isFreeBSD isOpenBSD
isi686 isx86_64 is64bit isAarch32 isAarch64 isMips isBigEndian;
isArm = lib.warn
"`stdenv.isArm` is deprecated after 18.03. Please use `stdenv.isAarch32` instead"
hostPlatform.isAarch32;
# Whether we should run paxctl to pax-mark binaries.
needsPax = isLinux;
# The derivation's `system` is `buildPlatform.system`.
inherit (buildPlatform) system;
inherit (import ./make-derivation.nix {
inherit lib config stdenv;
@@ -135,8 +143,6 @@ let
inherit overrides;
inherit cc;
isCross = targetPlatform != buildPlatform;
}
# Propagate any extra attributes. For instance, we use this to

View File

@@ -36,8 +36,12 @@ rec {
, depsTargetTarget ? [] # 1 -> 1
, depsTargetTargetPropagated ? [] # 1 -> 1
, checkInputs ? []
, installCheckInputs ? []
# Configure Phase
, configureFlags ? []
, cmakeFlags ? []
, # Target is not included by default because most programs don't care.
# Including it then would cause needless mass rebuilds.
#
@@ -46,18 +50,23 @@ rec {
(stdenv.hostPlatform != stdenv.buildPlatform)
[ "build" "host" ]
# TODO(@Ericson2314): Make unconditional / resolve #33599
# Check phase
, doCheck ? false
, doCheck ? config.doCheckByDefault or false
# TODO(@Ericson2314): Make unconditional / resolve #33599
# InstallCheck phase
, doInstallCheck ? false
, doInstallCheck ? config.doCheckByDefault or false
, crossConfig ? null
, # TODO(@Ericson2314): Make always true and remove
strictDeps ? stdenv.hostPlatform != stdenv.buildPlatform
, meta ? {}
, passthru ? {}
, pos ? # position used in error messages and for meta.position
(if attrs.meta.description or null != null
then builtins.unsafeGetAttrPos "description" attrs.meta
else if attrs.version or null != null
then builtins.unsafeGetAttrPos "version" attrs
else builtins.unsafeGetAttrPos "name" attrs)
, separateDebugInfo ? false
, outputs ? [ "out" ]
@@ -71,9 +80,31 @@ rec {
, ... } @ attrs:
# TODO(@Ericson2314): Make this more modular, and not O(n^2).
let
computedName = if name != "" then name else "${attrs.pname}-${attrs.version}";
# TODO(@oxij, @Ericson2314): This is here to keep the old semantics, remove when
# no package has `doCheck = true`.
doCheck' = doCheck && stdenv.hostPlatform == stdenv.buildPlatform;
doInstallCheck' = doInstallCheck && stdenv.hostPlatform == stdenv.buildPlatform;
separateDebugInfo' = separateDebugInfo && stdenv.hostPlatform.isLinux;
outputs' = outputs ++ lib.optional separateDebugInfo' "debug";
fixedOutputDrv = attrs ? outputHash;
noNonNativeDeps = builtins.length (depsBuildTarget ++ depsBuildTargetPropagated
++ depsHostHost ++ depsHostHostPropagated
++ buildInputs ++ propagatedBuildInputs
++ depsTargetTarget ++ depsTargetTargetPropagated) == 0;
dontAddHostSuffix = attrs ? outputHash && !noNonNativeDeps || stdenv.cc == null;
supportedHardeningFlags = [ "fortify" "stackprotector" "pie" "pic" "strictoverflow" "format" "relro" "bindnow" ];
defaultHardeningFlags = if stdenv.hostPlatform.isMusl
then supportedHardeningFlags
else lib.remove "pie" supportedHardeningFlags;
enabledHardeningOptions =
if builtins.elem "all" hardeningDisable
then []
else lib.subtractLists hardeningDisable (defaultHardeningFlags ++ hardeningEnable);
# hardeningDisable additionally supports "all".
erroneousHardeningFlags = lib.subtractLists supportedHardeningFlags (hardeningEnable ++ lib.remove "all" hardeningDisable);
in if builtins.length erroneousHardeningFlags != 0
@@ -81,6 +112,11 @@ rec {
inherit erroneousHardeningFlags hardeningDisable hardeningEnable supportedHardeningFlags;
})
else let
doCheck = doCheck';
doInstallCheck = doInstallCheck';
outputs = outputs';
references = nativeBuildInputs ++ buildInputs
++ propagatedNativeBuildInputs ++ propagatedBuildInputs;
@@ -88,13 +124,15 @@ rec {
[
(map (drv: drv.__spliced.buildBuild or drv) depsBuildBuild)
(map (drv: drv.nativeDrv or drv) nativeBuildInputs
++ lib.optional separateDebugInfo ../../build-support/setup-hooks/separate-debug-info.sh
++ lib.optional separateDebugInfo' ../../build-support/setup-hooks/separate-debug-info.sh
++ lib.optional stdenv.hostPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh)
(map (drv: drv.__spliced.buildTarget or drv) depsBuildTarget)
]
[
(map (drv: drv.__spliced.hostHost or drv) depsHostHost)
(map (drv: drv.crossDrv or drv) buildInputs)
(map (drv: drv.crossDrv or drv) (buildInputs
++ lib.optionals doCheck checkInputs
++ lib.optionals doInstallCheck' installCheckInputs))
]
[
(map (drv: drv.__spliced.targetTarget or drv) depsTargetTarget)
@@ -115,58 +153,71 @@ rec {
]
];
outputs' =
outputs ++
(if separateDebugInfo then assert stdenv.hostPlatform.isLinux; [ "debug" ] else []);
computedSandboxProfile =
lib.concatMap (input: input.__propagatedSandboxProfile or [])
(stdenv.extraNativeBuildInputs
++ stdenv.extraBuildInputs
++ lib.concatLists dependencies);
computedPropagatedSandboxProfile =
lib.concatMap (input: input.__propagatedSandboxProfile or [])
(lib.concatLists propagatedDependencies);
computedImpureHostDeps =
lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or [])
(stdenv.extraNativeBuildInputs
++ stdenv.extraBuildInputs
++ lib.concatLists dependencies));
computedPropagatedImpureHostDeps =
lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or [])
(lib.concatLists propagatedDependencies));
derivationArg =
(removeAttrs attrs
["meta" "passthru" "crossAttrs" "pos"
["meta" "passthru" "pos"
"checkInputs" "installCheckInputs"
"__impureHostDeps" "__propagatedImpureHostDeps"
"sandboxProfile" "propagatedSandboxProfile"])
// (let
computedSandboxProfile =
lib.concatMap (input: input.__propagatedSandboxProfile or [])
(stdenv.extraNativeBuildInputs
++ stdenv.extraBuildInputs
++ lib.concatLists dependencies);
computedPropagatedSandboxProfile =
lib.concatMap (input: input.__propagatedSandboxProfile or [])
(lib.concatLists propagatedDependencies);
computedImpureHostDeps =
lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or [])
(stdenv.extraNativeBuildInputs
++ stdenv.extraBuildInputs
++ lib.concatLists dependencies));
computedPropagatedImpureHostDeps =
lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or [])
(lib.concatLists propagatedDependencies));
in
{
// {
# A hack to make `nix-env -qa` and `nix search` ignore broken packages.
# TODO(@oxij): remove this assert when something like NixOS/nix#1771 gets merged into nix.
name = assert validity.handled; name + lib.optionalString
(stdenv.hostPlatform != stdenv.buildPlatform)
name = assert validity.handled; computedName + lib.optionalString
# Fixed-output derivations like source tarballs shouldn't get a host
# suffix. But we have some weird ones with run-time deps that are
# just used for their side-affects. Those might as well since the
# hash can't be the same. See #32986.
(stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix)
("-" + stdenv.hostPlatform.config);
builder = attrs.realBuilder or stdenv.shell;
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
inherit stdenv;
inherit (stdenv) system;
# The `system` attribute of a derivation has special meaning to Nix.
# Derivations set it to choose what sort of machine could be used to
# execute the build, The build platform entirely determines this,
# indeed more finely than Nix knows or cares about. The `system`
# attribute of `buildPlatfom` matches Nix's degree of specificity.
# exactly.
inherit (stdenv.buildPlatform) system;
userHook = config.stdenv.userHook or null;
__ignoreNulls = true;
inherit strictDeps;
depsBuildBuild = lib.elemAt (lib.elemAt dependencies 0) 0;
nativeBuildInputs = lib.elemAt (lib.elemAt dependencies 0) 1;
depsBuildTarget = lib.elemAt (lib.elemAt dependencies 0) 2;
depsHostBuild = lib.elemAt (lib.elemAt dependencies 1) 0;
depsHostHost = lib.elemAt (lib.elemAt dependencies 1) 0;
buildInputs = lib.elemAt (lib.elemAt dependencies 1) 1;
depsTargetTarget = lib.elemAt (lib.elemAt dependencies 2) 0;
depsBuildBuildPropagated = lib.elemAt (lib.elemAt propagatedDependencies 0) 0;
propagatedNativeBuildInputs = lib.elemAt (lib.elemAt propagatedDependencies 0) 1;
depsBuildTargetPropagated = lib.elemAt (lib.elemAt propagatedDependencies 0) 2;
depsHostBuildPropagated = lib.elemAt (lib.elemAt propagatedDependencies 1) 0;
depsHostHostPropagated = lib.elemAt (lib.elemAt propagatedDependencies 1) 0;
propagatedBuildInputs = lib.elemAt (lib.elemAt propagatedDependencies 1) 1;
depsTargetTargetPropagated = lib.elemAt (lib.elemAt propagatedDependencies 2) 0;
@@ -179,6 +230,24 @@ rec {
++ optional (elem "host" configurePlatforms) "--host=${stdenv.hostPlatform.config}"
++ optional (elem "target" configurePlatforms) "--target=${stdenv.targetPlatform.config}";
inherit doCheck doInstallCheck;
inherit outputs;
} // lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) {
cmakeFlags =
(/**/ if lib.isString cmakeFlags then [cmakeFlags]
else if cmakeFlags == null then []
else cmakeFlags)
++ lib.optional (stdenv.hostPlatform.uname.system != null) "-DCMAKE_SYSTEM_NAME=${stdenv.hostPlatform.uname.system}"
++ lib.optional (stdenv.hostPlatform.uname.processor != null) "-DCMAKE_SYSTEM_PROCESSOR=${stdenv.hostPlatform.uname.processor}"
++ lib.optional (stdenv.hostPlatform.uname.release != null) "-DCMAKE_SYSTEM_VERSION=${stdenv.hostPlatform.release}"
++ lib.optional (stdenv.buildPlatform.uname.system != null) "-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}"
++ lib.optional (stdenv.buildPlatform.uname.processor != null) "-DCMAKE_HOST_SYSTEM_PROCESSOR=${stdenv.buildPlatform.uname.processor}"
++ lib.optional (stdenv.buildPlatform.uname.release != null) "-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}";
} // lib.optionalAttrs (attrs.enableParallelBuilding or false) {
enableParallelChecking = attrs.enableParallelChecking or true;
} // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) {
NIX_HARDENING_ENABLE = enabledHardeningOptions;
} // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) {
# TODO: remove lib.unique once nix has a list canonicalization primitive
__sandboxProfile =
@@ -193,23 +262,14 @@ rec {
"/bin/sh"
];
__propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps;
} // lib.optionalAttrs (outputs' != [ "out" ]) {
outputs = outputs';
} // lib.optionalAttrs (attrs ? doCheck) {
# TODO(@Ericson2314): Make unconditional / resolve #33599
doCheck = doCheck && (stdenv.hostPlatform == stdenv.buildPlatform);
} // lib.optionalAttrs (attrs ? doInstallCheck) {
# TODO(@Ericson2314): Make unconditional / resolve #33599
doInstallCheck = doInstallCheck && (stdenv.hostPlatform == stdenv.buildPlatform);
});
};
validity = import ./check-meta.nix {
inherit lib config meta derivationArg;
mkDerivationArg = attrs;
inherit lib config meta;
# Nix itself uses the `system` field of a derivation to decide where
# to build it. This is a bit confusing for cross compilation.
inherit (stdenv) system;
};
inherit (stdenv) hostPlatform;
} 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
@@ -218,7 +278,7 @@ rec {
meta = {
# `name` above includes cross-compilation cruft (and is under assert),
# lets have a clean always accessible version here.
inherit name;
name = computedName;
# If the packager hasn't specified `outputsToInstall`, choose a default,
# which is the name of `p.bin or p.out or p`;
@@ -228,10 +288,9 @@ rec {
# unless they are comfortable with this default.
outputsToInstall =
let
outs = outputs'; # the value passed to derivation primitive
hasOutput = out: builtins.elem out outs;
in [( lib.findFirst hasOutput null (["bin" "out"] ++ outs) )]
++ lib.optional (hasOutput "man") "man";
hasOutput = out: builtins.elem out outputs;
in [( lib.findFirst hasOutput null (["bin" "out"] ++ outputs) )]
++ lib.optional (hasOutput "man") "man";
}
// attrs.meta or {}
# Fill `meta.position` to identify the source location of the package.

View File

@@ -211,7 +211,7 @@ isELF() {
exec {fd}< "$fn"
read -r -n 4 -u "$fd" magic
exec {fd}<&-
if [[ "$magic" =~ ELF ]]; then return 0; else return 1; fi
if [ "$magic" = $'\177ELF' ]; then return 0; else return 1; fi
}
# Return success if the specified file is a script (i.e. starts with
@@ -220,7 +220,6 @@ isScript() {
local fn="$1"
local fd
local magic
if ! [ -x /bin/sh ]; then return 0; fi
exec {fd}< "$fn"
read -r -n 2 -u "$fd" magic
exec {fd}<&-
@@ -258,9 +257,17 @@ shopt -s nullglob
# Set up the initial path.
PATH=
HOST_PATH=
for i in $initialPath; do
if [ "$i" = / ]; then i=; fi
addToSearchPath PATH "$i/bin"
# For backward compatibility, we add initial path to HOST_PATH so
# it can be used in auto patch-shebangs. Unfortunately this will
# not work with cross compilation.
if [ -z "${strictDeps-}" ]; then
addToSearchPath HOST_PATH "$i/bin"
fi
done
if (( "${NIX_DEBUG:-0}" >= 1 )); then
@@ -274,11 +281,6 @@ BASH="$SHELL"
export CONFIG_SHELL="$SHELL"
# Dummy implementation of the paxmark function. On Linux, this is
# overwritten by paxctl's setup hook.
paxmark() { true; }
# Execute the pre-hook.
if [ -z "${shell:-}" ]; then export shell="$SHELL"; fi
runHook preHook
@@ -501,10 +503,14 @@ activatePackage() {
# the transition, we do include everything in thatcase.
#
# TODO(@Ericson2314): Don't special-case native compilation
if [[ ( -z "${crossConfig-}" || "$hostOffset" -le -1 ) && -d "$pkg/bin" ]]; then
if [[ ( -z "${strictDeps-}" || "$hostOffset" -le -1 ) && -d "$pkg/bin" ]]; then
addToSearchPath _PATH "$pkg/bin"
fi
if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then
addToSearchPath HOST_PATH "$pkg/bin"
fi
if [[ -f "$pkg/nix-support/setup-hook" ]]; then
local oldOpts="$(shopt -po nounset)"
set +u
@@ -551,7 +557,7 @@ _addToEnv() {
for depTargetOffset in "${allPlatOffsets[@]}"; do
(( "$depHostOffset" <= "$depTargetOffset" )) || continue
local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]"
if [[ -z "${crossConfig-}" ]]; then
if [[ -z "${strictDeps-}" ]]; then
# Apply environment hooks to all packages during native
# compilation to ease the transition.
#
@@ -641,29 +647,25 @@ fi
# Textual substitution functions.
substitute() {
local input="$1"
local output="$2"
substituteStream() {
local var=$1
local description=$2
shift 2
if [ ! -f "$input" ]; then
echo "substitute(): ERROR: file '$input' does not exist" >&2
return 1
fi
local content
# read returns non-0 on EOF, so we want read to fail
if IFS='' read -r -N 0 content < "$input"; then
echo "substitute(): ERROR: File \"$input\" has null bytes, won't process" >&2
return 1
fi
while (( "$#" )); do
case "$1" in
--replace)
pattern="$2"
replacement="$3"
shift 3
local savedvar
savedvar="${!var}"
eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'
if [ "$pattern" != "$replacement" ]; then
if [ "${!var}" == "$savedvar" ]; then
echo "substituteStream(): WARNING: pattern '$pattern' doesn't match anything in $description" >&2
fi
fi
;;
--subst-var)
@@ -671,32 +673,59 @@ substitute() {
shift 2
# check if the used nix attribute name is a valid bash name
if ! [[ "$varName" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then
echo "substitute(): ERROR: substitution variables must be valid Bash names, \"$varName\" isn't." >&2
echo "substituteStream(): ERROR: substitution variables must be valid Bash names, \"$varName\" isn't." >&2
return 1
fi
if [ -z ${!varName+x} ]; then
echo "substituteStream(): ERROR: variable \$$varName is unset" >&2
return 1
fi
pattern="@$varName@"
replacement="${!varName}"
eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'
;;
--subst-var-by)
pattern="@$2@"
replacement="$3"
eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'
shift 3
;;
*)
echo "substitute(): ERROR: Invalid command line argument: $1" >&2
echo "substituteStream(): ERROR: Invalid command line argument: $1" >&2
return 1
;;
esac
content="${content//"$pattern"/$replacement}"
done
if [ -e "$output" ]; then chmod +w "$output"; fi
printf "%s" "$content" > "$output"
printf "%s" "${!var}"
}
consumeEntire() {
# read returns non-0 on EOF, so we want read to fail
if IFS='' read -r -N 0 $1; then
echo "consumeEntire(): ERROR: Input null bytes, won't process" >&2
return 1
fi
}
substitute() {
local input="$1"
local output="$2"
shift 2
if [ ! -f "$input" ]; then
echo "substitute(): ERROR: file '$input' does not exist" >&2
return 1
fi
local content
consumeEntire content < "$input"
if [ -e "$output" ]; then chmod +w "$output"; fi
substituteStream content "file '$input'" "$@" > "$output"
}
substituteInPlace() {
local fileName="$1"
@@ -704,20 +733,30 @@ substituteInPlace() {
substitute "$fileName" "$fileName" "$@"
}
# Substitute all environment variables that start with a lowercase character and
# are valid Bash names.
substituteAll() {
local input="$1"
local output="$2"
local -a args=()
_allFlags() {
for varName in $(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }'); do
if (( "${NIX_DEBUG:-0}" >= 1 )); then
printf "@%s@ -> %q\n" "${varName}" "${!varName}"
fi
args+=("--subst-var" "$varName")
done
}
substituteAllStream() {
local -a args=()
_allFlags
substituteStream "$1" "$2" "${args[@]}"
}
# Substitute all environment variables that start with a lowercase character and
# are valid Bash names.
substituteAll() {
local input="$1"
local output="$2"
local -a args=()
_allFlags
substitute "$input" "$output" "${args[@]}"
}
@@ -774,11 +813,11 @@ _defaultUnpack() {
else
case "$fn" in
*.tar.xz | *.tar.lzma)
*.tar.xz | *.tar.lzma | *.txz)
# Don't rely on tar knowing about .xz.
xz -d < "$fn" | tar xf -
;;
*.tar | *.tar.* | *.tgz | *.tbz2)
*.tar | *.tar.* | *.tgz | *.tbz2 | *.tbz)
# GNU tar can automatically select the decompression method
# (info "(tar) gzip").
tar xf "$fn"
@@ -968,9 +1007,11 @@ buildPhase() {
# set to empty if unset
: ${makeFlags=}
if [[ -z "$makeFlags" && ! ( -n "${makefile:-}" || -e Makefile || -e makefile || -e GNUmakefile ) ]]; then
if [[ -z "$makeFlags" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then
echo "no Makefile, doing nothing"
else
foundMakefile=1
# See https://github.com/NixOS/nixpkgs/pull/1354#issuecomment-31260409
makeFlags="SHELL=$SHELL $makeFlags"
@@ -994,18 +1035,38 @@ buildPhase() {
checkPhase() {
runHook preCheck
# Old bash empty array hack
# shellcheck disable=SC2086
local flagsArray=(
${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"}
${checkTarget:-check}
)
if [[ -z "${foundMakefile:-}" ]]; then
echo "no Makefile or custom buildPhase, doing nothing"
runHook postCheck
return
fi
echoCmd 'check flags' "${flagsArray[@]}"
make ${makefile:+-f $makefile} "${flagsArray[@]}"
unset flagsArray
if [[ -z "${checkTarget:-}" ]]; then
#TODO(@oxij): should flagsArray influence make -n?
if make -n ${makefile:+-f $makefile} check >/dev/null 2>&1; then
checkTarget=check
elif make -n ${makefile:+-f $makefile} test >/dev/null 2>&1; then
checkTarget=test
fi
fi
if [[ -z "${checkTarget:-}" ]]; then
echo "no check/test target in ${makefile:-Makefile}, doing nothing"
else
# Old bash empty array hack
# shellcheck disable=SC2086
local flagsArray=(
${enableParallelChecking:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"}
${checkTarget}
)
echoCmd 'check flags' "${flagsArray[@]}"
make ${makefile:+-f $makefile} "${flagsArray[@]}"
unset flagsArray
fi
runHook postCheck
}
@@ -1018,14 +1079,12 @@ installPhase() {
mkdir -p "$prefix"
fi
installTargets="${installTargets:-install}"
# Old bash empty array hack
# shellcheck disable=SC2086
local flagsArray=(
$installTargets
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
$installFlags ${installFlagsArray+"${installFlagsArray[@]}"}
${installTargets:-install}
)
echoCmd 'install flags' "${flagsArray[@]}"
@@ -1091,6 +1150,19 @@ fixupPhase() {
substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook"
fi
# TODO(@Ericson2314): Remove after https://github.com/NixOS/nixpkgs/pull/31414
if [ -n "${setupHooks:-}" ]; then
mkdir -p "${!outputDev}/nix-support"
local hook
for hook in $setupHooks; do
local content
consumeEntire content < "$hook"
substituteAllStream content "file '$hook'" >> "${!outputDev}/nix-support/setup-hook"
unset -v content
done
unset -v hook
fi
# Propagate user-env packages into the output with binaries, TODO?
if [ -n "${propagatedUserEnvPkgs:-}" ]; then
@@ -1106,18 +1178,26 @@ fixupPhase() {
installCheckPhase() {
runHook preInstallCheck
# Old bash empty array hack
# shellcheck disable=SC2086
local flagsArray=(
${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
$installCheckFlags ${installCheckFlagsArray+"${installCheckFlagsArray[@]}"}
${installCheckTarget:-installcheck}
)
if [[ -z "${foundMakefile:-}" ]]; then
echo "no Makefile or custom buildPhase, doing nothing"
#TODO(@oxij): should flagsArray influence make -n?
elif [[ -z "${installCheckTarget:-}" ]] \
&& ! make -n ${makefile:+-f $makefile} ${installCheckTarget:-installcheck} >/dev/null 2>&1; then
echo "no installcheck target in ${makefile:-Makefile}, doing nothing"
else
# Old bash empty array hack
# shellcheck disable=SC2086
local flagsArray=(
${enableParallelChecking:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
$installCheckFlags ${installCheckFlagsArray+"${installCheckFlagsArray[@]}"}
${installCheckTarget:-installcheck}
)
echoCmd 'installcheck flags' "${flagsArray[@]}"
make ${makefile:+-f $makefile} "${flagsArray[@]}"
unset flagsArray
echoCmd 'installcheck flags' "${flagsArray[@]}"
make ${makefile:+-f $makefile} "${flagsArray[@]}"
unset flagsArray
fi
runHook postInstallCheck
}

View File

@@ -1,11 +1,11 @@
{
busybox = import <nix/fetchurl.nix> {
url = https://wdtz.org/files/030q34q7fk6jdfxkgcqp5rzr4yhw3pgx-stdenv-bootstrap-tools-x86_64-unknown-linux-musl/on-server/busybox;
sha256 = "16lzrwwvdk6q3g08gs45pldz0rh6xpln2343xr444960h6wqxl5v";
url = https://wdtz.org/files/gywxhjgl70sxippa0pxs0vj5qcgz1wi8-stdenv-bootstrap-tools/on-server/busybox;
sha256 = "0779c2wn00467h76xpqil678gfi1y2p57c7zq2d917jsv2qj5009";
executable = true;
};
bootstrapTools = import <nix/fetchurl.nix> {
url = https://wdtz.org/files/030q34q7fk6jdfxkgcqp5rzr4yhw3pgx-stdenv-bootstrap-tools-x86_64-unknown-linux-musl/on-server/bootstrap-tools.tar.xz;
sha256 = "0ly0wj8wzbikn2j8sn727vikk90bq36drh98qvfx1kkh5k5azm2j";
url = https://wdtz.org/files/gywxhjgl70sxippa0pxs0vj5qcgz1wi8-stdenv-bootstrap-tools/on-server/bootstrap-tools.tar.xz;
sha256 = "1dwiqw4xvnm0b5fdgl89lz2qq45f6s9icwxn6n6ams71xw0dbqyi";
};
}

View File

@@ -26,7 +26,7 @@ for i in $out/bin/* $out/libexec/gcc/*/*/*; do
./patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i"
done
for i in $out/lib/libiconv*.so $out/lib/libpcre* $out/lib/libc.so; do
for i in $out/lib/libpcre* $out/lib/libc.so; do
if [ -L "$i" ]; then continue; fi
echo patching "$i"
$out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"

View File

@@ -9,6 +9,9 @@ echo Patching the bootstrap tools...
if test -f $out/lib/ld.so.?; then
# MIPS case
LD_BINARY=$out/lib/ld.so.?
elif test -f $out/lib/ld64.so.?; then
# ppc64(le)
LD_BINARY=$out/lib/ld64.so.?
else
# i686, x86_64 and armv5tel
LD_BINARY=$out/lib/ld-*so.?

View File

@@ -4,7 +4,7 @@
# compiler and linker that do not search in default locations,
# ensuring purity of components produced by it.
{ lib
, localSystem, crossSystem, config, overlays
, localSystem, crossSystem, config, overlays, crossOverlays ? []
, bootstrapFiles ?
let table = {
@@ -15,12 +15,14 @@
"armv6l-linux" = import ./bootstrap-files/armv6l.nix;
"armv7l-linux" = import ./bootstrap-files/armv7l.nix;
"aarch64-linux" = import ./bootstrap-files/aarch64.nix;
"mips64el-linux" = import ./bootstrap-files/loongson2f.nix;
"mipsel-linux" = import ./bootstrap-files/loongson2f.nix;
"powerpc64le-linux" = import ./bootstrap-files/ppc64le.nix;
};
"musl" = {
"aarch64-linux" = import ./bootstrap-files/aarch64-musl.nix;
"armv6l-linux" = import ./bootstrap-files/armv6l-musl.nix;
"x86_64-linux" = import ./bootstrap-files/x86_64-musl.nix;
"powerpc64le-linux" = import ./bootstrap-files/ppc64le-musl.nix;
};
};
archLookupTable = table.${localSystem.libc}
@@ -30,7 +32,7 @@
in files
}:
assert crossSystem == null;
assert crossSystem == localSystem;
let
inherit (localSystem) system platform;
@@ -40,7 +42,7 @@ let
export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""}
${if system == "mips64el-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""}
${if system == "mipsel-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""}
'';
@@ -66,7 +68,7 @@ let
let
thisStdenv = import ../generic {
name = "stdenv-linux-boot";
name = "${name}-stdenv-linux";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
@@ -88,6 +90,7 @@ let
cc = if isNull prevStage.gcc-unwrapped
then null
else lib.makeOverridable (import ../../build-support/cc-wrapper) {
name = "${name}-gcc-wrapper";
nativeTools = false;
nativeLibc = false;
buildPackages = lib.optionalAttrs (prevStage ? stdenv) {
@@ -98,7 +101,6 @@ let
isGNU = true;
libc = getLibc prevStage;
inherit (prevStage) coreutils gnugrep;
name = name;
stdenvNoCC = prevStage.ccWrapperStdenv;
};
@@ -106,11 +108,6 @@ let
# Having the proper 'platform' in all the stdenvs allows getting proper
# linuxHeaders for example.
inherit platform;
# stdenv.glibc is used by GCC build to figure out the system-level
# /usr/include directory.
# TODO: Remove this!
inherit (prevStage) glibc;
};
overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; };
};
@@ -128,8 +125,6 @@ in
__raw = true;
gcc-unwrapped = null;
glibc = assert false; null;
musl = assert false; null;
binutils = null;
coreutils = null;
gnugrep = null;
@@ -138,7 +133,7 @@ in
# Build a dummy stdenv with no GCC or working fetchurl. This is
# because we need a stdenv to build the GCC wrapper and fetchurl.
(prevStage: stageFun prevStage {
name = null;
name = "bootstrap-stage0";
overrides = self: super: {
# We thread stage0's stdenv through under this name so downstream stages
@@ -152,7 +147,7 @@ in
# create a dummy Glibc here, which will be used in the stdenv of
# stage1.
${localSystem.libc} = self.stdenv.mkDerivation {
name = "bootstrap-${localSystem.libc}";
name = "bootstrap-stage0-${localSystem.libc}";
buildCommand = ''
mkdir -p $out
ln -s ${bootstrapTools}/lib $out/lib
@@ -164,13 +159,13 @@ in
};
gcc-unwrapped = bootstrapTools;
binutils = import ../../build-support/bintools-wrapper {
name = "bootstrap-stage0-binutils-wrapper";
nativeTools = false;
nativeLibc = false;
buildPackages = { };
libc = getLibc self;
inherit (self) stdenvNoCC coreutils gnugrep;
bintools = bootstrapTools;
name = "bootstrap-binutils-wrapper";
};
coreutils = bootstrapTools;
gnugrep = bootstrapTools;
@@ -189,11 +184,13 @@ in
# simply re-export those packages in the middle stage(s) using the
# overrides attribute and the inherit syntax.
(prevStage: stageFun prevStage {
name = "bootstrap-gcc-wrapper";
name = "bootstrap-stage1";
# Rebuild binutils to use from stage2 onwards.
overrides = self: super: {
binutils = super.binutils_nogold;
binutils-unwrapped = super.binutils-unwrapped.override {
gold = false;
};
inherit (prevStage)
ccWrapperStdenv
gcc-unwrapped coreutils gnugrep;
@@ -213,13 +210,13 @@ in
# 2nd stdenv that contains our own rebuilt binutils and is used for
# compiling our own Glibc.
(prevStage: stageFun prevStage {
name = "bootstrap-gcc-wrapper";
name = "bootstrap-stage2";
overrides = self: super: {
inherit (prevStage)
ccWrapperStdenv
gcc-unwrapped coreutils gnugrep
perl paxctl gnum4 bison;
perl gnum4 bison;
# This also contains the full, dynamically linked, final Glibc.
binutils = prevStage.binutils.override {
# Rewrap the binutils with the new glibc, so both the next
@@ -234,7 +231,7 @@ in
# one uses the rebuilt Glibc from stage2. It still uses the recent
# binutils and rest of the bootstrap tools, including GCC.
(prevStage: stageFun prevStage {
name = "bootstrap-gcc-wrapper";
name = "bootstrap-stage3";
overrides = self: super: rec {
inherit (prevStage)
@@ -253,23 +250,24 @@ in
isl = isl_0_17;
};
};
extraNativeBuildInputs = [ prevStage.patchelf prevStage.paxctl ] ++
extraNativeBuildInputs = [ prevStage.patchelf ] ++
# Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
lib.optional localSystem.isAarch64 prevStage.updateAutotoolsGnuConfigScriptsHook;
lib.optional (!localSystem.isx86 || localSystem.libc == "musl")
prevStage.updateAutotoolsGnuConfigScriptsHook;
})
# Construct a fourth stdenv that uses the new GCC. But coreutils is
# still from the bootstrap tools.
(prevStage: stageFun prevStage {
name = "";
name = "bootstrap-stage4";
overrides = self: super: {
# Zlib has to be inherited and not rebuilt in this stage,
# because gcc (since JAR support) already depends on zlib, and
# then if we already have a zlib we want to use that for the
# other purposes (binutils and top-level pkgs) too.
inherit (prevStage) gettext gnum4 bison gmp perl zlib linuxHeaders;
inherit (prevStage) gettext gnum4 bison gmp perl texinfo zlib linuxHeaders;
${localSystem.libc} = getLibc prevStage;
binutils = super.binutils.override {
# Don't use stdenv's shell but our own
@@ -291,13 +289,13 @@ in
bintools = self.binutils;
libc = getLibc self;
inherit (self) stdenvNoCC coreutils gnugrep;
name = "";
shell = self.bash + "/bin/bash";
};
};
extraNativeBuildInputs = [ prevStage.patchelf prevStage.xz ] ++
# Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
lib.optional localSystem.isAarch64 prevStage.updateAutotoolsGnuConfigScriptsHook;
lib.optional (!localSystem.isx86 || localSystem.libc == "musl")
prevStage.updateAutotoolsGnuConfigScriptsHook;
})
# Construct the final stdenv. It uses the Glibc and GCC, and adds
@@ -310,6 +308,8 @@ in
(prevStage: {
inherit config overlays;
stdenv = import ../generic rec {
name = "stdenv-linux";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
@@ -325,9 +325,10 @@ in
initialPath =
((import ../common-path.nix) {pkgs = prevStage;});
extraNativeBuildInputs = [ prevStage.patchelf prevStage.paxctl ] ++
extraNativeBuildInputs = [ prevStage.patchelf ] ++
# Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
lib.optional localSystem.isAarch64 prevStage.updateAutotoolsGnuConfigScriptsHook;
lib.optional (!localSystem.isx86 || localSystem.libc == "musl")
prevStage.updateAutotoolsGnuConfigScriptsHook;
cc = prevStage.gcc;
@@ -346,9 +347,9 @@ in
# Mainly avoid reference to bootstrap tools
allowedRequisites = with prevStage; with lib;
# Simple executable tools
concatMap (p: [ (getBin p) (getLib p) ])
[ gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils
gawk gnumake gnused gnutar gnugrep gnupatch patchelf ed paxctl
concatMap (p: [ (getBin p) (getLib p) ]) [
gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils
gawk gnumake gnused gnutar gnugrep gnupatch patchelf ed
]
# Library dependencies
++ map getLib (
@@ -360,19 +361,18 @@ in
++ [ /*propagated from .dev*/ linuxHeaders
binutils gcc gcc.cc gcc.cc.lib gcc.expand-response-params
]
++ lib.optional (localSystem.libc == "musl") libiconv
++ lib.optionals localSystem.isAarch64
++ lib.optionals (!localSystem.isx86 || localSystem.libc == "musl")
[ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ];
overrides = self: super: {
inherit (prevStage)
gzip bzip2 xz bash coreutils diffutils findutils gawk
gnumake gnused gnutar gnugrep gnupatch patchelf
attr acl paxctl zlib pcre;
attr acl zlib pcre;
${localSystem.libc} = getLibc prevStage;
} // lib.optionalAttrs (super.targetPlatform == localSystem) {
} // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
# Need to get rid of these when cross-compiling.
inherit (prevStage) binutils binutils-raw;
inherit (prevStage) binutils binutils-unwrapped;
gcc = cc;
};
};

View File

@@ -5,17 +5,18 @@ let
localSystem = { inherit system; };
inherit crossSystem;
};
in with (import ../../../lib).systems.examples; {
armv5tel = make sheevaplug;
scaleway = make scaleway-c1;
pogoplug4 = make pogoplug4;
armv6l = make raspberryPi;
armv7l = make armv7l-hf-multiplatform;
aarch64 = make aarch64-multiplatform;
x86_64-musl = make musl64;
i686-musl = make musl32;
armv6l-musl = make muslpi;
aarch64-musl = make aarch64-multiplatform-musl;
riscv64 = make riscv64;
}
lib = import ../../../lib;
in lib.mapAttrs (n: make) (with lib.systems.examples; {
armv5tel = sheevaplug;
scaleway = scaleway-c1;
pogoplug4 = pogoplug4;
armv6l = raspberryPi;
armv7l = armv7l-hf-multiplatform;
aarch64 = aarch64-multiplatform;
x86_64-musl = musl64;
armv6l-musl = muslpi;
aarch64-musl = aarch64-multiplatform-musl;
riscv64 = riscv64;
powerpc64le = powernv;
powerpc64le-musl = musl-power;
})

View File

@@ -19,7 +19,7 @@ in with pkgs; rec {
tarMinimal = gnutar.override { acl = null; };
busyboxMinimal = busybox.override {
useMusl = !targetPlatform.isRiscV;
useMusl = !stdenv.targetPlatform.isRiscV;
enableStatic = true;
enableMinimal = true;
extraConfig = ''
@@ -44,7 +44,7 @@ in with pkgs; rec {
set -x
mkdir -p $out/bin $out/lib $out/libexec
'' + (if (hostPlatform.libc == "glibc") then ''
'' + (if (stdenv.hostPlatform.libc == "glibc") then ''
# Copy what we need of Glibc.
cp -d ${libc.out}/lib/ld*.so* $out/lib
cp -d ${libc.out}/lib/libc*.so* $out/lib
@@ -75,7 +75,7 @@ in with pkgs; rec {
find $out/include -name .install -exec rm {} \;
find $out/include -name ..install.cmd -exec rm {} \;
mv $out/include $out/include-glibc
'' else if (hostPlatform.libc == "musl") then ''
'' else if (stdenv.hostPlatform.libc == "musl") then ''
# Copy what we need from musl
cp ${libc.out}/lib/* $out/lib
cp -rL ${libc.dev}/include $out
@@ -88,7 +88,7 @@ in with pkgs; rec {
'' else throw "unsupported libc for bootstrap tools")
+ ''
# Copy coreutils, bash, etc.
cp ${coreutilsMinimal.out}/bin/* $out/bin
cp -d ${coreutilsMinimal.out}/bin/* $out/bin
(cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users)
cp ${bash.out}/bin/bash $out/bin
@@ -112,8 +112,8 @@ in with pkgs; rec {
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 -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
chmod -R u+w $out/lib
rm -f $out/lib/gcc/*/*/include*/linux
@@ -136,10 +136,8 @@ in with pkgs; rec {
cp -d ${libmpc.out}/lib/libmpc*.so* $out/lib
cp -d ${zlib.out}/lib/libz.so* $out/lib
cp -d ${libelf}/lib/libelf.so* $out/lib
'' + lib.optionalString (hostPlatform.libc == "musl") ''
cp -d ${libiconv.out}/lib/libiconv*.so* $out/lib
'' + lib.optionalString (hostPlatform != buildPlatform) ''
'' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
# These needed for cross but not native tools because the stdenv
# GCC has certain things built in statically. See
# pkgs/stdenv/linux/default.nix for the details.
@@ -152,6 +150,7 @@ in with pkgs; rec {
for i in as ld ar ranlib nm strip readelf objdump; do
cp ${binutils.bintools.out}/bin/$i $out/bin
done
cp '${lib.getLib binutils.bintools}'/lib/* "$out/lib/"
chmod -R u+w $out
@@ -201,21 +200,21 @@ in with pkgs; rec {
bootstrapTools = runCommand "bootstrap-tools.tar.xz" {} "cp ${build}/on-server/bootstrap-tools.tar.xz $out";
};
bootstrapTools = if (hostPlatform.libc == "glibc") then
bootstrapTools = if (stdenv.hostPlatform.libc == "glibc") then
import ./bootstrap-tools {
inherit (hostPlatform) system;
inherit (stdenv.buildPlatform) system; # Used to determine where to build
inherit bootstrapFiles;
}
else if (hostPlatform.libc == "musl") then
else if (stdenv.hostPlatform.libc == "musl") then
import ./bootstrap-tools-musl {
inherit (hostPlatform) system;
inherit (stdenv.buildPlatform) system; # Used to determine where to build
inherit bootstrapFiles;
}
else throw "unsupported libc";
test = derivation {
name = "test-bootstrap-tools";
inherit (hostPlatform) system;
inherit (stdenv.hostPlatform) system; # We cannot "cross test"
builder = bootstrapFiles.busybox;
args = [ "ash" "-e" "-c" "eval \"$buildCommand\"" ];
@@ -234,12 +233,12 @@ in with pkgs; rec {
grep --version
gcc --version
'' + lib.optionalString (hostPlatform.libc == "glibc") ''
'' + lib.optionalString (stdenv.hostPlatform.libc == "glibc") ''
ldlinux=$(echo ${bootstrapTools}/lib/ld-linux*.so.?)
export CPP="cpp -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools}"
export CC="gcc -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
export CXX="g++ -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
'' + lib.optionalString (hostPlatform.libc == "musl") ''
'' + lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
ldmusl=$(echo ${bootstrapTools}/lib/ld-musl*.so.?)
export CPP="cpp -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools}"
export CC="gcc -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools} -Wl,-dynamic-linker,$ldmusl -Wl,-rpath,${bootstrapTools}/lib"

View File

@@ -1,11 +1,11 @@
{ lib
, localSystem, crossSystem, config, overlays
, localSystem, crossSystem, config, overlays, crossOverlays ? []
}:
assert crossSystem == null;
assert crossSystem == localSystem;
let
inherit (localSystem) system platform;
inherit (localSystem) system;
shell =
if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash"
@@ -119,14 +119,23 @@ in
};
stdenvNoCC = stdenv;
cc = import ../../build-support/cc-wrapper {
name = "cc-native";
nativeTools = true;
nativeLibc = true;
cc = let
nativePrefix = { # switch
"i686-solaris" = "/usr/gnu";
"x86_64-solaris" = "/opt/local/gcc47";
}.${system} or "/usr";
in
import ../../build-support/cc-wrapper {
name = "cc-native";
nativeTools = true;
nativeLibc = true;
inherit nativePrefix;
bintools = import ../../build-support/bintools-wrapper {
name = "bintools";
inherit stdenvNoCC nativePrefix;
nativeTools = true;
nativeLibc = true;
};
inherit stdenvNoCC;
};

View File

@@ -1,10 +1,10 @@
{ lib
, crossSystem, config, overlays
, crossSystem, localSystem, config, overlays
, bootStages
, ...
}:
assert crossSystem == null;
assert crossSystem == localSystem;
bootStages ++ [
(prevStage: {