From 7a559264d53cb36a361b3d46b5dee572e8b2b795 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 26 Nov 2022 14:17:19 +0200 Subject: [PATCH] bootstrap: on NixOS, also patchelf `libexec/*`, just like `bin/*`. --- src/bootstrap/bootstrap.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 57128685d9110..c7f7721a9e64f 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -437,10 +437,19 @@ def download_toolchain(self): filename = "cargo-{}-{}{}".format(rustc_channel, self.build, tarball_suffix) self._download_component_helper(filename, "cargo", tarball_suffix) - self.fix_bin_or_dylib("{}/bin/cargo".format(bin_root)) - self.fix_bin_or_dylib("{}/bin/rustc".format(bin_root)) - self.fix_bin_or_dylib("{}/bin/rustdoc".format(bin_root)) + for bin_dir_name in ["bin", "libexec"]: + bin_dir = "{}/{}".format(bin_root, bin_dir_name) + for bin in os.listdir(bin_dir): + bin_file = os.path.join(bin_dir, bin) + + # Skip script files, only actual executables need patching. + with open(bin_file, "rb", buffering=0) as f: + if f.read(2) == b"#!": + continue + + self.fix_bin_or_dylib(bin_file) + lib_dir = "{}/lib".format(bin_root) for lib in os.listdir(lib_dir): if lib.endswith(".so"):