From 4f87987e3f361a7d38bdf59d6542ba621f100c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Sat, 15 Feb 2025 02:30:24 +0800 Subject: [PATCH] bootstrap: build compiler libs with version number of libs being built Previously, on a non-stable channel, it's possible for two builds from different versioned sources (e.g. 1.84.0 vs 1.84.1) to produce `librustc_driver*.so` with the same filename hashes. This causes problems with side-by-side installs wrt. linker search paths because 1.84.1 rustc bin and 1.84.0 may try to link to the "same" `librustc_driver*.so` (same filename hash) but fail because the contents of the so is actually different. We try to mitigate this by including the version number of artifacts being built via `__CARGO_DEFAULT_LIB_METADATA`. --- src/bootstrap/src/core/builder/cargo.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 59680af00622f..5064a83159e81 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -779,6 +779,12 @@ impl Builder<'_> { Mode::Codegen => metadata.push_str("codegen"), _ => {} } + // `rustc_driver`'s version number is always `0.0.0`, which can cause linker search path + // problems on side-by-side installs because we don't include the version number of the + // `rustc_driver` being built. This can cause builds of different version numbers to produce + // `librustc_driver*.so` artifacts that end up with identical filename hashes. + metadata.push_str(&self.version); + cargo.env("__CARGO_DEFAULT_LIB_METADATA", &metadata); if cmd_kind == Kind::Clippy {