Skip to content

Commit 4e7c34b

Browse files
build: optimize wasm with bulk memory support
Run wasm-opt separately after build to enable bulk memory. This fixes compilation problems with rust nightly. Issue: BTC-0
1 parent c385071 commit 4e7c34b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/wasm-miniscript/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
WASM_PACK = wasm-pack
2+
WASM_OPT = wasm-opt
23
WASM_PACK_FLAGS = --no-pack --weak-refs
34

45
ifdef WASM_PACK_DEV
56
WASM_PACK_FLAGS += --dev
67
endif
78

89
define WASM_PACK_COMMAND
9-
$(WASM_PACK) build --out-dir $(1) $(WASM_PACK_FLAGS) --target $(2)
10+
$(WASM_PACK) build --no-opt --out-dir $(1) $(WASM_PACK_FLAGS) --target $(2)
11+
endef
12+
13+
# run wasm-opt separately so we can pass `--enable-bulk-memory`
14+
define WASM_OPT_COMMAND
15+
$(WASM_OPT) --enable-bulk-memory -Oz $(1)/*.wasm -o $(1)/*.wasm
1016
endef
1117

1218
define REMOVE_GITIGNORE
@@ -22,6 +28,7 @@ endef
2228
define BUILD
2329
rm -rf $(1)
2430
$(call WASM_PACK_COMMAND,$(1),$(2))
31+
$(call WASM_OPT_COMMAND,$(1))
2532
$(call REMOVE_GITIGNORE,$(1))
2633
$(call SHOW_WASM_SIZE,$(1))
2734
endef

0 commit comments

Comments
 (0)