]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Rollup merge of #74441 - eddyb:zlib-on-nixos, r=nagisa
authorManish Goregaokar <manishsmail@gmail.com>
Sat, 18 Jul 2020 01:13:44 +0000 (18:13 -0700)
committerGitHub <noreply@github.com>
Sat, 18 Jul 2020 01:13:44 +0000 (18:13 -0700)
commit8d1bb0e7488855f40175d38c035bad1c546da97b
tree2a0f06de6119a76ee4ca8b16222a4bf8934a1538
parent7b66c6678c107b4b391a8561c375e8ffad0f52e2
parentb5076fbb9669bd8e29ad58160a2d60ddd6813df7
Rollup merge of #74441 - eddyb:zlib-on-nixos, r=nagisa

bootstrap.py: patch RPATH on NixOS to handle the new zlib dependency.

This is a stop-gap until #74420 is resolved (assuming we'll patch beta to statically link zlib).

However, I've been meaning to rewrite the NixOS support we have in `bootstrap.py` for a while now, and had to in order to cleanly add zlib as a dependency (the second commit is a relatively small delta in functionality, compared to the first).

Previously, we would extract the `ld-linux.so` path from the output of `ldd /run/current-system/sw/bin/sh`, which assumes a lot. On top of that we didn't use any symlinks, which meant if the user ran  GC (`nix-collect-garbage`), e.g. after updating their system, their `stage0` binaries would suddenly be broken (i.e. referring to files that no longer exist).
We were also using `patchelf` directly, assuming it can be found in `$PATH` (which is not necessarily true).

My new approach relies on using `nix-build` to get the following "derivations" (packages, more or less):
* `stdenv.cc.bintools`, which has a `nix-support/dynamic-linker` file containing the path to `ld-linux.so`
  * reading this file is [the canonical way to run `patchelf --set-interpreter`](https://github.com/NixOS/nixpkgs/search?l=Nix&q=%22--set-interpreter+%24%28cat+%24NIX_CC%2Fnix-support%2Fdynamic-linker%29%22)
* `patchelf` (so that the user doesn't need to have it installed)
* `zlib`, for the `libz.so` dependency of `libLLVM-*.so` (until #74420 is resolved, presumably)

This is closer to how software is built on Nix, but I've tried to keep it as simple as possible (and not add e.g. a `stage0.nix` file).
Symlinks to each of those dependencies are kept in `stage0/.nix-deps`, which prevents GC from invalidating `stage0` binaries.

r? @nagisa cc @Mark-Simulacrum @oli-obk @davidtwco