miniaudio-rs
miniaudio-rs copied to clipboard
Fix wasm32-unknown-emscripten cross-compile
This PR adds workarounds for two issues that manifest when compiling for WASM with Emscripten:
- Bindgen doesn't always detect the correct target. This is marked as a bug upstream, so hopefully this workaround is temporary. On macOS, this manifests as the following error:
--- stderr
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:828:2: error: Unsupported architecture
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/_types.h:36:2: error: architecture not supported
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
...
-
Clang assumes the wrong visibility when building WASM targets. This manifests as a series of
cannot find functionerrors:
Compiling miniaudio v0.10.0 (/Users/kofi/Documents/miniaudio-rs/miniaudio)
error[E0425]: cannot find function `ma_context_init` in crate `sys`
--> miniaudio-sys/examples/simple-enumeration-raw.rs:13:13
|
13 | if sys::ma_context_init(null(), 0, null(), context.as_mut_ptr()) != sys::MA_SUCCESS as _ {
| ^^^^^^^^^^^^^^^ not found in `sys`
error[E0425]: cannot find function `ma_context_get_devices` in crate `sys`
--> miniaudio-sys/examples/simple-enumeration-raw.rs:25:23
|
25 | let result = sys::ma_context_get_devices(
| ^^^^^^^^^^^^^^^^^^^^^^ not found in `sys`