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.
This commit is contained in:
bjorn3 2024-09-26 19:51:14 +00:00
parent 4428a05167
commit 6414d9f52d
2 changed files with 7 additions and 1 deletions

View File

@ -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()
}

View File

@ -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()
}