From 8ac528bed1cc30eabe26a5acc345acd9cbcf7198 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Sun, 8 Mar 2015 18:10:33 -0700 Subject: [PATCH 1/3] rustc: Fix an ICE when -o bare-path rustc will ICE if you specify an outfile path that is bare without a directory. As a workaround, before this -o ./foo will work --- src/librustc_driver/driver.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 565782b29e97..13499439f724 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -954,8 +954,11 @@ pub fn build_output_filenames(input: &Input, if *odir != None { sess.warn("ignoring --out-dir flag due to -o flag."); } + + let cur_dir = Path::new(""); + OutputFilenames { - out_directory: out_file.parent().unwrap().to_path_buf(), + out_directory: out_file.parent().unwrap_or(cur_dir).to_path_buf(), out_filestem: out_file.file_stem().unwrap() .to_str().unwrap().to_string(), single_output_file: ofile, From 0487ad91193057cfcf109e4efa7bef6b00944e2b Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Sun, 8 Mar 2015 18:54:59 -0700 Subject: [PATCH 2/3] Add a test for a bare outfile param to rustc --- src/test/run-make/bare-outfile/Makefile | 4 ++++ src/test/run-make/bare-outfile/foo.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/test/run-make/bare-outfile/Makefile create mode 100644 src/test/run-make/bare-outfile/foo.rs diff --git a/src/test/run-make/bare-outfile/Makefile b/src/test/run-make/bare-outfile/Makefile new file mode 100644 index 000000000000..e6cd3851e03c --- /dev/null +++ b/src/test/run-make/bare-outfile/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + rustc -o foo foo.rs diff --git a/src/test/run-make/bare-outfile/foo.rs b/src/test/run-make/bare-outfile/foo.rs new file mode 100644 index 000000000000..63e747901ae8 --- /dev/null +++ b/src/test/run-make/bare-outfile/foo.rs @@ -0,0 +1,12 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { +} From 103636114d67417048758b4a4d236383af2d44dd Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Sun, 8 Mar 2015 22:21:36 -0700 Subject: [PATCH 3/3] normalize the current directory as Path{""} --- src/librustc_driver/driver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 13499439f724..dc27a3011095 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -927,7 +927,7 @@ pub fn build_output_filenames(input: &Input, // We want to toss everything after the final '.' let dirpath = match *odir { Some(ref d) => d.clone(), - None => PathBuf::new(".") + None => PathBuf::new("") }; // If a crate name is present, we use it as the link name