Skip to content

Commit 4c61b30

Browse files
committed
bootstrap: auto-patch libgccjit.so for NixOS
Currently all downloaded rustc and LLVM components are auto patched on NixOS, but this is not done for libgccjit.so, so when GCC backend is enabled on NixOS, the build ICEs with errors like this: thread 'rustc' (2286205) panicked at compiler/rustc_codegen_gcc/src/lib.rs:191:9: Cannot load libgccjit.so: libzstd.so.1: cannot open shared object file: No such file or directory Fix this by auto-patch libgccjit.so, too. `zstd` is added to the dependency environment. Signed-off-by: Gary Guo <gary@garyguo.net>
1 parent 25a54d4 commit 4c61b30

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/bootstrap/src/core/download.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,16 @@ impl Config {
398398
self.download_file(&format!("{base}/{gcc_sha}/{filename}"), &tarball, help_on_error);
399399
}
400400
self.unpack(&tarball, root_dir, "gcc-dev");
401+
402+
if self.should_fix_bins_and_dylibs() {
403+
let lib_dir = root_dir.join("lib");
404+
for entry in t!(fs::read_dir(lib_dir)) {
405+
let lib = t!(entry).path();
406+
if path_is_dylib(&lib) {
407+
self.fix_bin_or_dylib(&lib);
408+
}
409+
}
410+
}
401411
}
402412
}
403413

@@ -677,6 +687,8 @@ fn fix_bin_or_dylib(out: &Path, fname: &Path, exec_ctx: &ExecutionContext) {
677687
// bintools: Needed for the path of `ld-linux.so` (via `nix-support/dynamic-linker`).
678688
// cc.lib: Needed similarly for `libstdc++.so.6`.
679689
// zlib: Needed as a system dependency of `libLLVM-*.so`.
690+
// zstd.out: Needed as a system dependency of `libgccjit.so`. `.out` is necessary as the
691+
// default output of `zstd` derivation is `.bin`.
680692
// patchelf: Needed for patching ELF binaries (see doc comment above).
681693
let nix_deps_dir = out.join(".nix-deps");
682694
const NIX_EXPR: &str = "
@@ -685,6 +697,7 @@ fn fix_bin_or_dylib(out: &Path, fname: &Path, exec_ctx: &ExecutionContext) {
685697
name = \"rust-stage0-dependencies\";
686698
paths = [
687699
zlib
700+
zstd.out
688701
patchelf
689702
stdenv.cc.bintools
690703
stdenv.cc.cc.lib

0 commit comments

Comments
 (0)