Skip to content

Commit

Permalink
Add a profile for profiling the binary sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxammann committed May 9, 2022
1 parent 374d047 commit 4cc2cf1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[target.wasm32-unknown-unknown]

rustflags = [
# Enabled unstable APIs from web_sys
"--cfg=web_sys_unstable_apis",
Expand All @@ -7,4 +8,8 @@ rustflags = [
# Enables the possibility to import memory into wasm.
# Without --shared-memory it is not possible to use shared WebAssembly.Memory.
"-C", "link-args=--shared-memory --import-memory",
]
]

# We can use this once build-std is stable
#[unstable]
#build-std = "std,panic_abort"
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ members = [
[profile.release]
lto = true
codegen-units = 1
opt-level = 's'
panic = "abort"

strip = "debuginfo"
strip = true # Automatically strip symbols from the binary.
opt-level = "z" # Optimize for size.

[profile.bench]
debug = true

[profile.binary-size]
inherits = "release"
strip = false
13 changes: 13 additions & 0 deletions web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,22 @@ web-webgl = ["maplibre/web-webgl"]
enable-tracing = ["maplibre/enable-tracing", "tracing-wasm"]
default = []

[package.metadata.wasm-pack.profile.binary-size]
wasm-opt = ["-g"]

[package.metadata.wasm-pack.profile.binary-size.wasm-bindgen]
debug-js-glue = false
demangle-name-section = true
dwarf-debug-info = true

[package.metadata.wasm-pack.profile.release]
wasm-opt = true

[package.metadata.wasm-pack.profile.release.wasm-bindgen]
debug-js-glue = false
demangle-name-section = true
dwarf-debug-info = false

[lib]
crate-type = ["cdylib", "rlib"]

Expand Down

0 comments on commit 4cc2cf1

Please sign in to comment.