Skip to content

Commit ce6ff22

Browse files
committed
Fix Windows nightly error caused by rust-lang/rust#92519
1 parent 56fbfd1 commit ce6ff22

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/zig.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,24 @@ fn write_linker_wrapper(path: &Path, command: &str, args: &str) -> Result<()> {
360360
writeln!(
361361
&mut custom_linker_file,
362362
"{} zig {} -- {} %*",
363-
current_exe, command, args
363+
adjust_canonicalization(current_exe),
364+
command,
365+
args
364366
)?;
365367
Ok(())
366368
}
367369

368370
pub(crate) fn is_mingw_shell() -> bool {
369371
env::var_os("MSYSTEM").is_some() && env::var_os("SHELL").is_some()
370372
}
373+
374+
// https://stackoverflow.com/a/50323079/3549270
375+
#[cfg(target_os = "windows")]
376+
pub fn adjust_canonicalization(p: String) -> String {
377+
const VERBATIM_PREFIX: &str = r#"\\?\"#;
378+
if p.starts_with(VERBATIM_PREFIX) {
379+
p[VERBATIM_PREFIX.len()..].to_string()
380+
} else {
381+
p
382+
}
383+
}

0 commit comments

Comments
 (0)