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/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 09d7785 Application.mk: Link the compiler runtime for ELF modules
09d7785 is described below
commit 09d778558c31ee6833ca52ba827e96263a47bcf0
Author: YAMAMOTO Takashi <[email protected]>
AuthorDate: Thu Jan 27 18:25:09 2022 +0900
Application.mk: Link the compiler runtime for ELF modules
An alternative is to have symbols like __udivdi3 in
the symbol table explicitly when loading the module.
But I feel it's too cumbersome to maintain.
---
Application.mk | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/Application.mk b/Application.mk
index a0371cb..1f344d5 100644
--- a/Application.mk
+++ b/Application.mk
@@ -69,6 +69,18 @@ ifneq ($(CONFIG_BUILD_KERNEL),y)
endif
endif
+# When building a module, link with the compiler runtime.
+# This should be linked after libapps. Consider that mbedtls in libapps
+# uses __udivdi3.
+ifeq ($(BUILD_MODULE),y)
+ # Revisit: This only works for gcc and clang.
+ # Do other compilers have similar?
+ COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
+ ifneq ($(COMPILER_RT_LIB),)
+ LDLIBS += $(COMPILER_RT_LIB)
+ endif
+endif
+
SUFFIX = $(subst $(DELIM),.,$(CWD))
PROGNAME := $(shell echo $(PROGNAME))