diff --git a/tools/Wasm.mk b/tools/Wasm.mk index 28627c115d..f42aae3563 100644 --- a/tools/Wasm.mk +++ b/tools/Wasm.mk @@ -42,7 +42,12 @@ define LINK_WASM $(if $(RETVAL), \ $(error wasm build failed for $(PROGNAME).wasm) \ ) \ - $(call WAMR_AOT_COMPILE) \ + $(eval RETVAL=$(shell $(WASI_SDK_PATH)/wasm-opt -Oz -o $(BINDIR)$(DELIM)wasm$(DELIM)$(PROGNAME).wasm \ + $(BINDIR)$(DELIM)wasm$(DELIM)$(PROGNAME).wasm || echo 1;)) \ + $(if $(RETVAL), \ + $(error wasm build failed for $(PROGNAME).wasm) \ + ) \ + $(call WAMR_AOT_COMPILE) \ ) \ ) endef