mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Provide a way for non-wasm Rust code to find the WASI libc
This commit is contained in:
parent
dd1d49db75
commit
5fffea969a
6 changed files with 51 additions and 31 deletions
|
@ -31,6 +31,7 @@ libloading = "0.7.1"
|
|||
tempfile = "3.2.0"
|
||||
inkwell = { path = "../../vendor/inkwell", optional = true }
|
||||
target-lexicon = "0.12.3"
|
||||
wasi_libc_sys = { path = "../../wasi-libc-sys", optional = true }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
serde_json = "1.0.69"
|
||||
|
@ -40,7 +41,7 @@ target-arm = []
|
|||
target-aarch64 = ["roc_gen_dev/target-aarch64"]
|
||||
target-x86 = []
|
||||
target-x86_64 = ["roc_gen_dev/target-x86_64"]
|
||||
target-wasm32 = ["roc_gen_wasm"]
|
||||
target-wasm32 = ["roc_gen_wasm", "wasi_libc_sys"]
|
||||
|
||||
# This is a separate feature because when we generate docs on Netlify,
|
||||
# it doesn't have LLVM installed. (Also, it doesn't need to do code gen.)
|
||||
|
|
|
@ -72,12 +72,12 @@ fn find_zig_str_path() -> PathBuf {
|
|||
}
|
||||
|
||||
fn find_wasi_libc_path() -> PathBuf {
|
||||
use wasi_libc_sys::WASI_LIBC_PATH;
|
||||
|
||||
// Environment variable defined in wasi-libc-sys/build.rs
|
||||
if let Ok(wasi_libc_path) = std::env::var("WASI_LIBC_SYS_PATH") {
|
||||
let wasi_libc_pathbuf = PathBuf::from(&wasi_libc_path);
|
||||
if std::path::Path::exists(&wasi_libc_pathbuf) {
|
||||
return wasi_libc_pathbuf;
|
||||
}
|
||||
let wasi_libc_pathbuf = PathBuf::from(WASI_LIBC_PATH);
|
||||
if std::path::Path::exists(&wasi_libc_pathbuf) {
|
||||
return wasi_libc_pathbuf;
|
||||
}
|
||||
|
||||
panic!("cannot find `wasi-libc.a`")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue