This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new e1fdbd793 tools/Wasm.mk: Link compiler-rt into wasm module
e1fdbd793 is described below

commit e1fdbd7936afaad594758795024ba27a09b930d3
Author: Huang Qi <[email protected]>
AuthorDate: Thu Jun 1 12:09:11 2023 +0800

    tools/Wasm.mk: Link compiler-rt into wasm module
    
    Link `libgcc.a` like compiler intrinsics library into wasm module.
    
    Signed-off-by: Huang Qi <[email protected]>
---
 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) \
           ) \
         )

Reply via email to