commit 5faff7d783dfea4f830725938fd96a6bd3829d71
parent 28ab8f182764279ec2d15f5137dc8c9a530c26a5
Author: parazyd <parazyd@dyne.org>
Date: Fri, 11 Mar 2022 13:21:13 +0100
Use lto when building wasm binary to reduce size.
Diffstat:
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -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
diff --git a/smart-contract/Cargo.toml b/smart-contract/Cargo.toml
@@ -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
diff --git a/src/runtime.rs b/src/runtime.rs
@@ -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(())
}