Skip to content

Commit

Permalink
stdenv: use gcc external bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Joseph committed Jan 16, 2023
1 parent 446ca63 commit abbf7fa
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 53 deletions.
40 changes: 36 additions & 4 deletions pkgs/development/libraries/glibc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
, withGd ? false
, withLibcrypt? false
, buildPackages
, enableCopyLibGccHack ? true
, enableCopyLibGccHack ? !stdenv.enableGccExternalBootstrapForStdenv or false
}:

let
Expand All @@ -15,10 +15,12 @@ let
];
in

lib.pipe
(callPackage ./common.nix { inherit stdenv; } {
inherit withLinuxHeaders withGd profilingLibraries withLibcrypt;
pname = "glibc" + lib.optionalString withGd "-gd";
}).overrideAttrs(previousAttrs: {
}) [
(pkg: pkg.overrideAttrs(previousAttrs: {

# Note:
# Things you write here override, and do not add to,
Expand Down Expand Up @@ -65,6 +67,27 @@ in
])
]);

# glibc needs to `dlopen()` `libgcc_s.so` (see `preInstall` phase below for
# why) but does not link against it. Furthermore, glibc doesn't use the
# ordinary `dlopen()` call to do this; instead it uses one which ignores
# most paths:
#
# https://sourceware.org/legacy-ml/libc-help/2013-11/msg00026.html
#
# In order to get it to not ignore `libgcc_s.so`, we have to add its path to
# `user-defined-trusted-dirs`:
#
# https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/Makefile;h=b509b3eada1fb77bf81e2a0ca5740b94ad185764#l1355
#
# Conveniently, this will also inform Nix of the fact that glibc depends on
# gcc.libgcc, since the path will be embedded in the resulting binary.
#
makeFlags =
(previousAttrs.makeFlags or [])
++ lib.optionals (!enableCopyLibGccHack && stdenv.cc.cc?libgcc) [
"user-defined-trusted-dirs=${stdenv.cc.cc.libgcc}/lib"
];

# Since glibc commit 9d79e0377b08773ec4f7ec38479b1563606f7ef7, Any program
# which calls `pthread_cancel()` or `pthread_exit()` must be able to
# `dlopen("libgcc_s.so")`. If it cannot, `glibc` will abort the process.
Expand Down Expand Up @@ -170,6 +193,15 @@ in

separateDebugInfo = true;

meta = (previousAttrs.meta or {}) // { description = "The GNU C Library"; };
})
meta = (previousAttrs.meta or {}) // { description = "The GNU C Library"; };
}))

(pkg: pkg.overrideAttrs (previousAttrs: {
passthru = (previousAttrs.passthru or {}) // {
isFromBootstrapTools = false;
} // lib.optionalAttrs (!enableCopyLibGccHack && stdenv.cc.cc?libgcc) {
inherit (stdenv.cc.cc) libgcc;
};
}))
]

1 change: 1 addition & 0 deletions pkgs/development/libraries/gmp/6.x.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let self = stdenv.mkDerivation rec {
# - see #5855 for related discussion
outputs = [ "out" "dev" "info" ];
passthru.static = self.out;
passthru.isFromBootstrapFiles = false;

strictDeps = true;
depsBuildBuild = [ buildPackages.stdenv.cc ];
Expand Down
1 change: 1 addition & 0 deletions pkgs/development/libraries/isl/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ stdenv.mkDerivation {
description = "A library for manipulating sets and relations of integer points bounded by linear constraints";
platforms = lib.platforms.all;
};
passthru.isFromBootstrapFiles = false;
}
1 change: 1 addition & 0 deletions pkgs/development/libraries/libmpc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ stdenv.mkDerivation rec {
platforms = lib.platforms.all;
maintainers = [ ];
};
passthru.isFromBootstrapFiles = false;
}
1 change: 1 addition & 0 deletions pkgs/development/libraries/mpfr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ stdenv.mkDerivation rec {
pcregrep -o1 '<title>GNU MPFR version ([0-9.]+)</title>')"
update-source-version ${pname} "$new_version"
'';
isFromBootstrapFiles = false;
};

meta = {
Expand Down
Loading

0 comments on commit abbf7fa

Please sign in to comment.