about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-12-14 23:11:13 -0800
committerAlex Crichton <alex@alexcrichton.com>2013-12-15 22:36:44 -0800
commit6ebacf2fd77b4a7a688aeebd5f6fcc422e230635 (patch)
tree396149cc4beccc5691cb5ad7e7bdf3e047e46218
parentf73c9c9bbcaf1595f766ad8bb01e21c78fcba84b (diff)
downloadrust-6ebacf2fd77b4a7a688aeebd5f6fcc422e230635.tar.gz
rust-6ebacf2fd77b4a7a688aeebd5f6fcc422e230635.zip
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
-rw-r--r--src/librustc/back/link.rs13
-rw-r--r--src/librustc/driver/session.rs7
-rw-r--r--src/test/run-make/no-intermediate-extras/Makefile7
-rw-r--r--src/test/run-make/no-intermediate-extras/foo.rs0
4 files changed, 16 insertions, 11 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index 91680f5c2e5..badc0507a43 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -722,17 +722,10 @@ pub fn link_binary(sess: Session,
                    obj_filename: &Path,
                    out_filename: &Path,
                    lm: &LinkMeta) -> ~[Path] {
-    // If we're generating a test executable, then ignore all other output
-    // styles at all other locations
-    let outputs = if sess.opts.test {
-        ~[session::OutputExecutable]
-    } else {
-        (*sess.outputs).clone()
-    };
-
     let mut out_filenames = ~[];
-    for output in outputs.move_iter() {
-        let out_file = link_binary_output(sess, trans, output, obj_filename, out_filename, lm);
+    for &output in sess.outputs.iter() {
+        let out_file = link_binary_output(sess, trans, output, obj_filename,
+                                          out_filename, lm);
         out_filenames.push(out_file);
     }
 
diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs
index 00f39138f58..78b59f49341 100644
--- a/src/librustc/driver/session.rs
+++ b/src/librustc/driver/session.rs
@@ -405,13 +405,13 @@ pub fn expect<T:Clone>(sess: Session, opt: Option<T>, msg: || -> ~str) -> T {
 }
 
 pub fn building_library(options: &options, crate: &ast::Crate) -> bool {
+    if options.test { return false }
     for output in options.outputs.iter() {
         match *output {
             OutputExecutable => {}
             OutputStaticlib | OutputDylib | OutputRlib => return true
         }
     }
-    if options.test { return false }
     match syntax::attr::first_attr_value_str_by_name(crate.attrs, "crate_type") {
         Some(s) => "lib" == s || "rlib" == s || "dylib" == s || "staticlib" == s,
         _ => false
@@ -419,6 +419,11 @@ pub fn building_library(options: &options, crate: &ast::Crate) -> bool {
 }
 
 pub fn collect_outputs(options: &options, crate: &ast::Crate) -> ~[OutputStyle] {
+    // If we're generating a test executable, then ignore all other output
+    // styles at all other locations
+    if options.test {
+        return ~[OutputExecutable];
+    }
     let mut base = options.outputs.clone();
     let mut iter = crate.attrs.iter().filter_map(|a| {
         if "crate_type" == a.name() {
diff --git a/src/test/run-make/no-intermediate-extras/Makefile b/src/test/run-make/no-intermediate-extras/Makefile
new file mode 100644
index 00000000000..89186b2ad4d
--- /dev/null
+++ b/src/test/run-make/no-intermediate-extras/Makefile
@@ -0,0 +1,7 @@
+# Regression test for issue #10973
+
+-include ../tools.mk
+
+all:
+	$(RUSTC) --rlib --test foo.rs
+	rm $(TMPDIR)/foo.bc && exit 1 || exit 0
diff --git a/src/test/run-make/no-intermediate-extras/foo.rs b/src/test/run-make/no-intermediate-extras/foo.rs
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/src/test/run-make/no-intermediate-extras/foo.rs