Skip to content

Commit 538d699

Browse files
james7132BD103
andauthored
Make dynamic_linking a no-op on wasm targets (#12672)
# Objective Resolve #10054. ## Solution Make dynamic linking a no-op by omitting it from the dependency tree on wasm targets. To test this, try `cargo build --lib --target wasm32-unknown-unknown --features bevy/dynamic_linking` with and without this PR. Might need to update the book on the website to explain this when this makes it into a release. Co-Authored By: @daxpedda --------- Co-authored-by: BD103 <[email protected]>
1 parent f1d1491 commit 538d699

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,12 @@ meshlet_processor = ["bevy_internal/meshlet_processor"]
330330
ios_simulator = ["bevy_internal/ios_simulator"]
331331

332332
[dependencies]
333-
bevy_dylib = { path = "crates/bevy_dylib", version = "0.14.0-dev", default-features = false, optional = true }
334333
bevy_internal = { path = "crates/bevy_internal", version = "0.14.0-dev", default-features = false }
335334

335+
# WASM does not support dynamic linking.
336+
[target.'cfg(not(target_family = "wasm"))'.dependencies]
337+
bevy_dylib = { path = "crates/bevy_dylib", version = "0.14.0-dev", default-features = false, optional = true }
338+
336339
[dev-dependencies]
337340
rand = "0.8.0"
338341
rand_chacha = "0.3.1"

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
pub use bevy_internal::*;
5050

51-
#[cfg(feature = "dynamic_linking")]
51+
// WASM does not support dynamic linking.
52+
#[cfg(all(feature = "dynamic_linking", not(target_family = "wasm")))]
5253
#[allow(unused_imports)]
5354
use bevy_dylib;

0 commit comments

Comments
 (0)