From 2b3b865c285dc090eb49d8e5ed93165a69c6c498 Mon Sep 17 00:00:00 2001 From: YOUNGSUK_KIM Date: Sat, 5 Oct 2019 17:11:09 -0400 Subject: [PATCH 1/4] change cargo-miri.rs to fix issue #978 --- src/bin/cargo-miri.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 43e8761d48..1f1705a49a 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -333,7 +333,14 @@ path = "lib.rs" None => true, Some(target) => target == rustc_version::version_meta().unwrap().host, }; - let sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) }; + let mut sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) }; + if cfg!(target_os = "windows") { + // Replace backslashes in path to slashes as they cause problems. + // Win10 Powershell can work with slashes in paths. + sysroot = PathBuf::from( + String::from(sysroot.to_str().unwrap()).replace("\\", "/") + ); + } std::env::set_var("MIRI_SYSROOT", &sysroot); // pass the env var to the processes we spawn, which will turn it into "--sysroot" flags if print_env { println!("MIRI_SYSROOT={}", sysroot.display()); From 610dbdd562bc327f016a326c703073cee97dc645 Mon Sep 17 00:00:00 2001 From: YOUNGSUK_KIM Date: Thu, 10 Oct 2019 11:03:20 -0400 Subject: [PATCH 2/4] fixed cargo-miri bug for windows users --- src/bin/cargo-miri.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 1f1705a49a..521ac8fa06 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -333,17 +333,11 @@ path = "lib.rs" None => true, Some(target) => target == rustc_version::version_meta().unwrap().host, }; - let mut sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) }; - if cfg!(target_os = "windows") { - // Replace backslashes in path to slashes as they cause problems. - // Win10 Powershell can work with slashes in paths. - sysroot = PathBuf::from( - String::from(sysroot.to_str().unwrap()).replace("\\", "/") - ); - } + let sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) }; + std::env::set_var("MIRI_SYSROOT", &sysroot); // pass the env var to the processes we spawn, which will turn it into "--sysroot" flags if print_env { - println!("MIRI_SYSROOT={}", sysroot.display()); + println!("MIRI_SYSROOT={:?}", &sysroot); // for Windows users, prints path with backslashes escaped. } else if !ask_user { println!("A libstd for Miri is now available in `{}`.", sysroot.display()); } From e06ce728ca49fc647ea1dfbb609116d76385446c Mon Sep 17 00:00:00 2001 From: YOUNGSUK_KIM Date: Mon, 14 Oct 2019 20:57:57 -0400 Subject: [PATCH 3/4] Ralf Jung's great idea! --- src/bin/cargo-miri.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 521ac8fa06..3af5a2b35d 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -333,11 +333,11 @@ path = "lib.rs" None => true, Some(target) => target == rustc_version::version_meta().unwrap().host, }; - let sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) }; - + let sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) }; + std::env::set_var("MIRI_SYSROOT", &sysroot); // pass the env var to the processes we spawn, which will turn it into "--sysroot" flags if print_env { - println!("MIRI_SYSROOT={:?}", &sysroot); // for Windows users, prints path with backslashes escaped. + println!("MIRI_SYSROOT='{}'", sysroot.display().to_string().replace('\'', r#"'"'"'"#)); } else if !ask_user { println!("A libstd for Miri is now available in `{}`.", sysroot.display()); } From 65fd00665ee246a029c9b220781098277319cd6a Mon Sep 17 00:00:00 2001 From: YOUNGSUK_KIM Date: Mon, 14 Oct 2019 22:37:54 -0400 Subject: [PATCH 4/4] remove unnecessary line break --- src/bin/cargo-miri.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 3af5a2b35d..479374ee47 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -334,7 +334,6 @@ path = "lib.rs" Some(target) => target == rustc_version::version_meta().unwrap().host, }; let sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) }; - std::env::set_var("MIRI_SYSROOT", &sysroot); // pass the env var to the processes we spawn, which will turn it into "--sysroot" flags if print_env { println!("MIRI_SYSROOT='{}'", sysroot.display().to_string().replace('\'', r#"'"'"'"#));