Skip to content

Commit 008fc79

Browse files
committed
Propagate parallel_compiler feature through rustc crates. Turned off feature gives change of builded crates: 238 -> 224.
1 parent 78fbcca commit 008fc79

File tree

9 files changed

+36
-14
lines changed

9 files changed

+36
-14
lines changed

compiler/rustc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ features = ['unprefixed_malloc_on_supported_platforms']
1919
jemalloc = ['tikv-jemalloc-sys']
2020
llvm = ['rustc_driver/llvm']
2121
max_level_info = ['rustc_driver/max_level_info']
22+
rustc_use_parallel_compiler = ['rustc_driver/rustc_use_parallel_compiler']

compiler/rustc_data_structures/Cargo.toml

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ doctest = false
99
[dependencies]
1010
arrayvec = { version = "0.7", default-features = false }
1111
ena = "0.14"
12-
indexmap = { version = "1.8.0", features = ["rustc-rayon"] }
12+
indexmap = { version = "1.8.0" }
1313
tracing = "0.1"
1414
jobserver_crate = { version = "0.1.13", package = "jobserver" }
1515
rustc_serialize = { path = "../rustc_serialize" }
1616
rustc_macros = { path = "../rustc_macros" }
1717
rustc_graphviz = { path = "../rustc_graphviz" }
1818
cfg-if = "0.1.2"
1919
stable_deref_trait = "1.0.0"
20-
rayon = { version = "0.3.2", package = "rustc-rayon" }
21-
rayon-core = { version = "0.3.2", package = "rustc-rayon-core" }
20+
rayon = { version = "0.3.2", package = "rustc-rayon", optional = true }
21+
rayon-core = { version = "0.3.2", package = "rustc-rayon-core", optional = true }
2222
rustc-hash = "1.1.0"
2323
smallvec = { version = "1.6.1", features = ["const_generics", "union", "may_dangle"] }
2424
rustc_index = { path = "../rustc_index", package = "rustc_index" }
@@ -36,3 +36,6 @@ winapi = { version = "0.3", features = ["fileapi", "psapi", "winerror"] }
3636

3737
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
3838
memmap2 = "0.2.1"
39+
40+
[features]
41+
rustc_use_parallel_compiler = ["indexmap/rustc-rayon", "rayon", "rayon-core"]

