@@ -853,14 +853,30 @@ impl<'a> Builder<'a> {
853853
854854 // FIXME: Temporary fix for https://github.com/rust-lang/cargo/issues/3005
855855 // Force cargo to output binaries with disambiguating hashes in the name
856- let metadata = if compiler. stage == 0 {
857- // Treat stage0 like special channel, whether it's a normal prior-
856+ let mut metadata = if compiler. stage == 0 {
857+ // Treat stage0 like a special channel, whether it's a normal prior-
858858 // release rustc or a local rebuild with the same version, so we
859859 // never mix these libraries by accident.
860- "bootstrap"
860+ "bootstrap" . to_string ( )
861861 } else {
862- & self . config . channel
862+ self . config . channel . to_string ( )
863863 } ;
864+ // We want to make sure that none of the dependencies between
865+ // std/test/rustc unify with one another. This is done for weird linkage
866+ // reasons but the gist of the problem is that if librustc, libtest, and
867+ // libstd all depend on libc from crates.io (which they actually do) we
868+ // want to make sure they all get distinct versions. Things get really
869+ // weird if we try to unify all these dependencies right now, namely
870+ // around how many times the library is linked in dynamic libraries and
871+ // such. If rustc were a static executable or if we didn't ship dylibs
872+ // this wouldn't be a problem, but we do, so it is. This is in general
873+ // just here to make sure things build right. If you can remove this and
874+ // things still build right, please do!
875+ match mode {
876+ Mode :: Std => metadata. push_str ( "std" ) ,
877+ Mode :: Test => metadata. push_str ( "test" ) ,
878+ _ => { } ,
879+ }
864880 cargo. env ( "__CARGO_DEFAULT_LIB_METADATA" , & metadata) ;
865881
866882 let stage;
0 commit comments