Skip to content

Commit 6ebacf2

Browse files
committed
Move logic for test output generation forward
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
1 parent f73c9c9 commit 6ebacf2

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
@@ -722,17 +722,10 @@ pub fn link_binary(sess: Session,
722722
obj_filename: &Path,
723723
out_filename: &Path,
724724
lm: &LinkMeta) -> ~[Path] {
725-
// If we're generating a test executable, then ignore all other output
726-
// styles at all other locations
727-
let outputs = if sess.opts.test {
728-
~[session::OutputExecutable]
729-
} else {
730-
(*sess.outputs).clone()
731-
};
732-
733725
let mut out_filenames = ~[];
734-
for output in outputs.move_iter() {
735-
let out_file = link_binary_output(sess, trans, output, obj_filename, out_filename, lm);
726+
for &output in sess.outputs.iter() {
727+
let out_file = link_binary_output(sess, trans, output, obj_filename,
728+
out_filename, lm);
736729
out_filenames.push(out_file);
737730
}
738731

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)