compiler/rustc_driver/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ winapi = { version = "0.3", features = ["consoleapi", "debugapi", "processenv"]
3939
[features]
4040
llvm = ['rustc_interface/llvm']
4141
max_level_info = ['rustc_log/max_level_info']
42+
rustc_use_parallel_compiler = ['rustc_data_structures/rustc_use_parallel_compiler', 'rustc_interface/rustc_use_parallel_compiler',
43+
'rustc_middle/rustc_use_parallel_compiler']

compiler/rustc_interface/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ doctest = false
1010
libc = "0.2"
1111
libloading = "0.7.1"
1212
tracing = "0.1"
13-
rustc-rayon-core = "0.3.2"
14-
rayon = { version = "0.3.2", package = "rustc-rayon" }
13+
rustc-rayon-core = { version = "0.3.2", optional = true }
14+
rayon = { version = "0.3.2", package = "rustc-rayon", optional = true }
1515
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
1616
rustc_ast = { path = "../rustc_ast" }
1717
rustc_attr = { path = "../rustc_attr" }
@@ -57,3 +57,4 @@ rustc_target = { path = "../rustc_target" }
5757

5858
[features]
5959
llvm = ['rustc_codegen_llvm']
60+
rustc_use_parallel_compiler = ['rayon', 'rustc-rayon-core', 'rustc_query_impl/rustc_use_parallel_compiler']

compiler/rustc_middle/Cargo.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ bitflags = "1.2.1"
1212
either = "1.5.0"
1313
gsgdt = "0.1.2"
1414
tracing = "0.1"
15-
rustc-rayon = "0.3.2"
16-
rustc-rayon-core = "0.3.2"
15+
rustc-rayon = { version = "0.3.2", optional = true }
16+
rustc-rayon-core = { version = "0.3.2", optional = true }
1717
polonius-engine = "0.13.0"
1818
rustc_apfloat = { path = "../rustc_apfloat" }
1919
rustc_attr = { path = "../rustc_attr" }
@@ -35,3 +35,6 @@ rustc_session = { path = "../rustc_session" }
3535
rustc_type_ir = { path = "../rustc_type_ir" }
3636
rand = "0.8.4"
3737
rand_xoshiro = "0.6.0"
38+
39+
[features]
40+
rustc_use_parallel_compiler = ["rustc-rayon", "rustc-rayon-core"]

compiler/rustc_query_impl/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ doctest = false
88

99
[dependencies]
1010
measureme = "10.0.0"
11-
rustc-rayon-core = "0.3.2"
11+
rustc-rayon-core = { version = "0.3.2", optional = true }
1212
rustc_ast = { path = "../rustc_ast" }
1313
rustc_data_structures = { path = "../rustc_data_structures" }
1414
rustc_errors = { path = "../rustc_errors" }
@@ -20,3 +20,6 @@ rustc_query_system = { path = "../rustc_query_system" }
2020
rustc_serialize = { path = "../rustc_serialize" }
2121
rustc_session = { path = "../rustc_session" }
2222
rustc_span = { path = "../rustc_span" }
23+
24+
[features]
25+
rustc_use_parallel_compiler = ["rustc-rayon-core", "rustc_query_system/rustc_use_parallel_compiler"]

compiler/rustc_query_system/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ doctest = false
99
[dependencies]
1010
rustc_arena = { path = "../rustc_arena" }
1111
tracing = "0.1"
12-
rustc-rayon-core = "0.3.2"
12+
rustc-rayon-core = { version = "0.3.2", optional = true }
1313
rustc_ast = { path = "../rustc_ast" }
1414
rustc_data_structures = { path = "../rustc_data_structures" }
1515
rustc_errors = { path = "../rustc_errors" }
@@ -23,3 +23,6 @@ rustc_span = { path = "../rustc_span" }
2323
rustc_target = { path = "../rustc_target" }
2424
parking_lot = "0.11"
2525
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
26+
27+
[features]
28+
rustc_use_parallel_compiler = ["rustc-rayon-core"]

src/bootstrap/compile.rs

+2
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
689689
}
690690

691691
if builder.config.rustc_parallel {
692+
// keep in sync with `bootstrap/lib.rs:Build::rustc_features`
693+
// `cfg` option for rustc, `features` option for cargo, for conditional compilation
692694
cargo.rustflag("--cfg=parallel_compiler");
693695
cargo.rustdocflag("--cfg=parallel_compiler");
694696
}

src/bootstrap/lib.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -729,12 +729,16 @@ impl Build {
729729

730730
/// Gets the space-separated set of activated features for the compiler.
731731
fn rustc_features(&self, kind: Kind) -> String {
732-
let mut features = String::new();
732+
let mut features = vec![];
733733
if self.config.jemalloc {
734-
features.push_str("jemalloc");
734+
features.push("jemalloc");
735735
}
736736
if self.config.llvm_enabled() || kind == Kind::Check {
737-
features.push_str(" llvm");
737+
features.push("llvm");
738+
}
739+
// keep in sync with `bootstrap/compile.rs:rustc_cargo_env`
740+
if self.config.rustc_parallel {
741+
features.push("rustc_use_parallel_compiler");
738742
}
739743

740744
// If debug logging is on, then we want the default for tracing:
@@ -743,10 +747,10 @@ impl Build {
743747
// if its unset, if debug_assertions is on, then debug_logging will also be on
744748
// as well as tracing *ignoring* this feature when debug_assertions is on
745749
if !self.config.rust_debug_logging {
746-
features.push_str(" max_level_info");
750+
features.push("max_level_info");
747751
}
748752

749-
features
753+
features.join(" ")
750754
}
751755

752756
/// Component directory that Cargo will produce output into (e.g.

0 commit comments

Comments
 (0)