Skip to content

Commit 6414d9f

Browse files
committed
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.
1 parent 4428a05 commit 6414d9f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/rustc_fs_util/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ pub fn link_or_copy<P: AsRef<Path>, Q: AsRef<Path>>(p: P, q: Q) -> io::Result<Li
7676
}
7777
}
7878

79-
#[cfg(unix)]
79+
#[cfg(any(unix, all(target_os = "wasi", target_env = "p1")))]
8080
pub fn path_to_c_string(p: &Path) -> CString {
8181
use std::ffi::OsStr;
82+
#[cfg(unix)]
8283
use std::os::unix::ffi::OsStrExt;
84+
#[cfg(all(target_os = "wasi", target_env = "p1"))]
85+
use std::os::wasi::ffi::OsStrExt;
86+
8387
let p: &OsStr = p.as_ref();
8488
CString::new(p.as_bytes()).unwrap()
8589
}

src/bootstrap/src/utils/shared_helpers.rs

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ pub fn exe(name: &str, target: &str) -> String {
4949
format!("{name}.exe")
5050
} else if target.contains("uefi") {
5151
format!("{name}.efi")
52+
} else if target.contains("wasm") {
53+
format!("{name}.wasm")
5254
} else {
5355
name.to_string()
5456
}

0 commit comments

Comments
 (0)