diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-09-26 19:51:14 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-09-26 19:51:14 +0000 |
| commit | 6414d9f52dd8c9e31ce0c923a4327583b794bb43 (patch) | |
| tree | b53bf5ddb494c7ffaa24769e206ce9a4f11b3a89 /compiler/rustc_fs_util/src/lib.rs | |
| parent | 4428a051679ec6194a118424f4616d922249a1e6 (diff) | |
| download | rust-6414d9f52dd8c9e31ce0c923a4327583b794bb43.tar.gz rust-6414d9f52dd8c9e31ce0c923a4327583b794bb43.zip | |
Couple of changes to make it easier to compile rustc for wasm
This is a subset of the patches I have on my rust fork to compile rustc for wasm32-wasip1.
Diffstat (limited to 'compiler/rustc_fs_util/src/lib.rs')
| -rw-r--r-- | compiler/rustc_fs_util/src/lib.rs | 6 |
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() } |
