diff --git a/var/spack/repos/builtin/packages/rust-bootstrap/package.py b/var/spack/repos/builtin/packages/rust-bootstrap/package.py index 73d6de12235159..1603c9e853b383 100644 --- a/var/spack/repos/builtin/packages/rust-bootstrap/package.py +++ b/var/spack/repos/builtin/packages/rust-bootstrap/package.py @@ -133,6 +133,12 @@ class RustBootstrap(Package): if os in rust_releases[release] and target in rust_releases[release][os]: version(release, sha256=rust_releases[release][os][target]) + # rust-ldd and libLLVM both depend on zlib, which is not vendored. + depends_on("zlib-api") + depends_on("zlib-ng +shared", when="^[virtuals=zlib-api] zlib-ng") + depends_on("zlib +shared", when="^[virtuals=zlib-api] zlib") + depends_on("patchelf@0.13:", when="platform=linux", type="build") + def url_for_version(self, version): if self.os not in ("linux", "darwin"): return None @@ -151,6 +157,15 @@ def url_for_version(self, version): url = "https://static.rust-lang.org/dist/rust-{0}-{1}-{2}.tar.gz" return url.format(version, target, os) + @run_before("install", when="platform=linux") + def fixup_rpaths(self): + # set rpaths of libLLVM.so and rust-ldd to zlib's lib directory + rpaths = self.spec["zlib-api"].libs.directories + + for binary in find(self.stage.source_path, ["libLLVM.so.*", "rust-lld"]): + patchelf = Executable("patchelf") + patchelf("--add-rpath", ":".join(rpaths), binary) + def install(self, spec, prefix): install_script = Executable("./install.sh") install_args = [f"--prefix={prefix}", "--without=rust-docs"]