Skip to content

Commit 8ad7c34

Browse files
committed
Auto merge of #46564 - Zoxc:rayon-queries, r=<try>
WIP: Parallelize passes using rayon This builds on #46193 and #45912 and actually makes code run in parallel. This is not quite ready yet since `rustc` is not yet completely thread safe. It also uses a rough fork of rayon which uses fibers/stackful coroutines.
2 parents 2537a49 + 26a0515 commit 8ad7c34

File tree

160 files changed

+3858
-2408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+3858
-2408
lines changed

src/Cargo.lock

+309-107
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/bin/rustc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ fn main() {
262262
}
263263
}
264264

265+
if env::var_os("RUSTC_PARALLEL_QUERIES").is_some() {
266+
cmd.arg("--cfg").arg("parallel_queries");
267+
}
268+
265269
let color = match env::var("RUSTC_COLOR") {
266270
Ok(s) => usize::from_str(&s).expect("RUSTC_COLOR should be an integer"),
267271
Err(_) => 0,

src/bootstrap/compile.rs

+3
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ pub fn rustc_cargo(build: &Build,
561561
if let Some(ref s) = build.config.rustc_default_linker {
562562
cargo.env("CFG_DEFAULT_LINKER", s);
563563
}
564+
if build.config.rustc_parallel_queries {
565+
cargo.env("RUSTC_PARALLEL_QUERIES", "1");
566+
}
564567
}
565568

566569
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub struct Config {
8787
pub rust_debuginfo_lines: bool,
8888
pub rust_debuginfo_only_std: bool,
8989
pub rust_rpath: bool,
90+
pub rustc_parallel_queries: bool,
9091
pub rustc_default_linker: Option<String>,
9192
pub rust_optimize_tests: bool,
9293
pub rust_debuginfo_tests: bool,
@@ -266,6 +267,7 @@ struct Rust {
266267
debuginfo: Option<bool>,
267268
debuginfo_lines: Option<bool>,
268269
debuginfo_only_std: Option<bool>,
270+
experimental_parallel_queries: Option<bool>,
269271
debug_jemalloc: Option<bool>,
270272
use_jemalloc: Option<bool>,
271273
backtrace: Option<bool>,
@@ -474,6 +476,7 @@ impl Config {
474476
set(&mut config.rust_dist_src, rust.dist_src);
475477
set(&mut config.quiet_tests, rust.quiet_tests);
476478
set(&mut config.test_miri, rust.test_miri);
479+
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
477480
config.rustc_default_linker = rust.default_linker.clone();
478481
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
479482
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);

src/bootstrap/job.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ pub unsafe fn setup(build: &mut Build) {
126126
// during startup or terminating abnormally). This is important for running tests,
127127
// since some of them use abnormal termination by design.
128128
// This mode is inherited by all child processes.
129-
let mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); // read inherited flags
130-
SetErrorMode(mode | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
129+
//let mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); // read inherited flags
130+
SetErrorMode(0);
131131

132132
// Create a new job object for us to use
133133
let job = CreateJobObjectW(0 as *mut _, 0 as *const _);

src/libarena/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ version = "0.0.0"
77
name = "arena"
88
path = "lib.rs"
99
crate-type = ["dylib"]
10+
11+
[dependencies]
12+
rustc_data_structures = { path = "../librustc_data_structures" }

0 commit comments

Comments
 (0)