tUse lto when building wasm binary to reduce size. - wasm-runtime - A wasm runtime
HTML git clone https://git.parazyd.org/wasm-runtime
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 5faff7d783dfea4f830725938fd96a6bd3829d71
DIR parent 28ab8f182764279ec2d15f5137dc8c9a530c26a5
HTML Author: parazyd <parazyd@dyne.org>
Date: Fri, 11 Mar 2022 13:21:13 +0100
Use lto when building wasm binary to reduce size.
Diffstat:
M Makefile | 1 +
M smart-contract/Cargo.toml | 5 +++++
M src/runtime.rs | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
---
DIR diff --git a/Makefile b/Makefile
t@@ -19,5 +19,6 @@ wabt:
smart_contract.wasm: $(SRC)
cd smart-contract && $(CARGO) build --release --lib --target wasm32-unknown-unknown
cp -f smart-contract/target/wasm32-unknown-unknown/release/$@ $@
+ -wabt/bin/wasm-strip $@
.PHONY: all
DIR diff --git a/smart-contract/Cargo.toml b/smart-contract/Cargo.toml
t@@ -14,3 +14,8 @@ drk-sdk = { path = "../drk-sdk" }
git = "https://github.com/parazyd/pasta_curves"
branch = "optional-borsh-support"
features = ["borsh"]
+
+[profile.release]
+lto = true
+codegen-units = 1
+overflow-checks = true
DIR diff --git a/src/runtime.rs b/src/runtime.rs
t@@ -33,7 +33,7 @@ impl WasmerEnv for Env {
&mut self,
instance: &Instance,
) -> std::result::Result<(), HostEnvInitError> {
- let memory: Memory = instance.exports.get_with_generics_weak("memory").unwrap();
+ let memory: Memory = instance.exports.get_with_generics_weak("memory")?;
self.memory.initialize(memory);
Ok(())
}