Skip to content

Commit 32eed1c

Browse files
committed
Make backend switchable
1 parent 859a77c commit 32eed1c

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
936936
options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
937937
build_debugging_options, "Z", "debugging",
938938
DB_OPTIONS, db_type_desc, dbsetters,
939+
trans: Option<String> = (None, parse_opt_string, [TRACKED],
940+
"the backend to use"),
939941
verbose: bool = (false, parse_bool, [UNTRACKED],
940942
"in general, enable more debug printouts"),
941943
span_free_formats: bool = (false, parse_bool, [UNTRACKED],

src/librustc_driver/lib.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -238,25 +238,32 @@ pub fn run_compiler<'a>(args: &[String],
238238
target_features::add_configuration(&mut cfg, &sess);
239239
sess.parse_sess.config = cfg;
240240

241-
let cstore = Rc::new(CStore::new(DefaultTransCrate::metadata_loader()));
242-
243-
do_or_return!(callbacks.late_callback(&matches,
244-
&sess,
245-
&*cstore,
246-
&input,
247-
&odir,
248-
&ofile), Some(sess));
249-
250241
let plugins = sess.opts.debugging_opts.extra_plugins.clone();
251242
let control = callbacks.build_controller(&sess, &matches);
252-
(driver::compile_input::<DefaultTransCrate>(&sess,
253-
&cstore,
254-
&input,
255-
&odir,
256-
&ofile,
257-
Some(plugins),
258-
&control),
259-
Some(sess))
243+
244+
let trans_name = sess.opts.debugging_opts.trans.unwrap_or_else(||"llvm".to_string());
245+
match *trans_name {
246+
"llvm" => {
247+
let cstore = Rc::new(CStore::new(DefaultTransCrate::metadata_loader()));
248+
249+
do_or_return!(callbacks.late_callback(&matches,
250+
&sess,
251+
&*cstore,
252+
&input,
253+
&odir,
254+
&ofile), Some(sess));
255+
256+
(driver::compile_input::<DefaultTransCrate>(&sess,
257+
&cstore,
258+
&input,
259+
&odir,
260+
&ofile,
261+
Some(plugins),
262+
&control),
263+
Some(sess))
264+
}
265+
_ => sess.fatal(&format!("Invalid trans {}", trans_name)),
266+
}
260267
}
261268

262269
// Extract output directory and file from matches.

0 commit comments

Comments
 (0)