Clean up cross bootstrapping

For a long time, we've had `crossLibcStdenv`, `*Cross` libc attributes,
and `*bsdCross` pre-libc package sets. This was always bad because
having "cross" things is "not declarative": the naming doesn't reflect
what packages *need* but rather how we *provide* something. This is
ugly, and creates needless friction between cross and native building.

Now, almost all of these `*Cross` attributes are gone: just these are
kept:

- Glibc's and Musl's are kept, because those packages are widely used
  and I didn't want to risk changing the native builds of those at this
  time.

- generic `libcCross`, `theadsCross`, and friends, because these relate
  to the convolulted GCC bootstrap which still needs to be redone.

The BSD and obscure Linux or freestnanding libcs have conversely all
been made to use a new `stdenvNoLibc`, which is like the old
`crossLibcStdenv` except:

1. It usable for native and cross alike

2. It named according to what it *is* ("a standard environment without
   libc but with a C compiler"), rather than some non-compositional
   jargon ("the stdenv used for building libc when cross compiling",
   yuck).

I should have done this change long ago, but I was stymied because of
"infinite recursions". The problem was that in too many cases we are
overriding `stdenv` to *remove* things we don't need, and this risks
cyles since those more minimal stdenvs are used to build things in the
more maximal stdenvs.

The solution is to pass `stage.nix` `stdenvNoCC`, so we can override to
*build up* rather than *tear down*. For now, the full `stdenv` is also
passed, so I don't need to change the native bootstraps, but I can see
this changing as we make things more uniform and clean those up.

Finally, the BSDs also had to be cleaned up, since they have a few
pre-libc dependencies, demanding a systematic approach. I realized what
rhelmot did in 61202561d9 (specify what
packages just need `stdenvNoLibc`) is definitely the right approach for
this, and adjusted NetBSD and OpenBSD to likewise use it.
This commit is contained in:
John Ericson 2024-06-18 12:38:21 -04:00
parent 4bd76beac0
commit 51f1ecaa59
25 changed files with 177 additions and 171 deletions

View file

@ -10,15 +10,15 @@
, stdenvNoCC , stdenvNoCC
, runtimeShell , runtimeShell
, bintools ? null, libc ? null, coreutils ? null, gnugrep ? null , bintools ? null, libc ? null, coreutils ? null, gnugrep ? null
, netbsd ? null, netbsdCross ? null , netbsd ? null
, sharedLibraryLoader ? , sharedLibraryLoader ?
if libc == null then if libc == null then
null null
else if stdenvNoCC.targetPlatform.isNetBSD then else if stdenvNoCC.targetPlatform.isNetBSD then
if !(targetPackages ? netbsdCross) then if !(targetPackages ? netbsd) then
netbsd.ld_elf_so netbsd.ld_elf_so
else if libc != targetPackages.netbsdCross.headers then else if libc != targetPackages.netbsd.headers then
targetPackages.netbsdCross.ld_elf_so targetPackages.netbsd.ld_elf_so
else else
null null
else else

View file

@ -1,5 +1,5 @@
{ lib { lib
, stdenv , stdenvNoLibc
, buildPackages , buildPackages
, fetchurl , fetchurl
, gitUpdater , gitUpdater
@ -9,6 +9,7 @@
}: }:
let let
stdenv = stdenvNoLibc;
isCross = (stdenv.buildPlatform != stdenv.hostPlatform); isCross = (stdenv.buildPlatform != stdenv.hostPlatform);
configParser = '' configParser = ''
function parseconfig { function parseconfig {

View file

@ -1,6 +1,6 @@
{ stdenv, texinfo, flex, bison, fetchFromGitHub, crossLibcStdenv, buildPackages }: { stdenv, texinfo, flex, bison, fetchFromGitHub, stdenvNoLibc, buildPackages }:
crossLibcStdenv.mkDerivation { stdenvNoLibc.mkDerivation {
name = "newlib"; name = "newlib";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "openrisc"; owner = "openrisc";

View file

@ -1,6 +1,6 @@
{ stdenv, texinfo, flex, bison, fetchFromGitHub, crossLibcStdenv, buildPackages }: { stdenv, texinfo, flex, bison, fetchFromGitHub, stdenvNoLibc, buildPackages }:
crossLibcStdenv.mkDerivation { stdenvNoLibc.mkDerivation {
name = "newlib"; name = "newlib";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "itszor"; owner = "itszor";

View file

@ -3,7 +3,6 @@
makeScopeWithSplicing', makeScopeWithSplicing',
generateSplicesForMkScope, generateSplicesForMkScope,
callPackage, callPackage,
crossLibcStdenv,
attributePathToSplice ? [ "freebsd" ], attributePathToSplice ? [ "freebsd" ],
branch ? "release/14.0.0", branch ? "release/14.0.0",
}: }:
@ -24,41 +23,30 @@ let
Branches can be selected by overriding the `branch` attribute on the freebsd package set. Branches can be selected by overriding the `branch` attribute on the freebsd package set.
''; '';
# `./package-set.nix` should never know the name of the package set we # we do not include the branch in the splice here because the branch
# are constructing; just this function is allowed to know that. This # parameter to this file will only ever take on one value - more values
# is why we: # are provided through overrides.
# otherSplices = generateSplicesForMkScope attributePathToSplice;
# - do the splicing for cross compilation here
#
# - construct the *anonymized* `buildFreebsd` attribute to be passed
# to `./package-set.nix`.
callFreeBSDWithAttrs =
extraArgs:
let
# we do not include the branch in the splice here because the branch
# parameter to this file will only ever take on one value - more values
# are provided through overrides.
otherSplices = generateSplicesForMkScope attributePathToSplice;
in
makeScopeWithSplicing' {
inherit otherSplices;
f =
self:
{
inherit branch;
}
// callPackage ./package-set.nix (
{
sourceData = versions.${self.branch} or (throw (badBranchError self.branch));
versionData = self.sourceData.version;
buildFreebsd = otherSplices.selfBuildHost;
patchesRoot = ./patches + "/${self.versionData.revision}";
}
// extraArgs
) self;
};
in in
{ # `./package-set.nix` should never know the name of the package set we
freebsd = callFreeBSDWithAttrs { }; # are constructing; just this function is allowed to know that. This
freebsdCross = callFreeBSDWithAttrs { stdenv = crossLibcStdenv; }; # is why we:
#
# - do the splicing for cross compilation here
#
# - construct the *anonymized* `buildFreebsd` attribute to be passed
# to `./package-set.nix`.
makeScopeWithSplicing' {
inherit otherSplices;
f =
self:
{
inherit branch;
}
// callPackage ./package-set.nix ({
sourceData = versions.${self.branch} or (throw (badBranchError self.branch));
versionData = self.sourceData.version;
buildFreebsd = otherSplices.selfBuildHost;
patchesRoot = ./patches + "/${self.versionData.revision}";
}) self;
} }

