CosmWasm / wasmvm

Go bindings to the running cosmwasm contracts with wasmer
Apache License 2.0
172 stars 99 forks source link

Strip shared libraries? #222

Closed webmaster128 closed 1 month ago

webmaster128 commented 3 years ago

Stripping is currently disabled. We could (should?) re-enable it. It must be performed in the guest (the builder) in order to support stripping for multiple systems.

ethanfrey commented 3 years ago

It was disabled to allow easier debugging if we hit a crash in Rust, which had happened before due to some race conditions.

Once we hit 1.0, we could strip again, and only make custom builds if we need to debug something.

webmaster128 commented 3 years ago

Is there any value in having a small binary for the shared library? One could argue the symbols do not hurt and may help debug exotic crashed on live chains.

If we want to enable stripping, I suggest letting Rust do it directly. There are two ways:

  1. Current workaround: RUSTFLAGS='-C link-arg=-s' cargo build --release
  2. The almost stable cargo configuration: https://github.com/rust-lang/rust/issues/72110

For now, I'll remove all reference to extra OS specific strip tools.

ethanfrey commented 3 years ago

5MB off of a 50-60MB wasmd binary is not a major issue IMO.

We could see what the size difference is with the stripped/unstripped DLLs. And then the current size of wasmd and guess what this will effect. But I don't see too much need to optimize for binary size.

webmaster128 commented 1 month ago

I just tried

diff --git a/libwasmvm/Cargo.toml b/libwasmvm/Cargo.toml
index d606b32..d9e76bf 100644
--- a/libwasmvm/Cargo.toml
+++ b/libwasmvm/Cargo.toml
@@ -61,3 +61,4 @@ codegen-units = 16
 panic = 'unwind'
 incremental = true
 overflow-checks = true
+strip = "debuginfo"

which is stable now. This is the size comparisons

File Before After
internal/api/libwasmvm.aarch64.so 11M 7,6M
internal/api/libwasmvm.dylib 14M 14M
internal/api/libwasmvm.x86_64.so 11M 8,0M
internal/api/libwasmvm_muslc.aarch64.a 71M 71M
internal/api/libwasmvm_muslc.x86_64.a 69M 69M

As you can see, only the Linux .so files benefit from the stripping. The static libraries don't change and the .dylib cannot be stripped on a Linux builder image:

warning: stripping debug info with `strip` failed: exit status: 1
  |
  = note: strip: /code/target/aarch64-apple-darwin/release/deps/libwasmvm.dylib: file format not recognized

[...]

warning: stripping debug info with `strip` failed: exit status: 1
  |
  = note: strip: /code/target/x86_64-apple-darwin/release/deps/libwasmvm.dylib: file format not recognized

Overall, closing as not worth the effort