@@ -183,6 +183,7 @@ struct Crate {
183
183
deps : HashSet < String > ,
184
184
path : PathBuf ,
185
185
has_lib : bool ,
186
+ features : Vec < String > ,
186
187
}
187
188
188
189
impl Crate {
@@ -666,16 +667,25 @@ impl Build {
666
667
}
667
668
668
669
/// Gets the space-separated set of activated features for the compiler.
669
- fn rustc_features ( & self , kind : Kind , target : TargetSelection ) -> String {
670
+ fn rustc_features ( & self , kind : Kind , target : TargetSelection , crates : & [ String ] ) -> String {
671
+ let possible_features_by_crates: HashSet < _ > = crates
672
+ . iter ( )
673
+ . flat_map ( |krate| & self . crates [ krate] . features )
674
+ . map ( std:: ops:: Deref :: deref)
675
+ . collect ( ) ;
670
676
let mut features = vec ! [ ] ;
671
- if self . config . jemalloc {
677
+ if self . config . jemalloc && possible_features_by_crates . contains ( "jemalloc" ) {
672
678
features. push ( "jemalloc" ) ;
673
679
}
674
- if self . config . llvm_enabled ( target) || kind == Kind :: Check {
680
+ if ( self . config . llvm_enabled ( target) || kind == Kind :: Check )
681
+ && possible_features_by_crates. contains ( "llvm" )
682
+ {
675
683
features. push ( "llvm" ) ;
676
684
}
677
685
// keep in sync with `bootstrap/compile.rs:rustc_cargo_env`
678
- if self . config . rustc_parallel {
686
+ if self . config . rustc_parallel
687
+ && possible_features_by_crates. contains ( "rustc_use_parallel_compiler" )
688
+ {
679
689
features. push ( "rustc_use_parallel_compiler" ) ;
680
690
}
681
691
@@ -684,7 +694,8 @@ impl Build {
684
694
// which is everything (including debug/trace/etc.)
685
695
// if its unset, if debug_assertions is on, then debug_logging will also be on
686
696
// as well as tracing *ignoring* this feature when debug_assertions is on
687
- if !self . config . rust_debug_logging {
697
+ if !self . config . rust_debug_logging && possible_features_by_crates. contains ( "max_level_info" )
698
+ {
688
699
features. push ( "max_level_info" ) ;
689
700
}
690
701
0 commit comments