Make ./x.py <cmd> compiler/<crate> aware of the crate's features · rust-lang/rust@39e3add (original) (raw)

`@@ -183,6 +183,7 @@ struct Crate {

`

183

183

`deps: HashSet,

`

184

184

`path: PathBuf,

`

185

185

`has_lib: bool,

`

``

186

`+

features: Vec,

`

186

187

`}

`

187

188

``

188

189

`impl Crate {

`

`@@ -666,16 +667,24 @@ 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();

`

``

676

`+

let check = |feature: &str| -> bool {

`

``

677

`+

crates.is_empty() || possible_features_by_crates.contains(feature)

`

``

678

`+

};

`

670

679

`let mut features = vec![];

`

671

``

`-

if self.config.jemalloc {

`

``

680

`+

if self.config.jemalloc && check("jemalloc") {

`

672

681

` features.push("jemalloc");

`

673

682

`}

`

674

``

`-

if self.config.llvm_enabled(target) || kind == Kind::Check {

`

``

683

`+

if (self.config.llvm_enabled(target) || kind == Kind::Check) && check("llvm") {

`

675

684

` features.push("llvm");

`

676

685

`}

`

677

686

`` // keep in sync with bootstrap/compile.rs:rustc_cargo_env

``

678

``

`-

if self.config.rustc_parallel {

`

``

687

`+

if self.config.rustc_parallel && check("rustc_use_parallel_compiler") {

`

679

688

` features.push("rustc_use_parallel_compiler");

`

680

689

`}

`

681

690

``

`@@ -684,7 +693,7 @@ impl Build {

`

684

693

`// which is everything (including debug/trace/etc.)

`

685

694

`// if its unset, if debug_assertions is on, then debug_logging will also be on

`

686

695

`// as well as tracing ignoring this feature when debug_assertions is on

`

687

``

`-

if !self.config.rust_debug_logging {

`

``

696

`+

if !self.config.rust_debug_logging && check("max_level_info") {

`

688

697

` features.push("max_level_info");

`

689

698

`}

`

690

699

``