about summary refs log tree commit diff
path: root/compiler/rustc_fs_util/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_fs_util/src/lib.rs')
-rw-r--r--compiler/rustc_fs_util/src/lib.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_fs_util/src/lib.rs b/compiler/rustc_fs_util/src/lib.rs
index 80813af3864..4e9d21c900d 100644
--- a/compiler/rustc_fs_util/src/lib.rs
+++ b/compiler/rustc_fs_util/src/lib.rs
@@ -76,10 +76,14 @@ pub fn link_or_copy<P: AsRef<Path>, Q: AsRef<Path>>(p: P, q: Q) -> io::Result<Li
     }
 }
 
-#[cfg(unix)]
+#[cfg(any(unix, all(target_os = "wasi", target_env = "p1")))]
 pub fn path_to_c_string(p: &Path) -> CString {
     use std::ffi::OsStr;
+    #[cfg(unix)]
     use std::os::unix::ffi::OsStrExt;
+    #[cfg(all(target_os = "wasi", target_env = "p1"))]
+    use std::os::wasi::ffi::OsStrExt;
+
     let p: &OsStr = p.as_ref();
     CString::new(p.as_bytes()).unwrap()
 }