tools: Allow customize ld flags for each wasm module

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2023-11-21 10:52:56 +08:00 committed by Xiang Xiao
parent bd159e103c
commit 3c624d38cd
2 changed files with 3 additions and 1 deletions

View File

@ -73,7 +73,7 @@ ifeq ($(CONFIG_LIBM),)
WCFLAGS += -DCONFIG_LIBM=1 -I$(APPDIR)$(DELIM)include$(DELIM)wasm
endif
WLDFLAGS += -z stack-size=$(STACKSIZE) -Wl,--initial-memory=$(INITIAL_MEMORY)
WLDFLAGS += -z stack-size=$(STACKSIZE) -Wl,--initial-memory=$(WASM_INITIAL_MEMORY)
WLDFLAGS += -Wl,--export=main -Wl,--export=__main_argc_argv
WLDFLAGS += -Wl,--export=__heap_base -Wl,--export=__data_end
WLDFLAGS += -Wl,--no-entry -Wl,--strip-all -Wl,--allow-undefined

View File

@ -36,6 +36,7 @@ define LINK_WASM
$(eval INITIAL_MEMORY=$(shell echo $(notdir $(bin)) | cut -d'#' -f2)) \
$(eval STACKSIZE=$(shell echo $(notdir $(bin)) | cut -d'#' -f3)) \
$(eval PROGNAME=$(shell echo $(notdir $(bin)) | cut -d'#' -f1)) \
$(eval WLDFLAGS=$(shell cat $(APPDIR)$(DELIM)wasm$(DELIM)$(PROGNAME).ldflags)) \
$(eval RETVAL=$(shell $(WCC) $(bin) $(WBIN) $(WCFLAGS) $(WLDFLAGS) $(WCC_COMPILER_RT_LIB) \
-Wl,--Map=$(APPDIR)$(DELIM)wasm$(DELIM)$(PROGNAME).map \
-o $(APPDIR)$(DELIM)wasm$(DELIM)$(PROGNAME).wasm || echo 1;)) \
@ -99,6 +100,7 @@ $(WBIN): $(WOBJS)
$(shell cp -rf $(strip $(main:=$(SUFFIX).wo)) \
$(strip $(APPDIR)/wasm/$(progname)#$(WASM_INITIAL_MEMORY)#$(STACKSIZE)#$(PRIORITY)#$(WAMR_MODE)#$(dstname)) \
) \
$(shell echo $(WLDFLAGS) > $(APPDIR)/wasm/$(progname).ldflags) \
)
clean::