Skip to content

Commit 54f0668

Browse files
committed
Add -Z no-parallel-llvm flag
Codegen issues commonly only manifest under specific circumstances, e.g. if multiple codegen units are used and ThinLTO is enabled. However, these configuration are threaded, making the use of LLVM debugging facilities hard, as output is interleaved. This patch adds a -Z no-parallel-llvm flag, which allows disabling parallelization of codegen and linking, while otherwise preserving behavior with regard to codegen units and LTO.
1 parent 9f80ea3 commit 54f0668

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13371337
"enable the experimental Chalk-based trait solving engine"),
13381338
cross_lang_lto: CrossLangLto = (CrossLangLto::Disabled, parse_cross_lang_lto, [TRACKED],
13391339
"generate build artifacts that are compatible with linker-based LTO."),
1340+
no_parallel_llvm: bool = (false, parse_bool, [UNTRACKED],
1341+
"don't run LLVM in parallel (while keeping codegen-units and ThinLTO)"),
13401342
}
13411343

13421344
pub fn default_lib_output() -> CrateType {

src/librustc_codegen_llvm/back/write.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,9 @@ fn start_executing_work(tcx: TyCtxt,
17381738
.binary_search_by_key(&cost, |&(_, cost)| cost)
17391739
.unwrap_or_else(|e| e);
17401740
work_items.insert(insertion_index, (work, cost));
1741-
helper.request_token();
1741+
if !cgcx.opts.debugging_opts.no_parallel_llvm {
1742+
helper.request_token();
1743+
}
17421744
}
17431745
}
17441746

@@ -1842,7 +1844,9 @@ fn start_executing_work(tcx: TyCtxt,
18421844
};
18431845
work_items.insert(insertion_index, (llvm_work_item, cost));
18441846

1845-
helper.request_token();
1847+
if !cgcx.opts.debugging_opts.no_parallel_llvm {
1848+
helper.request_token();
1849+
}
18461850
assert_eq!(main_thread_worker_state,
18471851
MainThreadWorkerState::Codegenning);
18481852
main_thread_worker_state = MainThreadWorkerState::Idle;

0 commit comments

Comments
 (0)