| Crates.io | wasm-merge-sys |
| lib.rs | wasm-merge-sys |
| version | 0.1.0 |
| created_at | 2025-10-20 02:42:00.945386+00 |
| updated_at | 2025-10-20 02:42:00.945386+00 |
| description | Native wasm-merge build (Rust bindings for Binaryen's wasm-merge) |
| homepage | |
| repository | https://github.com/oligamiq/wasm-merge-rs |
| max_upload_size | |
| id | 1891315 |
| size | 37,999,487 |
Rust bindings for Binaryen's wasm-merge tool.
This crate provides low-level bindings to the wasm-merge C++ implementation from the Binaryen project.
wasm-merge is a WebAssembly module merger that loads multiple wasm files, connects them together by hooking up imports to exports, and emits a single merged module. Unlike wasm-ld, this does not have the full semantics of native linkers. Instead, wasm-merge does at compile time what you can do with JavaScript at runtime: connect wasm modules together.
The result is a single module that behaves the same as the multiple original modules, but you don't need JavaScript to set up the connections between modules anymore. This allows for better optimization opportunities like DCE and inlining.
Add this to your Cargo.toml:
[dependencies]
wasm-merge-sys = "0.1.0"
use wasm_merge_sys::run_wasm_merge;
fn main() {
let args = vec![
"wasm-merge".to_string(),
"module1.wasm".to_string(),
"module1".to_string(),
"module2.wasm".to_string(),
"module2".to_string(),
"-o".to_string(),
"output.wasm".to_string(),
];
let exit_code = run_wasm_merge(&args);
if exit_code == 0 {
println!("Modules merged successfully!");
} else {
eprintln!("Merge failed with exit code: {}", exit_code);
}
}
run_wasm_merge(args: &[String]) -> i32Run wasm-merge with the given command-line arguments.
This is a safe wrapper around the C wasm_merge_main function that handles string conversion and memory management.
This crate requires:
binaryen/ directory)To build:
# If using as a git submodule
git submodule update --init
# Build the crate
cargo build
dwarf (default): Include DWARF debug information supportMIT OR Apache-2.0
This project is modeled after wasm-opt-rs by Brian Anderson.