From 467ae04f45e201f6e1ea4ea4af75afcb96277495 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 13 Sep 2024 18:49:58 +0900 Subject: [PATCH 1/2] templates/c: enable bulk-memory to reduce the cart size a bit wasm-ld emits a data section for bss if the memory is imported. --- cli/assets/templates/c/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/assets/templates/c/Makefile b/cli/assets/templates/c/Makefile index 23740b14..bbf64e79 100644 --- a/cli/assets/templates/c/Makefile +++ b/cli/assets/templates/c/Makefile @@ -13,7 +13,7 @@ WASM_OPT_FLAGS = -Oz --zero-filled-memory --strip-producers DEBUG = 0 # Compilation flags -CFLAGS = -W -Wall -Wextra -Werror -Wno-unused -Wconversion -Wsign-conversion -MMD -MP -fno-exceptions +CFLAGS = -W -Wall -Wextra -Werror -Wno-unused -Wconversion -Wsign-conversion -MMD -MP -fno-exceptions -mbulk-memory ifeq ($(DEBUG), 1) CFLAGS += -DDEBUG -O0 -g else From 3053b66ee81c3aee4187b2d1588f1d5fdf5d95a7 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 13 Sep 2024 18:51:14 +0900 Subject: [PATCH 2/2] templates/c: Add --enable-bulk-memory to WASM_OPT_FLAGS whether or not we compile our code with bulk-memory, wasi-sdk ships some functions built with bulk-memory. (memset etc) --- cli/assets/templates/c/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/assets/templates/c/Makefile b/cli/assets/templates/c/Makefile index bbf64e79..2d3cd424 100644 --- a/cli/assets/templates/c/Makefile +++ b/cli/assets/templates/c/Makefile @@ -7,7 +7,7 @@ CXX = "$(WASI_SDK_PATH)/bin/clang++" --sysroot="$(WASI_SDK_PATH)/share/wasi-sysr # Optional dependency from binaryen for smaller builds WASM_OPT = wasm-opt -WASM_OPT_FLAGS = -Oz --zero-filled-memory --strip-producers +WASM_OPT_FLAGS = -Oz --zero-filled-memory --strip-producers --enable-bulk-memory # Whether to build for debugging instead of release DEBUG = 0