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 | |
| 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.
| -rw-r--r-- | compiler/rustc_fs_util/src/lib.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/shared_helpers.rs | 2 |
2 files changed, 7 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() } diff --git a/src/bootstrap/src/utils/shared_helpers.rs b/src/bootstrap/src/utils/shared_helpers.rs index 7150c84313c..6d3c276cc05 100644 --- a/src/bootstrap/src/utils/shared_helpers.rs +++ b/src/bootstrap/src/utils/shared_helpers.rs @@ -49,6 +49,8 @@ pub fn exe(name: &str, target: &str) -> String { format!("{name}.exe") } else if target.contains("uefi") { format!("{name}.efi") + } else if target.contains("wasm") { + format!("{name}.wasm") } else { name.to_string() } |
