Skip to content

Commit 98b943e

Browse files
committed
Add partitioning -Z option to control which partitioning scheme is used
1 parent 5d501f9 commit 98b943e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/librustc_mir/monomorphize/partitioning/mod.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,16 @@ trait Partitioner<'tcx> {
135135
);
136136
}
137137

138-
fn get_partitioner<'tcx>() -> Box<dyn Partitioner<'tcx>> {
139-
Box::new(default::DefaultPartitioning)
138+
fn get_partitioner<'tcx>(tcx: TyCtxt<'tcx>) -> Box<dyn Partitioner<'tcx>> {
139+
let strategy = match &tcx.sess.opts.debugging_opts.cgu_partitioning_strategy {
140+
None => "default",
141+
Some(s) => &s[..],
142+
};
143+
144+
match strategy {
145+
"default" => Box::new(default::DefaultPartitioning),
146+
_ => tcx.sess.fatal("unknown partitioning strategy"),
147+
}
140148
}
141149

142150
pub fn partition<'tcx>(
@@ -147,7 +155,7 @@ pub fn partition<'tcx>(
147155
) -> Vec<CodegenUnit<'tcx>> {
148156
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning");
149157

150-
let mut partitioner = get_partitioner();
158+
let mut partitioner = get_partitioner(tcx);
151159
// In the first step, we place all regular monomorphizations into their
152160
// respective 'home' codegen unit. Regular monomorphizations are all
153161
// functions and statics defined in the local crate.

src/librustc_session/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
807807
"select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
808808
borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
809809
"gather borrowck statistics (default: no)"),
810+
cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
811+
"the codegen unit partitioning strategy to use"),
810812
chalk: bool = (false, parse_bool, [TRACKED],
811813
"enable the experimental Chalk-based trait solving engine"),
812814
codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],

0 commit comments

Comments
 (0)