@@ -475,12 +475,30 @@ impl Build {
475
475
. env ( "RUSTDOC_REAL" , self . rustdoc ( compiler) )
476
476
. env ( "RUSTC_FLAGS" , self . rustc_flags ( target) . join ( " " ) ) ;
477
477
478
- // Tools don't get debuginfo right now, e.g. cargo and rls don't get
479
- // compiled with debuginfo.
480
478
if mode != Mode :: Tool {
481
- cargo. env ( "RUSTC_DEBUGINFO" , self . config . rust_debuginfo . to_string ( ) )
482
- . env ( "RUSTC_DEBUGINFO_LINES" , self . config . rust_debuginfo_lines . to_string ( ) )
483
- . env ( "RUSTC_FORCE_UNSTABLE" , "1" ) ;
479
+ // Tools don't get debuginfo right now, e.g. cargo and rls don't
480
+ // get compiled with debuginfo.
481
+ cargo. env ( "RUSTC_DEBUGINFO" , self . config . rust_debuginfo . to_string ( ) )
482
+ . env ( "RUSTC_DEBUGINFO_LINES" , self . config . rust_debuginfo_lines . to_string ( ) )
483
+ . env ( "RUSTC_FORCE_UNSTABLE" , "1" ) ;
484
+
485
+ // Currently the compiler depends on crates from crates.io, and
486
+ // then other crates can depend on the compiler (e.g. proc-macro
487
+ // crates). Let's say, for example that rustc itself depends on the
488
+ // bitflags crate. If an external crate then depends on the
489
+ // bitflags crate as well, we need to make sure they don't
490
+ // conflict, even if they pick the same verison of bitflags. We'll
491
+ // want to make sure that e.g. a plugin and rustc each get their
492
+ // own copy of bitflags.
493
+
494
+ // Cargo ensures that this works in general through the -C metadata
495
+ // flag. This flag will frob the symbols in the binary to make sure
496
+ // they're different, even though the source code is the exact
497
+ // same. To solve this problem for the compiler we extend Cargo's
498
+ // already-passed -C metadata flag with our own. Our rustc.rs
499
+ // wrapper around the actual rustc will detect -C metadata being
500
+ // passed and frob it with this extra string we're passing in.
501
+ cargo. env ( "RUSTC_METADATA_SUFFIX" , "rustc" ) ;
484
502
}
485
503
486
504
// Enable usage of unstable features
0 commit comments