diff options
author | Adam Joseph <adam@westernsemico.com> | 2023-04-02 05:10:51 -0700 |
---|---|---|
committer | Adam Joseph <adam@westernsemico.com> | 2023-04-02 13:49:53 -0700 |
commit | d7fe0a5548413fedb2c23d8b7d9864c99350e226 (patch) | |
tree | 7a100d96b18ed6b0c341bc167288b3205a79d442 /pkgs/stdenv | |
parent | 86ca0faff759bb28901079e643c55c3f6a4ea47d (diff) |
make-bootstrap-tools.nix: use a patchelf built with -static-{libgcc,libstdc++}
Our bootstrap-files unpacker has always relied on a lot of unstated assumptions, one of them being that every library has a DT_NEEDED for librt.so, so patchelf'ing something into the RUNPATH into librt.so means that it will be searched for every library load in all of the bootstrap-files. Unfortunately that assumption is not true for libgcc. This causes problems, because patchelf links against libgcc (and against libstdc++, which links against libgcc). So we can't use patchelf on libgcc, because it needs libgcc, so patchelf doesn't work until libgcc is patchelfed. The robust solution here is to use static linking for the copy of patchelf that is shipped with the bootstrap-files. We don't have to go all the way to a statically linked libc; just -static-libgcc and -static-libstdc++ are enough to break the circular dependency.
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/linux/make-bootstrap-tools.nix | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix index 107e4c43a9fa0..091130ebf93a8 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix @@ -2,6 +2,10 @@ let libc = pkgs.stdenv.cc.libc; + patchelf = pkgs.patchelf.overrideAttrs(previousAttrs: { + NIX_CFLAGS_COMPILE = (previousAttrs.NIX_CFLAGS_COMPILE or []) ++ [ "-static-libgcc" "-static-libstdc++" ]; + NIX_CFLAGS_LINK = (previousAttrs.NIX_CFLAGS_LINK or []) ++ [ "-static-libgcc" "-static-libstdc++" ]; + }); in with pkgs; rec { |