-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #25134 - alexcrichton:fix-issue-25072-for-realsies, r=b…
…rson Turns out that a verbatim path was leaking through to gcc via the PATH environment variable (pointing to the bundled gcc provided by the main distribution) which was wreaking havoc when gcc itself was run. The fix here is to just stop passing verbatim paths down by adding more liberal uses of `fix_windows_verbatim_for_gcc`. Closes #25072
- Loading branch information
Showing
6 changed files
with
51 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,7 @@ pub mod util { | |
pub mod nodemap; | ||
pub mod lev_distance; | ||
pub mod num; | ||
pub mod fs; | ||
} | ||
|
||
pub mod lib { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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 <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. | ||
|
||
use std::path::{self, Path, PathBuf}; | ||
use std::ffi::OsString; | ||
|
||
// Unfortunately, on windows, gcc cannot accept paths of the form `\\?\C:\...` | ||
// (a verbatim path). This form of path is generally pretty rare, but the | ||
// implementation of `fs::canonicalize` currently generates paths of this form, | ||
// meaning that we're going to be passing quite a few of these down to gcc. | ||
// | ||
// For now we just strip the "verbatim prefix" of `\\?\` from the path. This | ||
// will probably lose information in some cases, but there's not a whole lot | ||
// more we can do with a buggy gcc... | ||
pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf { | ||
if !cfg!(windows) { | ||
return p.to_path_buf() | ||
} | ||
let mut components = p.components(); | ||
let prefix = match components.next() { | ||
Some(path::Component::Prefix(p)) => p, | ||
_ => return p.to_path_buf(), | ||
}; | ||
let disk = match prefix.kind() { | ||
path::Prefix::VerbatimDisk(disk) => disk, | ||
_ => return p.to_path_buf(), | ||
}; | ||
let mut base = OsString::from(format!("{}:", disk as char)); | ||
base.push(components.as_path()); | ||
PathBuf::from(base) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters