Skip to content

Commit 6156295

Browse files
committed
rustc: Move linking into compile_input
1 parent fd81fb6 commit 6156295

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/comp/driver/rustc.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,13 @@ fn inject_libcore_reference(sess: session::session,
131131

132132

133133
fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
134-
output: str) {
134+
output: option::t<str>) {
135+
135136
let time_passes = sess.get_opts().time_passes;
136137
let crate =
137138
time(time_passes, "parsing", bind parse_input(sess, cfg, input));
138139
if sess.get_opts().parse_only { ret; }
140+
139141
crate =
140142
time(time_passes, "configuration",
141143
bind front::config::strip_unconfigured_items(crate));
@@ -186,12 +188,26 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
186188
time(time_passes, "kind checking",
187189
bind kind::check_crate(ty_cx, last_uses, crate));
188190
if sess.get_opts().no_trans { ret; }
191+
192+
let outputs = build_output_filenames(input, output, sess);
193+
189194
let llmod =
190195
time(time_passes, "translation",
191-
bind trans::trans_crate(sess, crate, ty_cx, output, ast_map,
196+
bind trans::trans_crate(sess, crate, ty_cx,
197+
outputs.obj_filename, ast_map,
192198
mut_map, copy_map, last_uses));
193199
time(time_passes, "LLVM passes",
194-
bind link::write::run_passes(sess, llmod, output));
200+
bind link::write::run_passes(sess, llmod, outputs.obj_filename));
201+
202+
let stop_after_codegen =
203+
sess.get_opts().output_type != link::output_type_exe ||
204+
sess.get_opts().static && sess.building_library();
205+
206+
if stop_after_codegen { ret; }
207+
208+
time(time_passes, "Linking",
209+
bind link::link_binary(sess, outputs.obj_filename,
210+
outputs.out_filename));
195211
}
196212

197213
fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
@@ -604,19 +620,7 @@ fn main(args: [str]) {
604620
ret;
605621
}
606622

607-
let outputs = build_output_filenames(ifile, ofile, sess);
608-
609-
let stop_after_codegen =
610-
sopts.output_type != link::output_type_exe ||
611-
sopts.static && sess.building_library();
612-
613-
let temp_filename = outputs.obj_filename;
614-
615-
compile_input(sess, cfg, ifile, temp_filename);
616-
617-
if stop_after_codegen { ret; }
618-
619-
link::link_binary(sess, temp_filename, outputs.out_filename);
623+
compile_input(sess, cfg, ifile, ofile);
620624
}
621625

622626
#[cfg(test)]

0 commit comments

Comments
 (0)