View file

@ -2,7 +2,7 @@
lib, lib,
stdenv, stdenv,
stdenvNoCC, stdenvNoCC,
stdenvNoLibs, stdenvNoLibc,
overrideCC, overrideCC,
buildPackages, buildPackages,
versionData, versionData,
@ -28,7 +28,7 @@ lib.makeOverridable (
if attrs.noCC or false then if attrs.noCC or false then
stdenvNoCC stdenvNoCC
else if attrs.noLibc or false then else if attrs.noLibc or false then
stdenvNoLibs stdenvNoLibc
else if attrs.noLibcxx or false then else if attrs.noLibcxx or false then
overrideCC stdenv buildPackages.llvmPackages.clangNoLibcxx overrideCC stdenv buildPackages.llvmPackages.clangNoLibcxx
else else
@ -58,12 +58,9 @@ lib.makeOverridable (
HOST_SH = stdenv'.shell; HOST_SH = stdenv'.shell;
# Since STRIP below is the flag
STRIPBIN = "${stdenv.cc.bintools.targetPrefix}strip";
makeFlags = [ makeFlags = [
"STRIP=-s" # flag to install, not command "STRIP=-s" # flag to install, not command
] ++ lib.optional (!stdenv.hostPlatform.isFreeBSD) "MK_WERROR=no"; ] ++ lib.optional (!stdenv'.hostPlatform.isFreeBSD) "MK_WERROR=no";
# amd64 not x86_64 for this on unlike NetBSD # amd64 not x86_64 for this on unlike NetBSD
MACHINE_ARCH = freebsd-lib.mkBsdArch stdenv'; MACHINE_ARCH = freebsd-lib.mkBsdArch stdenv';
@ -91,6 +88,9 @@ lib.makeOverridable (
// lib.optionalAttrs stdenv'.hasCC { // lib.optionalAttrs stdenv'.hasCC {
# TODO should CC wrapper set this? # TODO should CC wrapper set this?
CPP = "${stdenv'.cc.targetPrefix}cpp"; CPP = "${stdenv'.cc.targetPrefix}cpp";
# Since STRIP below is the flag
STRIPBIN = "${stdenv'.cc.bintools.targetPrefix}strip";
} }
// lib.optionalAttrs stdenv'.isDarwin { MKRELRO = "no"; } // lib.optionalAttrs stdenv'.isDarwin { MKRELRO = "no"; }
// lib.optionalAttrs (stdenv'.cc.isClang or false) { // lib.optionalAttrs (stdenv'.cc.isClang or false) {

View file

@ -1,5 +1,4 @@
{ {
stdenv,
lib, lib,
stdenvNoCC, stdenvNoCC,
makeScopeWithSplicing', makeScopeWithSplicing',
@ -21,7 +20,9 @@ makeScopeWithSplicing' {
defaultMakeFlags = [ defaultMakeFlags = [
"MKSOFTFLOAT=${ "MKSOFTFLOAT=${
if stdenv.hostPlatform.gcc.float or (stdenv.hostPlatform.parsed.abi.float or "hard") == "soft" then if
stdenvNoCC.hostPlatform.gcc.float or (stdenvNoCC.hostPlatform.parsed.abi.float or "hard") == "soft"
then
"yes" "yes"
else else
"no" "no"
@ -36,7 +37,6 @@ makeScopeWithSplicing' {
# because of the splices. # because of the splices.
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix { mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit stdenv stdenvNoCC;
inherit (buildPackages.netbsd) inherit (buildPackages.netbsd)
netbsdSetupHook netbsdSetupHook
makeMinimal makeMinimal
@ -129,7 +129,7 @@ makeScopeWithSplicing' {
libpthread-headers = self.callPackage ./pkgs/libpthread/headers.nix { }; libpthread-headers = self.callPackage ./pkgs/libpthread/headers.nix { };
csu = self.callPackage ./pkgs/csu.nix { csu = self.callPackage ./pkgs/csu.nix {
inherit (self) headers sys ld_elf_so; inherit (self) headers sys-headers ld_elf_so;
inherit (buildPackages.netbsd) inherit (buildPackages.netbsd)
netbsdSetupHook netbsdSetupHook
makeMinimal makeMinimal

View file

@ -16,11 +16,12 @@
statHook, statHook,
rsync, rsync,
headers, headers,
sys, sys-headers,
ld_elf_so, ld_elf_so,
}: }:
mkDerivation { mkDerivation {
noLibc = true;
path = "lib/csu"; path = "lib/csu";
meta.platforms = lib.platforms.netbsd; meta.platforms = lib.platforms.netbsd;
nativeBuildInputs = [ nativeBuildInputs = [
@ -41,7 +42,7 @@ mkDerivation {
]; ];
buildInputs = [ headers ]; buildInputs = [ headers ];
extraPaths = [ extraPaths = [
sys.path sys-headers.path
ld_elf_so.path ld_elf_so.path
]; ];
} }

View file

@ -15,6 +15,7 @@
}: }:
mkDerivation { mkDerivation {
noLibc = true;
path = "include"; path = "include";
nativeBuildInputs = [ nativeBuildInputs = [
bsdSetupHook bsdSetupHook

View file

@ -6,6 +6,7 @@
}: }:
mkDerivation { mkDerivation {
noLibc = true;
path = "libexec/ld.elf_so"; path = "libexec/ld.elf_so";
meta.platforms = lib.platforms.netbsd; meta.platforms = lib.platforms.netbsd;
LIBC_PIC = "${libc}/lib/libc_pic.a"; LIBC_PIC = "${libc}/lib/libc_pic.a";

View file

@ -24,6 +24,7 @@
}: }:
mkDerivation { mkDerivation {
noLibc = true;
path = "lib/libc"; path = "lib/libc";
USE_FORT = "yes"; USE_FORT = "yes";
MKPROFILE = "no"; MKPROFILE = "no";
@ -94,5 +95,8 @@ mkDerivation {
make -C $BSDSRCDIR/lib/libcrypt $makeFlags make -C $BSDSRCDIR/lib/libcrypt $makeFlags
make -C $BSDSRCDIR/lib/libcrypt $makeFlags install make -C $BSDSRCDIR/lib/libcrypt $makeFlags install
''; '';
inherit (librt) postPatch; postPatch = ''
sed -i 's,/usr\(/include/sys/syscall.h\),${headers}\1,g' \
$BSDSRCDIR/lib/{libc,librt}/sys/Makefile.inc
'';
} }

View file

@ -9,8 +9,5 @@ mkDerivation {
path = "lib/librt"; path = "lib/librt";
meta.platforms = lib.platforms.netbsd; meta.platforms = lib.platforms.netbsd;
extraPaths = [ libc.path ] ++ libc.extraPaths; extraPaths = [ libc.path ] ++ libc.extraPaths;
postPatch = '' inherit (libc) postPatch;
sed -i 's,/usr\(/include/sys/syscall.h\),${headers}\1,g' \
$BSDSRCDIR/lib/{libc,librt}/sys/Makefile.inc
'';
} }

View file

@ -2,7 +2,7 @@
lib, lib,
stdenv, stdenv,
stdenvNoCC, stdenvNoCC,
crossLibcStdenv, stdenvNoLibc,
runCommand, runCommand,
rsync, rsync,
source, source,
@ -23,7 +23,13 @@
lib.makeOverridable ( lib.makeOverridable (
attrs: attrs:
let let
stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv; stdenv' =
if attrs.noCC or false then
stdenvNoCC
else if attrs.noLibc or false then
stdenvNoLibc
else
stdenv;
in in
stdenv'.mkDerivation ( stdenv'.mkDerivation (
rec { rec {

View file

@ -1,16 +1,17 @@
{ {
stdenv,
lib, lib,
stdenvNoCC,
makeScopeWithSplicing', makeScopeWithSplicing',
generateSplicesForMkScope, generateSplicesForMkScope,
pkgs,
buildPackages, buildPackages,
netbsd,
}: }:
makeScopeWithSplicing' { let
otherSplices = generateSplicesForMkScope "openbsd"; otherSplices = generateSplicesForMkScope "openbsd";
buildOpenbsd = otherSplices.selfBuildHost;
in
makeScopeWithSplicing' {
inherit otherSplices;
f = ( f = (
self: self:
lib.packagesFromDirectoryRecursive { lib.packagesFromDirectoryRecursive {
@ -19,8 +20,8 @@ makeScopeWithSplicing' {
} }
// { // {
libc = self.callPackage ./pkgs/libc/package.nix { libc = self.callPackage ./pkgs/libc/package.nix {
inherit (self) csu include lorder; inherit (self) csu include;
inherit (buildPackages.openbsd) makeMinimal; inherit (buildOpenbsd) makeMinimal;
inherit (buildPackages.netbsd) inherit (buildPackages.netbsd)
install install
gencat gencat
@ -30,16 +31,16 @@ makeScopeWithSplicing' {
}; };
makeMinimal = buildPackages.netbsd.makeMinimal.override { inherit (self) make-rules; }; makeMinimal = buildPackages.netbsd.makeMinimal.override { inherit (self) make-rules; };
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix { mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit stdenv;
inherit (buildPackages.netbsd) install; inherit (buildPackages.netbsd) install;
inherit (buildPackages.buildPackages) rsync;
}; };
include = self.callPackage ./pkgs/include/package.nix { include = self.callPackage ./pkgs/include/package.nix {
inherit (buildPackages.openbsd) makeMinimal; inherit (buildOpenbsd) makeMinimal;
inherit (buildPackages.netbsd) install rpcgen mtree; inherit (buildPackages.netbsd) install rpcgen mtree;
}; };
csu = self.callPackage ./pkgs/csu.nix { csu = self.callPackage ./pkgs/csu.nix {
inherit (self) include; inherit (self) include;
inherit (buildPackages.openbsd) makeMinimal; inherit (buildOpenbsd) makeMinimal;
inherit (buildPackages.netbsd) install; inherit (buildPackages.netbsd) install;
}; };
make-rules = self.callPackage ./pkgs/make-rules/package.nix { }; make-rules = self.callPackage ./pkgs/make-rules/package.nix { };

View file

@ -9,6 +9,7 @@
}: }:
mkDerivation { mkDerivation {
noLibc = true;
path = "lib/csu"; path = "lib/csu";
nativeBuildInputs = [ nativeBuildInputs = [
bsdSetupHook bsdSetupHook

View file

@ -1,6 +1,6 @@
{ {
lib, lib,
stdenv, stdenvNoLibc,
mkDerivation, mkDerivation,
bsdSetupHook, bsdSetupHook,
openbsdSetupHook, openbsdSetupHook,
@ -10,7 +10,6 @@
byacc, byacc,
gencat, gencat,
rpcgen, rpcgen,
lorder,
csu, csu,
include, include,
ctags, ctags,
@ -19,7 +18,8 @@
fetchpatch, fetchpatch,
}: }:
mkDerivation rec { mkDerivation {
noLibc = true;
pname = "libc"; pname = "libc";
path = "lib/libc"; path = "lib/libc";
extraPaths = [ extraPaths = [
@ -53,7 +53,6 @@ mkDerivation rec {
gencat gencat
rpcgen rpcgen
ctags ctags
lorder
tsort tsort
]; ];
@ -69,7 +68,9 @@ mkDerivation rec {
# Suppress lld >= 16 undefined version errors # Suppress lld >= 16 undefined version errors
# https://github.com/freebsd/freebsd-src/commit/2ba84b4bcdd6012e8cfbf8a0d060a4438623a638 # https://github.com/freebsd/freebsd-src/commit/2ba84b4bcdd6012e8cfbf8a0d060a4438623a638
env.NIX_LDFLAGS = lib.optionalString (stdenv.hostPlatform.linker == "lld") "--undefined-version"; env.NIX_LDFLAGS = lib.optionalString (
stdenvNoLibc.hostPlatform.linker == "lld"
) "--undefined-version";
makeFlags = [ makeFlags = [
"STRIP=-s" # flag to install, not command "STRIP=-s" # flag to install, not command

View file

@ -8,6 +8,7 @@
}: }:
mkDerivation { mkDerivation {
noCC = true;
path = "usr.bin/lorder"; path = "usr.bin/lorder";
nativeBuildInputs = [ nativeBuildInputs = [
bsdSetupHook bsdSetupHook

View file

@ -2,7 +2,6 @@
fetchpatch, fetchpatch,
lib, lib,
mkDerivation, mkDerivation,
stdenv,
}: }:
mkDerivation { mkDerivation {

View file

@ -2,6 +2,7 @@
lib, lib,
stdenv, stdenv,
stdenvNoCC, stdenvNoCC,
stdenvNoLibc,
runCommand, runCommand,
rsync, rsync,
source, source,
@ -14,7 +15,13 @@
lib.makeOverridable ( lib.makeOverridable (
attrs: attrs:
let let
stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv; stdenv' =
if attrs.noCC or false then
stdenvNoCC
else if attrs.noLibc or false then
stdenvNoLibc
else
stdenv;
in in
stdenv'.mkDerivation ( stdenv'.mkDerivation (
rec { rec {
@ -43,9 +50,6 @@ lib.makeOverridable (
HOST_SH = stdenv'.shell; HOST_SH = stdenv'.shell;
# Since STRIP below is the flag
STRIPBIN = "${stdenv.cc.bintools.targetPrefix}strip";
makeFlags = [ makeFlags = [
"STRIP=-s" # flag to install, not command "STRIP=-s" # flag to install, not command
"-B" "-B"
@ -81,6 +85,9 @@ lib.makeOverridable (
// lib.optionalAttrs stdenv'.hasCC { // lib.optionalAttrs stdenv'.hasCC {
# TODO should CC wrapper set this? # TODO should CC wrapper set this?
CPP = "${stdenv'.cc.targetPrefix}cpp"; CPP = "${stdenv'.cc.targetPrefix}cpp";
# Since STRIP below is the flag
STRIPBIN = "${stdenv'.cc.bintools.targetPrefix}strip";
} }
// lib.optionalAttrs (attrs.headersOnly or false) { // lib.optionalAttrs (attrs.headersOnly or false) {
installPhase = "includesPhase"; installPhase = "includesPhase";

View file

@ -1,5 +1,5 @@
{ lib, stdenv, buildPackages { lib, stdenv, buildPackages
, newScope, overrideCC, crossLibcStdenv, libcCross , newScope, overrideCC, stdenvNoLibc, libcCross
}: }:
lib.makeScope newScope (self: with self; { lib.makeScope newScope (self: with self; {
@ -14,11 +14,11 @@ lib.makeScope newScope (self: with self; {
mingw_runtime = mingwrt; mingw_runtime = mingwrt;
mingw_w64 = callPackage ./mingw-w64 { mingw_w64 = callPackage ./mingw-w64 {
stdenv = crossLibcStdenv; stdenv = stdenvNoLibc;
}; };
# FIXME untested with llvmPackages_16 was using llvmPackages_8 # FIXME untested with llvmPackages_16 was using llvmPackages_8
crossThreadsStdenv = overrideCC crossLibcStdenv crossThreadsStdenv = overrideCC stdenvNoLibc
(if stdenv.hostPlatform.useLLVM or false (if stdenv.hostPlatform.useLLVM or false
then buildPackages.llvmPackages.clangNoLibcxx then buildPackages.llvmPackages.clangNoLibcxx
else buildPackages.gccWithoutTargetLibc.override (old: { else buildPackages.gccWithoutTargetLibc.override (old: {

View file

@ -32,7 +32,11 @@ rec {
# Override the compiler in stdenv for specific packages. # Override the compiler in stdenv for specific packages.
overrideCC = stdenv: cc: stdenv.override { allowedRequisites = null; cc = cc; }; overrideCC = stdenv: cc: stdenv.override {
allowedRequisites = null;
cc = cc;
hasCC = cc != null;
};
# Add some arbitrary packages to buildInputs for specific packages. # Add some arbitrary packages to buildInputs for specific packages.

View file

@ -41,25 +41,43 @@ in lib.init bootStages ++ [
if crossSystem.isStatic if crossSystem.isStatic
then buildPackages.stdenvAdapters.makeStatic then buildPackages.stdenvAdapters.makeStatic
else lib.id; else lib.id;
stdenvNoCC = adaptStdenv (buildPackages.stdenv.override (old: rec {
buildPlatform = localSystem;
hostPlatform = crossSystem;
targetPlatform = crossSystem;
# 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 = null;
hasCC = false;
extraNativeBuildInputs = old.extraNativeBuildInputs
++ lib.optionals
(hostPlatform.isLinux && !buildPlatform.isLinux)
[ buildPackages.patchelf ]
++ lib.optional
(let f = p: !p.isx86 || builtins.elem p.libc [ "musl" "wasilibc" "relibc" ] || p.isiOS || p.isGenode;
in f hostPlatform && !(f buildPlatform) )
buildPackages.updateAutotoolsGnuConfigScriptsHook
;
}));
in { in {
inherit config; inherit config;
overlays = overlays ++ crossOverlays; overlays = overlays ++ crossOverlays;
selfBuild = false; selfBuild = false;
inherit stdenvNoCC;
stdenv = let stdenv = let
baseStdenv = adaptStdenv (buildPackages.stdenv.override (old: rec { inherit (stdenvNoCC) hostPlatform targetPlatform;
buildPlatform = localSystem; baseStdenv = stdenvNoCC.override {
hostPlatform = crossSystem;
targetPlatform = crossSystem;
# 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 extraBuildInputs = [ ] # Old ones run on wrong platform
++ lib.optionals hostPlatform.isDarwin [ buildPackages.targetPackages.darwin.apple_sdk.frameworks.CoreFoundation ] ++ lib.optionals hostPlatform.isDarwin [ buildPackages.targetPackages.darwin.apple_sdk.frameworks.CoreFoundation ]
; ;
allowedRequisites = null;
hasCC = !targetPlatform.isGhcjs; hasCC = !stdenvNoCC.targetPlatform.isGhcjs;
cc = if crossSystem.useiOSPrebuilt or false cc = if crossSystem.useiOSPrebuilt or false
then buildPackages.darwin.iosSdkPkgs.clang then buildPackages.darwin.iosSdkPkgs.clang
@ -77,16 +95,7 @@ in lib.init bootStages ++ [
then buildPackages.llvmPackages.clang then buildPackages.llvmPackages.clang
else buildPackages.gcc; else buildPackages.gcc;
extraNativeBuildInputs = old.extraNativeBuildInputs };
++ lib.optionals
(hostPlatform.isLinux && !buildPlatform.isLinux)
[ buildPackages.patchelf ]
++ lib.optional
(let f = p: !p.isx86 || builtins.elem p.libc [ "musl" "wasilibc" "relibc" ] || p.isiOS || p.isGenode;
in f hostPlatform && !(f buildPlatform) )
buildPackages.updateAutotoolsGnuConfigScriptsHook
;
}));
in if config ? replaceCrossStdenv then config.replaceCrossStdenv { inherit buildPackages baseStdenv; } else baseStdenv; in if config ? replaceCrossStdenv then config.replaceCrossStdenv { inherit buildPackages baseStdenv; } else baseStdenv;
}) })

View file

@ -97,6 +97,7 @@ mapAliases ({
auditBlasHook = throw "'auditBlasHook' has been removed since it never worked"; # Added 2024-04-02 auditBlasHook = throw "'auditBlasHook' has been removed since it never worked"; # Added 2024-04-02
authy = throw "'authy' has been removed since it reached end of life"; # Added 2024-04-19 authy = throw "'authy' has been removed since it reached end of life"; # Added 2024-04-19
avldrums-lv2 = x42-avldrums; # Added 2020-03-29 avldrums-lv2 = x42-avldrums; # Added 2020-03-29
avrlibcCross = avrlibc; # Added 2024-06-18
awesome-4-0 = awesome; # Added 2022-05-05 awesome-4-0 = awesome; # Added 2022-05-05
aws-env = throw "aws-env has been removed as the upstream project was unmaintained"; # Added 2024-06-11 aws-env = throw "aws-env has been removed as the upstream project was unmaintained"; # Added 2024-06-11
@ -197,6 +198,7 @@ mapAliases ({
cope = throw "'cope' has been removed, as it is broken in nixpkgs since it was added, and fixing it is not trivial"; # Added 2024-04-12 cope = throw "'cope' has been removed, as it is broken in nixpkgs since it was added, and fixing it is not trivial"; # Added 2024-04-12
cpp-ipfs-api = cpp-ipfs-http-client; # Project has been renamed. Added 2022-05-15 cpp-ipfs-api = cpp-ipfs-http-client; # Project has been renamed. Added 2022-05-15
crispyDoom = crispy-doom; # Added 2023-05-01 crispyDoom = crispy-doom; # Added 2023-05-01
crossLibcStdenv = stdenvNoLibc; # Added 2024-06-18
cryptowatch-desktop = throw "Cryptowatch Desktop was sunset on September 30th 2023 and has been removed from nixpkgs"; # Added 2023-12-22 cryptowatch-desktop = throw "Cryptowatch Desktop was sunset on September 30th 2023 and has been removed from nixpkgs"; # Added 2023-12-22
clash = throw "'clash' has been removed, upstream gone. Consider using 'mihomo' instead."; # added 2023-11-10 clash = throw "'clash' has been removed, upstream gone. Consider using 'mihomo' instead."; # added 2023-11-10
clasp = clingo; # added 2022-12-22 clasp = clingo; # added 2022-12-22
@ -874,6 +876,7 @@ mapAliases ({
mpd_clientlib = libmpdclient; # Added 2021-02-11 mpd_clientlib = libmpdclient; # Added 2021-02-11
mpdevil = plattenalbum; # Added 2024-05-22 mpdevil = plattenalbum; # Added 2024-05-22
mpg321 = throw "'mpg321' has been removed due to it being unmaintained by upstream. Consider using mpg123 instead."; # Added 2024-05-10 mpg321 = throw "'mpg321' has been removed due to it being unmaintained by upstream. Consider using mpg123 instead."; # Added 2024-05-10
msp430NewlibCross = msp430Newlib; # Added 2024-06-18
mumble_git = throw "'mumble_git' has been renamed to/replaced by 'pkgs.mumble'"; # Converted to throw 2023-09-10 mumble_git = throw "'mumble_git' has been renamed to/replaced by 'pkgs.mumble'"; # Converted to throw 2023-09-10
murmur_git = throw "'murmur_git' has been renamed to/replaced by 'pkgs.murmur'"; # Converted to throw 2023-09-10 murmur_git = throw "'murmur_git' has been renamed to/replaced by 'pkgs.murmur'"; # Converted to throw 2023-09-10
mutt-with-sidebar = mutt; # Added 2022-09-17 mutt-with-sidebar = mutt; # Added 2022-09-17
@ -907,6 +910,8 @@ mapAliases ({
nagiosPluginsOfficial = monitoring-plugins; nagiosPluginsOfficial = monitoring-plugins;
neochat = libsForQt5.kdeGear.neochat; # added 2022-05-10 neochat = libsForQt5.kdeGear.neochat; # added 2022-05-10
neoload = throw "'neoload' has been removed as it is broken and unmaintained"; # Added 2024-03-02 neoload = throw "'neoload' has been removed as it is broken and unmaintained"; # Added 2024-03-02
newlibCross = newlib; # Added 2024-06-18
newlib-nanoCross = newlib-nano; # Added 2024-06-18
nitrokey-udev-rules = libnitrokey; # Added 2023-03-25 nitrokey-udev-rules = libnitrokey; # Added 2023-03-25
nix-direnv-flakes = nix-direnv; nix-direnv-flakes = nix-direnv;
nix-repl = throw ( nix-repl = throw (
@ -1333,6 +1338,8 @@ mapAliases ({
uade123 = uade; # Added 2022-07-30 uade123 = uade; # Added 2022-07-30
uberwriter = apostrophe; # Added 2020-04-23 uberwriter = apostrophe; # Added 2020-04-23
ubootBeagleboneBlack = ubootAmx335xEVM; # Added 2020-01-21 ubootBeagleboneBlack = ubootAmx335xEVM; # Added 2020-01-21
uclibc = uclibc-ng; # Added 2022-06-16
uclibcCross = uclibc-ng; # Added 2022-06-16
ue4 = throw "ue4 has been removed, because the package was broken for years"; # Added 2023-11-22 ue4 = throw "ue4 has been removed, because the package was broken for years"; # Added 2023-11-22
uhd3_5 = throw "uhd3_5 has been removed, because it was no longer needed"; # Added 2023-10-07 uhd3_5 = throw "uhd3_5 has been removed, because it was no longer needed"; # Added 2023-10-07
uhhyou.lv2 = throw "'uhhyou.lv2' has been removed, upstream gone"; # Added 2023-06-21 uhhyou.lv2 = throw "'uhhyou.lv2' has been removed, upstream gone"; # Added 2023-06-21
@ -1470,6 +1477,10 @@ mapAliases ({
inherit (stdenv.hostPlatform) system; # Added 2021-10-22 inherit (stdenv.hostPlatform) system; # Added 2021-10-22
inherit (stdenv) buildPlatform hostPlatform targetPlatform; # Added 2023-01-09 inherit (stdenv) buildPlatform hostPlatform targetPlatform; # Added 2023-01-09
freebsdCross = freebsd; # Added 2024-06-18
netbsdCross = netbsd; # Added 2024-06-18
openbsdCross = openbsd; # Added 2024-06-18
# LLVM packages for (integration) testing that should not be used inside Nixpkgs: # LLVM packages for (integration) testing that should not be used inside Nixpkgs:
llvmPackages_latest = llvmPackages_18; llvmPackages_latest = llvmPackages_18;
llvmPackages_git = recurseIntoAttrs (callPackage ../development/compilers/llvm/git { llvmPackages_git = recurseIntoAttrs (callPackage ../development/compilers/llvm/git {

View file

@ -31,19 +31,6 @@ with pkgs;
# it's just the plain stdenv. # it's just the plain stdenv.
stdenv_32bit = lowPrio (if stdenv.hostPlatform.is32bit then stdenv else multiStdenv); stdenv_32bit = lowPrio (if stdenv.hostPlatform.is32bit then stdenv else multiStdenv);
stdenvNoCC = stdenv.override (
{ cc = null; hasCC = false; }
// lib.optionalAttrs (stdenv.hostPlatform.isDarwin && (stdenv.hostPlatform != stdenv.buildPlatform)) {
# TODO: This is a hack to use stdenvNoCC to produce a CF when cross
# compiling. It's not very sound. The cross stdenv has:
# extraBuildInputs = [ targetPackages.darwin.apple_sdks.frameworks.CoreFoundation ]
# and uses stdenvNoCC. In order to make this not infinitely recursive, we
# need to exclude this extraBuildInput.
extraBuildInputs = [];
}
);
mkStdenvNoLibs = stdenv: let mkStdenvNoLibs = stdenv: let
bintools = stdenv.cc.bintools.override { bintools = stdenv.cc.bintools.override {
libc = null; libc = null;
@ -61,7 +48,7 @@ with pkgs;
}; };
stdenvNoLibs = stdenvNoLibs =
if stdenv.hostPlatform != stdenv.buildPlatform && (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.useLLVM or false) if stdenvNoCC.hostPlatform != stdenvNoCC.buildPlatform
then then
# We cannot touch binutils or cc themselves, because that will cause # We cannot touch binutils or cc themselves, because that will cause
# infinite recursion. So instead, we just choose a libc based on the # infinite recursion. So instead, we just choose a libc based on the
@ -74,7 +61,17 @@ with pkgs;
# thing to to create an earlier thing (leading to infinite recursion) and # thing to to create an earlier thing (leading to infinite recursion) and
# we also would still respect the stage arguments choices for these # we also would still respect the stage arguments choices for these
# things. # things.
overrideCC stdenv buildPackages.llvmPackages.clangNoCompilerRt (if stdenvNoCC.hostPlatform.isDarwin || stdenvNoCC.hostPlatform.useLLVM or false
then overrideCC stdenvNoCC buildPackages.llvmPackages.clangNoCompilerRt
else gccCrossLibcStdenv)
else mkStdenvNoLibs stdenv;
stdenvNoLibc =
if stdenvNoCC.hostPlatform != stdenvNoCC.buildPlatform
then
(if stdenvNoCC.hostPlatform.isDarwin || stdenvNoCC.hostPlatform.useLLVM or false
then overrideCC stdenvNoCC buildPackages.llvmPackages.clangNoLibc
else gccCrossLibcStdenv)
else mkStdenvNoLibs stdenv; else mkStdenvNoLibs stdenv;
gccStdenvNoLibs = mkStdenvNoLibs gccStdenv; gccStdenvNoLibs = mkStdenvNoLibs gccStdenv;
@ -15466,11 +15463,6 @@ with pkgs;
gccCrossLibcStdenv = overrideCC stdenvNoCC buildPackages.gccWithoutTargetLibc; gccCrossLibcStdenv = overrideCC stdenvNoCC buildPackages.gccWithoutTargetLibc;
crossLibcStdenv =
if stdenv.hostPlatform.useLLVM or false || stdenv.hostPlatform.isDarwin
then overrideCC stdenv buildPackages.llvmPackages.clangNoLibc
else gccCrossLibcStdenv;
# The GCC used to build libc for the target platform. Normal gccs will be # The GCC used to build libc for the target platform. Normal gccs will be
# built with, and use, that cross-compiled libc. # built with, and use, that cross-compiled libc.
gccWithoutTargetLibc = assert stdenv.targetPlatform != stdenv.hostPlatform; let gccWithoutTargetLibc = assert stdenv.targetPlatform != stdenv.hostPlatform; let
@ -17639,9 +17631,8 @@ with pkgs;
h3 = h3_3; h3 = h3_3;
avrlibc = callPackage ../development/misc/avr/libc { }; avrlibc = callPackage ../development/misc/avr/libc {
avrlibcCross = callPackage ../development/misc/avr/libc { stdenv = stdenvNoLibc;
stdenv = crossLibcStdenv;
}; };
avr8burnomat = callPackage ../development/misc/avr8-burn-omat { }; avr8burnomat = callPackage ../development/misc/avr8-burn-omat { };
@ -17715,10 +17706,7 @@ with pkgs;
msp430GccSupport = callPackage ../development/misc/msp430/gcc-support.nix { }; msp430GccSupport = callPackage ../development/misc/msp430/gcc-support.nix { };
msp430Newlib = callPackage ../development/misc/msp430/newlib.nix { }; msp430Newlib = callPackage ../development/misc/msp430/newlib.nix { };
msp430NewlibCross = callPackage ../development/misc/msp430/newlib.nix {
newlib = newlibCross;
};
mspds = callPackage ../development/misc/msp430/mspds { }; mspds = callPackage ../development/misc/msp430/mspds { };
mspds-bin = callPackage ../development/misc/msp430/mspds/binary.nix { }; mspds-bin = callPackage ../development/misc/msp430/mspds/binary.nix { };
@ -20933,14 +20921,14 @@ with pkgs;
}; };
muslCross = musl.override { muslCross = musl.override {
stdenv = crossLibcStdenv; stdenv = stdenvNoLibc;
}; };
# These are used when buiding compiler-rt / libgcc, prior to building libc. # These are used when buiding compiler-rt / libgcc, prior to building libc.
preLibcCrossHeaders = let preLibcCrossHeaders = let
inherit (stdenv.targetPlatform) libc; inherit (stdenv.targetPlatform) libc;
in if stdenv.targetPlatform.isMinGW then targetPackages.windows.mingw_w64_headers or windows.mingw_w64_headers in if stdenv.targetPlatform.isMinGW then targetPackages.windows.mingw_w64_headers or windows.mingw_w64_headers
else if libc == "nblibc" then targetPackages.netbsdCross.headers or netbsdCross.headers else if libc == "nblibc" then targetPackages.netbsd.headers or netbsd.headers
else if libc == "libSystem" && stdenv.targetPlatform.isAarch64 then targetPackages.darwin.LibsystemCross or darwin.LibsystemCross else if libc == "libSystem" && stdenv.targetPlatform.isAarch64 then targetPackages.darwin.LibsystemCross or darwin.LibsystemCross
else null; else null;
@ -20951,13 +20939,13 @@ with pkgs;
/**/ if name == null then null /**/ if name == null then null
else if name == "glibc" then targetPackages.glibcCross or glibcCross else if name == "glibc" then targetPackages.glibcCross or glibcCross
else if name == "bionic" then targetPackages.bionic or bionic else if name == "bionic" then targetPackages.bionic or bionic
else if name == "uclibc" then targetPackages.uclibcCross or uclibcCross else if name == "uclibc" then targetPackages.uclibc or uclibc
else if name == "avrlibc" then targetPackages.avrlibcCross or avrlibcCross else if name == "avrlibc" then targetPackages.avrlibc or avrlibc
else if name == "newlib" && stdenv.targetPlatform.isMsp430 then targetPackages.msp430NewlibCross or msp430NewlibCross else if name == "newlib" && stdenv.targetPlatform.isMsp430 then targetPackages.msp430Newlib or msp430Newlib
else if name == "newlib" && stdenv.targetPlatform.isVc4 then targetPackages.vc4-newlib or vc4-newlib else if name == "newlib" && stdenv.targetPlatform.isVc4 then targetPackages.vc4-newlib or vc4-newlib
else if name == "newlib" && stdenv.targetPlatform.isOr1k then targetPackages.or1k-newlib or or1k-newlib else if name == "newlib" && stdenv.targetPlatform.isOr1k then targetPackages.or1k-newlib or or1k-newlib
else if name == "newlib" then targetPackages.newlibCross or newlibCross else if name == "newlib" then targetPackages.newlib or newlib
else if name == "newlib-nano" then targetPackages.newlib-nanoCross or newlib-nanoCross else if name == "newlib-nano" then targetPackages.newlib-nano or newlib-nano
else if name == "musl" then targetPackages.muslCross or muslCross else if name == "musl" then targetPackages.muslCross or muslCross
else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64 else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
else if name == "ucrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64 else if name == "ucrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
@ -20965,9 +20953,9 @@ with pkgs;
if stdenv.targetPlatform.useiOSPrebuilt if stdenv.targetPlatform.useiOSPrebuilt
then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries
else targetPackages.darwin.LibsystemCross or (throw "don't yet have a `targetPackages.darwin.LibsystemCross for ${stdenv.targetPlatform.config}`") else targetPackages.darwin.LibsystemCross or (throw "don't yet have a `targetPackages.darwin.LibsystemCross for ${stdenv.targetPlatform.config}`")
else if name == "fblibc" then targetPackages.freebsdCross.libc or freebsdCross.libc else if name == "fblibc" then targetPackages.freebsd.libc or freebsd.libc
else if name == "oblibc" then targetPackages.openbsdCross.libc or openbsdCross.libc else if name == "oblibc" then targetPackages.openbsd.libc or openbsd.libc
else if name == "nblibc" then targetPackages.netbsdCross.libc or netbsdCross.libc else if name == "nblibc" then targetPackages.netbsd.libc or netbsd.libc
else if name == "wasilibc" then targetPackages.wasilibc or wasilibc else if name == "wasilibc" then targetPackages.wasilibc or wasilibc
else if name == "relibc" then targetPackages.relibc or relibc else if name == "relibc" then targetPackages.relibc or relibc
else throw "Unknown libc ${name}"; else throw "Unknown libc ${name}";
@ -20983,7 +20971,7 @@ with pkgs;
}; };
wasilibc = callPackage ../development/libraries/wasilibc { wasilibc = callPackage ../development/libraries/wasilibc {
stdenv = crossLibcStdenv; stdenv = stdenvNoLibc;
}; };
relibc = callPackage ../development/libraries/relibc { }; relibc = callPackage ../development/libraries/relibc { };
@ -27974,14 +27962,6 @@ with pkgs;
buildBarebox buildBarebox
bareboxTools; bareboxTools;
uclibc-ng-cross = uclibc-ng.override {
stdenv = crossLibcStdenv;
};
# Aliases
uclibc = uclibc-ng;
uclibcCross = uclibc-ng-cross;
eudev = callPackage ../by-name/eu/eudev/package.nix { eudev = callPackage ../by-name/eu/eudev/package.nix {
util-linux = util-linuxMinimal; util-linux = util-linuxMinimal;
}; };
@ -40611,18 +40591,11 @@ with pkgs;
name = "bsd-setup-hook"; name = "bsd-setup-hook";
} ../os-specific/bsd/setup-hook.sh; } ../os-specific/bsd/setup-hook.sh;
inherit (callPackage ../os-specific/bsd/freebsd { }) freebsd = callPackage ../os-specific/bsd/freebsd { };
freebsd freebsdCross;
netbsd = callPackage ../os-specific/bsd/netbsd { }; netbsd = callPackage ../os-specific/bsd/netbsd { };
netbsdCross = callPackage ../os-specific/bsd/netbsd {
stdenv = crossLibcStdenv;
};
openbsd = callPackage ../os-specific/bsd/openbsd { }; openbsd = callPackage ../os-specific/bsd/openbsd { };
openbsdCross = callPackage ../os-specific/bsd/openbsd {
stdenv = crossLibcStdenv;
};
powershell = callPackage ../shells/powershell { }; powershell = callPackage ../shells/powershell { };
@ -40646,18 +40619,14 @@ with pkgs;
new-session-manager = callPackage ../applications/audio/new-session-manager { }; new-session-manager = callPackage ../applications/audio/new-session-manager { };
newlib = callPackage ../development/misc/newlib { }; newlib = callPackage ../development/misc/newlib {
newlibCross = callPackage ../development/misc/newlib { stdenv = stdenvNoLibc;
stdenv = crossLibcStdenv;
}; };
newlib-nano = callPackage ../development/misc/newlib { newlib-nano = callPackage ../development/misc/newlib {
stdenv = stdenvNoLibc;
nanoizeNewlib = true; nanoizeNewlib = true;
}; };
newlib-nanoCross = callPackage ../development/misc/newlib {
nanoizeNewlib = true;
stdenv = crossLibcStdenv;
};
omnisharp-roslyn = callPackage ../development/tools/omnisharp-roslyn { }; omnisharp-roslyn = callPackage ../development/tools/omnisharp-roslyn { };

View file

@ -49,6 +49,10 @@ in
, # The standard environment to use for building packages. , # The standard environment to use for building packages.
stdenv stdenv
, # `stdenv` without a C compiler. Passing in this helps avoid infinite
# recursions, and may eventually replace passing in the full stdenv.
stdenvNoCC ? stdenv.override { cc = null; hasCC = false; }
, # This is used because stdenv replacement and the stdenvCross do benefit from , # This is used because stdenv replacement and the stdenvCross do benefit from
# the overridden configuration provided by the user, as opposed to the normal # the overridden configuration provided by the user, as opposed to the normal
# bootstrapping stdenvs. # bootstrapping stdenvs.
@ -141,7 +145,7 @@ let
pkgs = self.pkgsHostTarget; pkgs = self.pkgsHostTarget;
targetPackages = self.pkgsTargetTarget; targetPackages = self.pkgsTargetTarget;
inherit stdenv; inherit stdenv stdenvNoCC;
}; };
splice = self: super: import ./splice.nix lib self (adjacentPackages != null); splice = self: super: import ./splice.nix lib self (adjacentPackages != null);