Skip to content

Rollup of 12 pull requests #39567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Feb 5, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3ccb87a
liballoc_jemalloc: fix linking with system library
ishitatsuyuki Feb 3, 2017
458167e
Add `aarch64-unknown-freebsd` to the supported targets
dumbbell Jan 25, 2017
f6c6b31
`aarch64` CPU type is called `arm64` on FreeBSD
dumbbell Feb 3, 2017
5e41ec2
rename other than copy/remove
king6cong Feb 1, 2017
7de99cd
Merge remote tracking branch 'upstream/master'
ishitatsuyuki Feb 3, 2017
768f6a9
add and use rename_or_copy_remove fn that fallback to copy & remove
king6cong Feb 3, 2017
d14b268
libbacktrace: Fix uninitialized variable
petrochenkov Feb 3, 2017
34f444d
Extract libcore benchmarks to a separate folder
phungleson Feb 3, 2017
efeb42b
Use less syscalls in `FileDesc::set_{nonblocking,cloexec}`
tbu- Feb 4, 2017
3c16139
Don't use "unadjusted" ABI on non windows platforms
est31 Feb 2, 2017
5a21f42
run rustfmt for librustc/util/fs.rs
king6cong Feb 4, 2017
87ace0d
More snap cleanup
nagisa Feb 4, 2017
206ee20
Unignore stage0/1 i128 tests as well
nagisa Feb 4, 2017
a1f42cd
Uninhabited while-let pattern fix
canndrew Feb 4, 2017
768c6c0
Support a debug info API change for LLVM 4.0
Feb 4, 2017
112a5a0
ignore more gdb versions with buggy rust support
TimNN Feb 4, 2017
a884a6c
Slightly optimize slice::sort
Feb 4, 2017
fa457bf
Minor fix in the *_expensive benchmark
Feb 4, 2017
0dbb1e4
Remove use of ptr::eq
canndrew Feb 5, 2017
7135d0a
Fix make tidy
canndrew Feb 5, 2017
388db66
Rollup merge of #39439 - king6cong:move, r=alexcrichton
frewsxcv Feb 5, 2017
ddd01e0
Rollup merge of #39472 - est31:unadjusted_only_for_win, r=nagisa
frewsxcv Feb 5, 2017
d021a3f
Rollup merge of #39481 - ishitatsuyuki:master, r=alexcrichton
frewsxcv Feb 5, 2017
b3518af
Rollup merge of #39491 - dumbbell:support-aarch64-unknown-freebsd, r=…
frewsxcv Feb 5, 2017
ac329cd
Rollup merge of #39501 - phungleson:libcorebench, r=alexcrichton
frewsxcv Feb 5, 2017
ae3aafa
Rollup merge of #39509 - petrochenkov:rb2, r=alexcrichton
frewsxcv Feb 5, 2017
d194688
Rollup merge of #39514 - tbu-:pr_less_syscalls_fd, r=alexcrichton
frewsxcv Feb 5, 2017
13b8e4b
Rollup merge of #39519 - nagisa:more-snap, r=alexcrichton
frewsxcv Feb 5, 2017
4e67bf9
Rollup merge of #39526 - canndrew:uninhabited-while-let-fix, r=arielb1
frewsxcv Feb 5, 2017
3e7ee35
Rollup merge of #39528 - dylanmckay:llvm-4.0-diglobalvar, r=alexcrichton
frewsxcv Feb 5, 2017
70cc1d3
Rollup merge of #39530 - TimNN:more-gdb, r=alexcrichton
frewsxcv Feb 5, 2017
a419dd1
Rollup merge of #39538 - stjepang:slightly-optimize-sort, r=alexcrichton
frewsxcv Feb 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions src/librustc/util/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use std::io;
// https://github.com/rust-lang/rust/issues/25505#issuecomment-102876737
pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
if !cfg!(windows) {
return p.to_path_buf()
return p.to_path_buf();
}
let mut components = p.components();
let prefix = match components.next() {
Expand All @@ -58,7 +58,7 @@ pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {

pub enum LinkOrCopy {
Link,
Copy
Copy,
}

/// Copy `p` into `q`, preferring to use hard-linking if possible. If
Expand All @@ -76,7 +76,35 @@ pub fn link_or_copy<P: AsRef<Path>, Q: AsRef<Path>>(p: P, q: Q) -> io::Result<Li
Err(_) => {
match fs::copy(p, q) {
Ok(_) => Ok(LinkOrCopy::Copy),
Err(e) => Err(e)
Err(e) => Err(e),
}
}
}
}

#[derive(Debug)]
pub enum RenameOrCopyRemove {
Rename,
CopyRemove,
}

/// Rename `p` into `q`, preferring to use `rename` if possible.
/// If `rename` fails (rename may fail for reasons such as crossing
/// filesystem), fallback to copy & remove
pub fn rename_or_copy_remove<P: AsRef<Path>, Q: AsRef<Path>>(p: P,
q: Q)
-> io::Result<RenameOrCopyRemove> {
let p = p.as_ref();
let q = q.as_ref();
match fs::rename(p, q) {
Ok(()) => Ok(RenameOrCopyRemove::Rename),
Err(_) => {
match fs::copy(p, q) {
Ok(_) => {
fs::remove_file(p)?;
Ok(RenameOrCopyRemove::CopyRemove)
}
Err(e) => Err(e),
}
}
}
Expand All @@ -93,8 +121,7 @@ pub fn create_dir_racy(path: &Path) -> io::Result<()> {
}
match path.parent() {
Some(p) => try!(create_dir_racy(p)),
None => return Err(io::Error::new(io::ErrorKind::Other,
"failed to create whole tree")),
None => return Err(io::Error::new(io::ErrorKind::Other, "failed to create whole tree")),
}
match fs::create_dir(path) {
Ok(()) => Ok(()),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use rustc::middle::privacy::AccessLevels;
use rustc::ty::{self, TyCtxt, Resolutions, GlobalArenas};
use rustc::util::common::time;
use rustc::util::nodemap::{NodeSet, NodeMap};
use rustc::util::fs::rename_or_copy_remove;
use rustc_borrowck as borrowck;
use rustc_incremental::{self, IncrementalHashesMap};
use rustc_incremental::ich::Fingerprint;
Expand Down Expand Up @@ -1084,10 +1085,9 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
// are going to build an executable
if sess.opts.output_types.contains_key(&OutputType::Exe) {
let f = outputs.path(OutputType::Object);
fs::copy(&f,
rename_or_copy_remove(&f,
f.with_file_name(format!("{}.0.o",
f.file_stem().unwrap().to_string_lossy()))).unwrap();
fs::remove_file(f).unwrap();
}

// Remove assembly source, unless --save-temps was specified
Expand Down