about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-04-30 20:37:05 +0100
committervarkor <github@varkor.com>2019-05-02 21:47:14 +0100
commite5828d4dc023e337b0ad7cc43dd173fc407c9123 (patch)
treeac91ca57fa5b6b504bf8a5761bbb059b13d94f77
parent08bfe16129b0621bc90184f8704523d4929695ef (diff)
downloadrust-e5828d4dc023e337b0ad7cc43dd173fc407c9123.tar.gz
rust-e5828d4dc023e337b0ad7cc43dd173fc407c9123.zip
Prevent dependencies between std/test/rustc unifying with each other
-rw-r--r--src/bootstrap/builder.rs24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 522466314d6..c84eb6476e0 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -853,14 +853,30 @@ impl<'a> Builder<'a> {
 
         // FIXME: Temporary fix for https://github.com/rust-lang/cargo/issues/3005
         // Force cargo to output binaries with disambiguating hashes in the name
-        let metadata = if compiler.stage == 0 {
-            // Treat stage0 like special channel, whether it's a normal prior-
+        let mut metadata = if compiler.stage == 0 {
+            // Treat stage0 like a special channel, whether it's a normal prior-
             // release rustc or a local rebuild with the same version, so we
             // never mix these libraries by accident.
-            "bootstrap"
+            "bootstrap".to_string()
         } else {
-            &self.config.channel
+            self.config.channel.to_string()
         };
+        // We want to make sure that none of the dependencies between
+        // std/test/rustc unify with one another. This is done for weird linkage
+        // reasons but the gist of the problem is that if librustc, libtest, and
+        // libstd all depend on libc from crates.io (which they actually do) we
+        // want to make sure they all get distinct versions. Things get really
+        // weird if we try to unify all these dependencies right now, namely
+        // around how many times the library is linked in dynamic libraries and
+        // such. If rustc were a static executable or if we didn't ship dylibs
+        // this wouldn't be a problem, but we do, so it is. This is in general
+        // just here to make sure things build right. If you can remove this and
+        // things still build right, please do!
+        match mode {
+            Mode::Std => metadata.push_str("std"),
+            Mode::Test => metadata.push_str("test"),
+            _ => {},
+        }
         cargo.env("__CARGO_DEFAULT_LIB_METADATA", &metadata);
 
         let stage;