From e1fdbd7936afaad594758795024ba27a09b930d3 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Thu, 1 Jun 2023 12:09:11 +0800 Subject: [PATCH] tools/Wasm.mk: Link compiler-rt into wasm module Link `libgcc.a` like compiler intrinsics library into wasm module. Signed-off-by: Huang Qi --- tools/Wasm.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/Wasm.mk b/tools/Wasm.mk index ba4f53463..7b8fe6a98 100644 --- a/tools/Wasm.mk +++ b/tools/Wasm.mk @@ -59,6 +59,13 @@ 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 +COMPILER_RT_LIB = $(shell $(WCC) --print-libgcc-file-name) +ifeq ($(wildcard $(COMPILER_RT_LIB)),) + # if "--print-libgcc-file-name" unable to find the correct libgcc PATH + # then go ahead and try "--print-file-name" + COMPILER_RT_LIB := $(wildcard $(shell $(WCC) --print-file-name $(notdir $(COMPILER_RT_LIB)))) +endif + # If called from $(APPDIR)/Make.defs, WASM_BUILD is not defined # Provide LINK_WASM, but only execute it when file wasm/*.wo exists @@ -71,7 +78,8 @@ 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)) \ - $(shell $(WCC) $(bin) $(WBIN) $(WCFLAGS) $(WLDFLAGS) -o $(APPDIR)$(DELIM)wasm$(DELIM)$(PROGNAME).wasm) \ + $(shell $(WCC) $(bin) $(WBIN) $(WCFLAGS) $(WLDFLAGS) $(COMPILER_RT_LIB) \ + -o $(APPDIR)$(DELIM)wasm$(DELIM)$(PROGNAME).wasm) \ $(call WAMR_AOT_COMPILE) \ ) \ )