From 6414d9f52dd8c9e31ce0c923a4327583b794bb43 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 26 Sep 2024 19:51:14 +0000 Subject: [PATCH] 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. --- compiler/rustc_fs_util/src/lib.rs | 6 +++++- src/bootstrap/src/utils/shared_helpers.rs | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) 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, Q: AsRef>(p: P, q: Q) -> io::Result
  • 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() }