about summary refs log tree commit diff
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2025-02-15 02:30:24 +0800
committer许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2025-02-15 19:31:15 +0800
commit4f87987e3f361a7d38bdf59d6542ba621f100c9e (patch)
tree2b296c2f8a407077976b13ac486293a1bf9009c3
parentf77247ac59b29ce927f4d2cd1c26a4b2d1d358c9 (diff)
downloadrust-4f87987e3f361a7d38bdf59d6542ba621f100c9e.tar.gz
rust-4f87987e3f361a7d38bdf59d6542ba621f100c9e.zip
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`.
-rw-r--r--src/bootstrap/src/core/builder/cargo.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs
index 59680af0062..5064a83159e 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 {