Skip to content

Commit 3272b00

Browse files
committed
auto merge of #10979 : alexcrichton/rust/less-bc, r=cmr
By performing this logic very late in the build process, it ended up leading to bugs like those found in #10973 where certain stages of the build process expected a particular output format which didn't end up being the case. In order to fix this, the build output generation is moved very early in the build process to the absolute first thing in phase 2. Closes #10973
2 parents fe85856 + 6ebacf2 commit 3272b00

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

src/librustc/back/link.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -728,17 +728,10 @@ pub fn link_binary(sess: Session,
728728
obj_filename: &Path,
729729
out_filename: &Path,
730730
lm: &LinkMeta) -> ~[Path] {
731-
// If we're generating a test executable, then ignore all other output
732-
// styles at all other locations
733-
let outputs = if sess.opts.test {
734-
~[session::OutputExecutable]
735-
} else {
736-
(*sess.outputs).clone()
737-
};
738-
739731
let mut out_filenames = ~[];
740-
for output in outputs.move_iter() {
741-
let out_file = link_binary_output(sess, trans, output, obj_filename, out_filename, lm);
732+
for &output in sess.outputs.iter() {
733+
let out_file = link_binary_output(sess, trans, output, obj_filename,
734+
out_filename, lm);
742735
out_filenames.push(out_file);
743736
}
744737

src/librustc/driver/session.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,20 +405,25 @@ pub fn expect<T:Clone>(sess: Session, opt: Option<T>, msg: || -> ~str) -> T {
405405
}
406406

407407
pub fn building_library(options: &options, crate: &ast::Crate) -> bool {
408+
if options.test { return false }
408409
for output in options.outputs.iter() {
409410
match *output {
410411
OutputExecutable => {}
411412
OutputStaticlib | OutputDylib | OutputRlib => return true
412413
}
413414
}
414-
if options.test { return false }
415415
match syntax::attr::first_attr_value_str_by_name(crate.attrs, "crate_type") {
416416
Some(s) => "lib" == s || "rlib" == s || "dylib" == s || "staticlib" == s,
417417
_ => false
418418
}
419419
}
420420

421421
pub fn collect_outputs(options: &options, crate: &ast::Crate) -> ~[OutputStyle] {
422+
// If we're generating a test executable, then ignore all other output
423+
// styles at all other locations
424+
if options.test {
425+
return ~[OutputExecutable];
426+
}
422427
let mut base = options.outputs.clone();
423428
let mut iter = crate.attrs.iter().filter_map(|a| {
424429
if "crate_type" == a.name() {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Regression test for issue #10973
2+
3+
-include ../tools.mk
4+
5+
all:
6+
$(RUSTC) --rlib --test foo.rs
7+
rm $(TMPDIR)/foo.bc && exit 1 || exit 0

src/test/run-make/no-intermediate-extras/foo.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)