)?
};
- 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 {
// 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
);
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("");
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 \
--- /dev/null
+// 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"]