Skip to content

Commit

Permalink
add more compile options for WAMR
Browse files Browse the repository at this point in the history
add a <project>/.cargo/config.toml

``` toml
[env]
WAMR_BH_VPRINTF = "my_vprintf2"
```
  • Loading branch information
lum1n0us committed Jul 26, 2024
1 parent 4b0ab26 commit 80f2846
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
23 changes: 20 additions & 3 deletions crates/wamr-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ fn main() {
if is_espidf {
let enable_llvm_jit = if cfg!(feature = "llvmjit") { "1" } else { "0" };
// TODO: define LLVM_DIR
let dst = Config::new(&wamr_root)
let mut cfg = Config::new(&wamr_root);
let mut cfg = cfg
// running mode
.define("WAMR_BUILD_AOT", "1")
.define("WAMR_BUILD_INTERP", "1")
Expand All @@ -33,8 +34,24 @@ fn main() {
.define("WAMR_BUILD_LIBC_WASI", "1")
// `nostdlib`
.define("WAMR_BUILD_LIBC_BUILTIN", "0")
.build_target("iwasm_static")
.build();
// hw bound checker (workaround)
.define("WAMR_DISABLE_HW_BOUND_CHECK", "1");
// for developer (uncomment when necessary)
// .define("WAMR_BUILD_DUMP_CALL_STACK", "1")
// .define("WAMR_BUILD_CUSTOM_NAME_SECTION", "1")
// .define("WAMR_BUILD_LOAD_CUSTOM_SECTION", "1")

// support STDIN/STDOUT/STDERR redirect.
cfg = match env::var("WAMR_BH_VPRINTF") {
Ok(bh_vprintf) => match bh_vprintf.len() {
0 => cfg,
_ => cfg.define("WAMR_BH_VPRINTF", bh_vprintf),
},
Err(_) => cfg,
};

// set target and finish configuration
let dst = cfg.build_target("iwasm_static").build();

println!("cargo:rustc-link-search=native={}/build", dst.display());
println!("cargo:rustc-link-lib=static=vmlib");
Expand Down
4 changes: 2 additions & 2 deletions src/wasi_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ impl WasiCtxBuilder {
.iter()
.map(|s| CString::new(s.as_bytes()).unwrap())
.collect::<Vec<CString>>();
self.env_cstr_ptrs = self.
env
self.env_cstr_ptrs = self
.env
.iter()
.map(|s| s.as_ptr() as *const c_char)
.collect::<Vec<*const c_char>>();
Expand Down

0 comments on commit 80f2846

Please sign in to comment.