about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-01-29 14:38:50 +0000
committervarkor <github@varkor.com>2018-01-29 14:38:50 +0000
commite92bdb9828ff19afc92c292b289be1790f2ee116 (patch)
tree6ca071148d2b4640318b8601a4604b8872da8ba4
parent9a2f02df6655f65e5a7892e853cc2112e28b89e8 (diff)
downloadrust-e92bdb9828ff19afc92c292b289be1790f2ee116.tar.gz
rust-e92bdb9828ff19afc92c292b289be1790f2ee116.zip
Specify output filenames for compatibility with Windows
-rw-r--r--src/librustc_driver/driver.rs15
-rw-r--r--src/test/run-make/output-filename-conflicts-with-directory/Makefile2
-rw-r--r--src/test/run-make/output-filename-conflicts-with-directory/foo.rs2
-rw-r--r--src/test/run-make/output-filename-overwrites-input/Makefile5
-rw-r--r--src/test/run-make/output-filename-overwrites-input/bar.rs11
-rw-r--r--src/test/run-make/output-filename-overwrites-input/foo.rs2
6 files changed, 27 insertions, 10 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index df8860823ad..50c19b5a99a 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -142,7 +142,7 @@ pub fn compile_input(trans: Box<TransCrate>,
             )?
         };
 
-        let output_paths = generated_output_paths(sess, &outputs, &crate_name);
+        let output_paths = generated_output_paths(sess, &outputs, output.is_some(), &crate_name);
 
         // Ensure the source file isn't accidentally overwritten during compilation.
         if let Some(ref input_path) = *input_path {
@@ -1111,16 +1111,19 @@ fn escape_dep_filename(filename: &FileName) -> String {
 // Returns all the paths that correspond to generated files.
 fn generated_output_paths(sess: &Session,
                           outputs: &OutputFilenames,
+                          exact_name: bool,
                           crate_name: &str) -> Vec<PathBuf> {
     let mut out_filenames = Vec::new();
     for output_type in sess.opts.output_types.keys() {
         let file = outputs.path(*output_type);
         match *output_type {
-            OutputType::Exe => {
-                for output in sess.crate_types.borrow().iter() {
+            // If the filename has been overridden using `-o`, it will not be modified
+            // by appending `.rlib`, `.exe`, etc., so we can skip this transformation.
+            OutputType::Exe if !exact_name => {
+                for crate_type in sess.crate_types.borrow().iter() {
                     let p = ::rustc_trans_utils::link::filename_for_input(
                         sess,
-                        *output,
+                        *crate_type,
                         crate_name,
                         outputs
                     );
@@ -1376,10 +1379,10 @@ pub fn build_output_filenames(input: &Input,
                 Some(out_file.clone())
             };
             if *odir != None {
-                sess.warn("ignoring --out-dir flag due to -o flag.");
+                sess.warn("ignoring --out-dir flag due to -o flag");
             }
             if !sess.opts.cg.extra_filename.is_empty() {
-                sess.warn("ignoring -C extra-filename flag due to -o flag.");
+                sess.warn("ignoring -C extra-filename flag due to -o flag");
             }
 
             let cur_dir = Path::new("");
diff --git a/src/test/run-make/output-filename-conflicts-with-directory/Makefile b/src/test/run-make/output-filename-conflicts-with-directory/Makefile
index 74dea9ce72b..74e5dcfcf36 100644
--- a/src/test/run-make/output-filename-conflicts-with-directory/Makefile
+++ b/src/test/run-make/output-filename-conflicts-with-directory/Makefile
@@ -3,5 +3,5 @@
 all:
 	cp foo.rs $(TMPDIR)/foo.rs
 	mkdir $(TMPDIR)/foo
-	$(RUSTC) $(TMPDIR)/foo.rs 2>&1 \
+	$(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \
 		| $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\""
diff --git a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs b/src/test/run-make/output-filename-conflicts-with-directory/foo.rs
index 046d27a9f0f..3f07b46791d 100644
--- a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs
+++ b/src/test/run-make/output-filename-conflicts-with-directory/foo.rs
@@ -1,4 +1,4 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
diff --git a/src/test/run-make/output-filename-overwrites-input/Makefile b/src/test/run-make/output-filename-overwrites-input/Makefile
index 0554627d677..6377038b7be 100644
--- a/src/test/run-make/output-filename-overwrites-input/Makefile
+++ b/src/test/run-make/output-filename-overwrites-input/Makefile
@@ -2,8 +2,11 @@
 
 all:
 	cp foo.rs $(TMPDIR)/foo
-	$(RUSTC) $(TMPDIR)/foo 2>&1 \
+	$(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \
 		| $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable"
+	cp bar.rs $(TMPDIR)/bar.rlib
+	$(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \
+		| $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable"
 	$(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1
 	cp foo.rs $(TMPDIR)/foo.rs
 	$(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \
diff --git a/src/test/run-make/output-filename-overwrites-input/bar.rs b/src/test/run-make/output-filename-overwrites-input/bar.rs
new file mode 100644
index 00000000000..8e4e35fdee6
--- /dev/null
+++ b/src/test/run-make/output-filename-overwrites-input/bar.rs
@@ -0,0 +1,11 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![crate_type = "lib"]
diff --git a/src/test/run-make/output-filename-overwrites-input/foo.rs b/src/test/run-make/output-filename-overwrites-input/foo.rs
index 046d27a9f0f..3f07b46791d 100644
--- a/src/test/run-make/output-filename-overwrites-input/foo.rs
+++ b/src/test/run-make/output-filename-overwrites-input/foo.rs
@@ -1,4 +1,4 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //