mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-08 02:38:11 +09:00
treewide: Leverage new top-level libc
in bootstrap, and simplify (#414573)
This commit is contained in:
commit
379d141418
7 changed files with 93 additions and 80 deletions
|
@ -242,7 +242,7 @@ self: super:
|
|||
buildPackages.stdenv.cc
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isStatic [
|
||||
(xorg.buildPackages.stdenv.cc.libc.static or null)
|
||||
(xorg.buildPackages.libc.static or null)
|
||||
];
|
||||
preConfigure = ''
|
||||
sed 's,^as_dummy.*,as_dummy="\$PATH",' -i configure
|
||||
|
|
|
@ -132,7 +132,7 @@ let
|
|||
bintools = prevStage.darwin.binutils;
|
||||
|
||||
isClang = true;
|
||||
libc = prevStage.darwin.libSystem;
|
||||
inherit (prevStage) libc;
|
||||
inherit (prevStage.llvmPackages) libcxx;
|
||||
|
||||
inherit lib;
|
||||
|
@ -582,7 +582,10 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
|
||||
assert allDeps isFromNixpkgs [
|
||||
(sdkPackagesNoCC prevStage)
|
||||
{ inherit (prevStage.darwin) binutils libSystem; }
|
||||
{
|
||||
inherit (prevStage.darwin) binutils libSystem;
|
||||
inherit (prevStage) libc;
|
||||
}
|
||||
];
|
||||
|
||||
stageFun prevStage {
|
||||
|
@ -1260,6 +1263,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
assert isBuiltByNixpkgsCompiler prevStage.darwin.sigtool;
|
||||
|
||||
assert isFromNixpkgs prevStage.darwin.libSystem;
|
||||
assert isFromNixpkgs prevStage.libc;
|
||||
assert isFromNixpkgs prevStage.darwin.binutils-unwrapped;
|
||||
|
||||
assert isBuiltByNixpkgsCompiler prevStage.llvmPackages.clang-unwrapped;
|
||||
|
|
|
@ -158,8 +158,6 @@ let
|
|||
isFromBootstrapFiles = true;
|
||||
};
|
||||
|
||||
getLibc = stage: stage.${localSystem.libc};
|
||||
|
||||
# This function builds the various standard environments used during
|
||||
# the bootstrap. In all stages, we build an stdenv and the package
|
||||
# set that can be built with that stdenv.
|
||||
|
@ -207,7 +205,7 @@ let
|
|||
cc = prevStage.gcc-unwrapped;
|
||||
bintools = prevStage.binutils;
|
||||
isGNU = true;
|
||||
libc = getLibc prevStage;
|
||||
inherit (prevStage) libc;
|
||||
inherit lib;
|
||||
inherit (prevStage) coreutils gnugrep;
|
||||
stdenvNoCC = prevStage.ccWrapperStdenv;
|
||||
|
@ -221,7 +219,7 @@ let
|
|||
postFixup =
|
||||
(a.postFixup or "")
|
||||
+ ''
|
||||
echo "--sysroot=${lib.getDev (getLibc prevStage)}" >> $out/nix-support/cc-cflags
|
||||
echo "--sysroot=${lib.getDev prevStage.libc}" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
@ -293,9 +291,13 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
expand-response-params = "";
|
||||
libc = getLibc self;
|
||||
inherit lib;
|
||||
inherit (self) stdenvNoCC coreutils gnugrep;
|
||||
inherit (self)
|
||||
stdenvNoCC
|
||||
coreutils
|
||||
gnugrep
|
||||
libc
|
||||
;
|
||||
bintools = bootstrapTools;
|
||||
runtimeShell = "${bootstrapTools}/bin/bash";
|
||||
};
|
||||
|
@ -320,6 +322,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
# previous stage0 stdenv:
|
||||
assert isFromBootstrapFiles prevStage.binutils.bintools;
|
||||
assert isFromBootstrapFiles prevStage."${localSystem.libc}";
|
||||
assert isFromBootstrapFiles prevStage.libc;
|
||||
assert isFromBootstrapFiles prevStage.gcc-unwrapped;
|
||||
assert isFromBootstrapFiles prevStage.coreutils;
|
||||
assert isFromBootstrapFiles prevStage.gnugrep;
|
||||
|
@ -339,7 +342,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
binutils
|
||||
;
|
||||
|
||||
${localSystem.libc} = getLibc prevStage;
|
||||
${localSystem.libc} = prevStage.${localSystem.libc};
|
||||
|
||||
# A threaded perl build needs glibc/libpthread_nonshared.a,
|
||||
# which is not included in bootstrapTools, so disable threading.
|
||||
|
@ -374,6 +377,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
prevStage:
|
||||
assert isBuiltByBootstrapFilesCompiler prevStage.binutils-unwrapped;
|
||||
assert isFromBootstrapFiles prevStage."${localSystem.libc}";
|
||||
assert isFromBootstrapFiles prevStage.libc;
|
||||
assert isFromBootstrapFiles prevStage.gcc-unwrapped;
|
||||
assert isFromBootstrapFiles prevStage.coreutils;
|
||||
assert isFromBootstrapFiles prevStage.gnugrep;
|
||||
|
@ -393,7 +397,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
perl
|
||||
patchelf
|
||||
;
|
||||
${localSystem.libc} = getLibc prevStage;
|
||||
${localSystem.libc} = prevStage.${localSystem.libc};
|
||||
gmp = super.gmp.override { cxx = false; };
|
||||
# This stage also rebuilds binutils which will of course be used only in the next stage.
|
||||
# We inherit this until stage3, in stage4 it will be rebuilt using the adjacent bash/runtimeShell pkg.
|
||||
|
@ -484,6 +488,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
# previous stage1 stdenv:
|
||||
assert isBuiltByBootstrapFilesCompiler prevStage.binutils-unwrapped;
|
||||
assert isFromBootstrapFiles prevStage."${localSystem.libc}";
|
||||
assert isFromBootstrapFiles prevStage.libc;
|
||||
assert isBuiltByBootstrapFilesCompiler prevStage.gcc-unwrapped;
|
||||
assert isFromBootstrapFiles prevStage.coreutils;
|
||||
assert isFromBootstrapFiles prevStage.gnugrep;
|
||||
|
@ -508,6 +513,9 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
doCheck = false;
|
||||
});
|
||||
|
||||
# Avoids infinite recursion, as this is in the build-time dependencies of libc.
|
||||
libiconv = self.libcIconv prevStage.libc;
|
||||
|
||||
# We need libidn2 and its dependency libunistring as glibc dependency.
|
||||
# To avoid the cycle, we build against bootstrap libc, nuke references,
|
||||
# and use the result as input for our final glibc. We also pass this pair
|
||||
|
@ -538,7 +546,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
binutils = prevStage.binutils.override {
|
||||
# Rewrap the binutils with the new glibc, so both the next
|
||||
# stage's wrappers use it.
|
||||
libc = getLibc self;
|
||||
inherit (self) libc;
|
||||
|
||||
# Unfortunately, when building gcc in the next stage, its LTO plugin
|
||||
# would use the final libc but `ld` would use the bootstrap one,
|
||||
|
@ -557,8 +565,8 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
mkdir -p "$out"/bin
|
||||
cp -a '${prevStage.bintools.bintools}'/bin/* "$out"/bin/
|
||||
chmod +w "$out"/bin/ld.bfd
|
||||
patchelf --set-interpreter '${getLibc self}'/lib/ld*.so.? \
|
||||
--set-rpath "${getLibc self}/lib:$(patchelf --print-rpath "$out"/bin/ld.bfd)" \
|
||||
patchelf --set-interpreter '${self.libc}'/lib/ld*.so.? \
|
||||
--set-rpath "${self.libc}/lib:$(patchelf --print-rpath "$out"/bin/ld.bfd)" \
|
||||
"$out"/bin/ld.bfd
|
||||
'';
|
||||
};
|
||||
|
@ -589,6 +597,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
# previous stage2 stdenv:
|
||||
assert isBuiltByNixpkgsCompiler prevStage.binutils-unwrapped;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.${localSystem.libc};
|
||||
assert isBuiltByNixpkgsCompiler prevStage.libc;
|
||||
assert isBuiltByBootstrapFilesCompiler prevStage.gcc-unwrapped;
|
||||
assert isFromBootstrapFiles prevStage.coreutils;
|
||||
assert isFromBootstrapFiles prevStage.gnugrep;
|
||||
|
@ -625,7 +634,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
gmp = super.gmp.override { cxx = false; };
|
||||
}
|
||||
// {
|
||||
${localSystem.libc} = getLibc prevStage;
|
||||
${localSystem.libc} = prevStage.${localSystem.libc};
|
||||
gcc-unwrapped =
|
||||
(super.gcc-unwrapped.override (
|
||||
commonGccOverrides
|
||||
|
@ -661,6 +670,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
# previous stage3 stdenv:
|
||||
assert isBuiltByNixpkgsCompiler prevStage.binutils-unwrapped;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.${localSystem.libc};
|
||||
assert isBuiltByNixpkgsCompiler prevStage.libc;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.gcc-unwrapped;
|
||||
assert isFromBootstrapFiles prevStage.coreutils;
|
||||
assert isFromBootstrapFiles prevStage.gnugrep;
|
||||
|
@ -684,7 +694,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
libidn2
|
||||
libunistring
|
||||
;
|
||||
${localSystem.libc} = getLibc prevStage;
|
||||
${localSystem.libc} = prevStage.${localSystem.libc};
|
||||
# Since this is the first fresh build of binutils since stage2, our own runtimeShell will be used.
|
||||
binutils = super.binutils.override {
|
||||
# Build expand-response-params with last stage like below
|
||||
|
@ -702,13 +712,13 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
inherit (prevStage) expand-response-params;
|
||||
cc = prevStage.gcc-unwrapped;
|
||||
bintools = self.binutils;
|
||||
libc = getLibc self;
|
||||
inherit lib;
|
||||
inherit (self)
|
||||
stdenvNoCC
|
||||
coreutils
|
||||
gnugrep
|
||||
runtimeShell
|
||||
libc
|
||||
;
|
||||
fortify-headers = self.fortify-headers;
|
||||
};
|
||||
|
@ -736,6 +746,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
# which applies here as well.
|
||||
assert isBuiltByNixpkgsCompiler prevStage.binutils-unwrapped;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.${localSystem.libc};
|
||||
assert isBuiltByNixpkgsCompiler prevStage.libc;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.gcc-unwrapped;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.coreutils;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.gnugrep;
|
||||
|
@ -843,7 +854,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
libunistring
|
||||
]
|
||||
# More complicated cases
|
||||
++ (map (x: lib.getOutput x (getLibc prevStage)) [
|
||||
++ (map (x: lib.getOutput x (prevStage.libc)) [
|
||||
"out"
|
||||
"dev"
|
||||
"bin"
|
||||
|
@ -893,7 +904,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
libunistring
|
||||
;
|
||||
inherit (prevStage.gnugrep) pcre2;
|
||||
${localSystem.libc} = getLibc prevStage;
|
||||
${localSystem.libc} = prevStage.${localSystem.libc};
|
||||
|
||||
# Hack: avoid libidn2.{bin,dev} referencing bootstrap tools. There's a logical cycle.
|
||||
libidn2 = import ../../development/libraries/libidn2/no-bootstrap-reference.nix {
|
||||
|
@ -925,6 +936,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
|
|||
# which applies here as well.
|
||||
assert isBuiltByNixpkgsCompiler prevStage.binutils-unwrapped;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.${localSystem.libc};
|
||||
assert isBuiltByNixpkgsCompiler prevStage.libc;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.gcc-unwrapped;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.coreutils;
|
||||
assert isBuiltByNixpkgsCompiler prevStage.gnugrep;
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
}:
|
||||
|
||||
let
|
||||
inherit (pkgs) lib stdenv config;
|
||||
|
||||
libc = pkgs.stdenv.cc.libc;
|
||||
inherit (pkgs)
|
||||
lib
|
||||
stdenv
|
||||
config
|
||||
libc
|
||||
;
|
||||
|
||||
patchelf = pkgs.patchelf.overrideAttrs (previousAttrs: {
|
||||
NIX_CFLAGS_COMPILE = (previousAttrs.NIX_CFLAGS_COMPILE or [ ]) ++ [
|
||||
|
|
|
@ -6181,7 +6181,7 @@ with pkgs;
|
|||
wrapBintoolsWith =
|
||||
{
|
||||
bintools,
|
||||
libc ? if stdenv.targetPlatform != stdenv.hostPlatform then targetPackages.libc else stdenv.cc.libc,
|
||||
libc ? targetPackages.libc or pkgs.libc,
|
||||
...
|
||||
}@extraArgs:
|
||||
callPackage ../build-support/bintools-wrapper (
|
||||
|
@ -8198,57 +8198,53 @@ with pkgs;
|
|||
|
||||
# We can choose:
|
||||
libc =
|
||||
if stdenv.hostPlatform == stdenv.buildPlatform then
|
||||
# TODO get rid of this branch after the native boostrap is reworked
|
||||
stdenv.cc.libc
|
||||
let
|
||||
inherit (stdenv.hostPlatform) libc;
|
||||
# libc is hackily often used from the previous stage. This `or`
|
||||
# hack fixes the hack, *sigh*.
|
||||
in
|
||||
if libc == null then
|
||||
null
|
||||
else if libc == "glibc" then
|
||||
glibc
|
||||
else if libc == "bionic" then
|
||||
bionic
|
||||
else if libc == "uclibc" then
|
||||
uclibc
|
||||
else if libc == "avrlibc" then
|
||||
avrlibc
|
||||
else if libc == "newlib" && stdenv.hostPlatform.isMsp430 then
|
||||
msp430Newlib
|
||||
else if libc == "newlib" && stdenv.hostPlatform.isVc4 then
|
||||
vc4-newlib
|
||||
else if libc == "newlib" && stdenv.hostPlatform.isOr1k then
|
||||
or1k-newlib
|
||||
else if libc == "newlib" then
|
||||
newlib
|
||||
else if libc == "newlib-nano" then
|
||||
newlib-nano
|
||||
else if libc == "musl" then
|
||||
musl
|
||||
else if libc == "msvcrt" then
|
||||
windows.mingw_w64
|
||||
else if libc == "ucrt" then
|
||||
windows.mingw_w64
|
||||
else if libc == "libSystem" then
|
||||
if stdenv.hostPlatform.useiOSPrebuilt then darwin.iosSdkPkgs.libraries else darwin.libSystem
|
||||
else if libc == "fblibc" then
|
||||
freebsd.libc
|
||||
else if libc == "oblibc" then
|
||||
openbsd.libc
|
||||
else if libc == "nblibc" then
|
||||
netbsd.libc
|
||||
else if libc == "wasilibc" then
|
||||
wasilibc
|
||||
else if libc == "relibc" then
|
||||
relibc
|
||||
else if name == "llvm" then
|
||||
llvmPackages_20.libc
|
||||
else
|
||||
let
|
||||
inherit (stdenv.hostPlatform) libc;
|
||||
# libc is hackily often used from the previous stage. This `or`
|
||||
# hack fixes the hack, *sigh*.
|
||||
in
|
||||
if libc == null then
|
||||
null
|
||||
else if libc == "glibc" then
|
||||
glibc
|
||||
else if libc == "bionic" then
|
||||
bionic
|
||||
else if libc == "uclibc" then
|
||||
uclibc
|
||||
else if libc == "avrlibc" then
|
||||
avrlibc
|
||||
else if libc == "newlib" && stdenv.hostPlatform.isMsp430 then
|
||||
msp430Newlib
|
||||
else if libc == "newlib" && stdenv.hostPlatform.isVc4 then
|
||||
vc4-newlib
|
||||
else if libc == "newlib" && stdenv.hostPlatform.isOr1k then
|
||||
or1k-newlib
|
||||
else if libc == "newlib" then
|
||||
newlib
|
||||
else if libc == "newlib-nano" then
|
||||
newlib-nano
|
||||
else if libc == "musl" then
|
||||
musl
|
||||
else if libc == "msvcrt" then
|
||||
windows.mingw_w64
|
||||
else if libc == "ucrt" then
|
||||
windows.mingw_w64
|
||||
else if libc == "libSystem" then
|
||||
if stdenv.hostPlatform.useiOSPrebuilt then darwin.iosSdkPkgs.libraries else darwin.libSystem
|
||||
else if libc == "fblibc" then
|
||||
freebsd.libc
|
||||
else if libc == "oblibc" then
|
||||
openbsd.libc
|
||||
else if libc == "nblibc" then
|
||||
netbsd.libc
|
||||
else if libc == "wasilibc" then
|
||||
wasilibc
|
||||
else if libc == "relibc" then
|
||||
relibc
|
||||
else if name == "llvm" then
|
||||
llvmPackages_20.libc
|
||||
else
|
||||
throw "Unknown libc ${libc}";
|
||||
throw "Unknown libc ${libc}";
|
||||
|
||||
threads =
|
||||
lib.optionalAttrs (stdenv.hostPlatform.isMinGW && !(stdenv.hostPlatform.useLLVM or false))
|
||||
|
@ -8772,7 +8768,7 @@ with pkgs;
|
|||
"fblibc"
|
||||
]
|
||||
then
|
||||
libcIconv (if stdenv.hostPlatform != stdenv.buildPlatform then libc else stdenv.cc.libc)
|
||||
libcIconv pkgs.libc
|
||||
else if stdenv.hostPlatform.isDarwin then
|
||||
darwin.libiconv
|
||||
else
|
||||
|
@ -8798,7 +8794,7 @@ with pkgs;
|
|||
"musl"
|
||||
]
|
||||
then
|
||||
lib.getBin stdenv.cc.libc
|
||||
lib.getBin libc
|
||||
else if stdenv.hostPlatform.isDarwin then
|
||||
lib.getBin libiconv
|
||||
else if stdenv.hostPlatform.isFreeBSD then
|
||||
|
|
|
@ -56,8 +56,7 @@ makeScopeWithSplicing' {
|
|||
};
|
||||
|
||||
binutils = pkgs.wrapBintoolsWith {
|
||||
libc =
|
||||
if stdenv.targetPlatform != stdenv.hostPlatform then targetPackages.libc else pkgs.stdenv.cc.libc;
|
||||
inherit (targetPackages) libc;
|
||||
bintools = self.binutils-unwrapped;
|
||||
};
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ let
|
|||
linux = pkgs.util-linux;
|
||||
};
|
||||
getconf = {
|
||||
linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.stdenv.cc.libc else pkgs.netbsd.getconf;
|
||||
linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.libc else pkgs.netbsd.getconf;
|
||||
darwin = pkgs.darwin.system_cmds;
|
||||
# I don't see any obvious arg exec in the doc/manpage
|
||||
binlore = ''
|
||||
|
@ -103,8 +103,7 @@ let
|
|||
'';
|
||||
};
|
||||
getent = {
|
||||
linux =
|
||||
if stdenv.hostPlatform.libc == "glibc" then pkgs.stdenv.cc.libc.getent else pkgs.netbsd.getent;
|
||||
linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.libc.getent else pkgs.netbsd.getent;
|
||||
darwin = pkgs.netbsd.getent;
|
||||
freebsd = pkgs.freebsd.getent;
|
||||
openbsd = pkgs.openbsd.getent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue