xiaoxiang781216 commented on code in PR #3884:
URL: https://github.com/apache/nuttx-apps/pull/3884#discussion_r4316895026


##########
Library.mk:
##########
@@ -66,6 +66,17 @@ LOCAL_CXX_OBJS := 
$(LOCAL_CXX_SRCS:%=$(LOCAL_PREFIX)%$(LOCAL_SUFFIX)$(OBJEXT))
 LOCAL_OBJS     := $(LOCAL_C_OBJS) $(LOCAL_CC_OBJS) $(LOCAL_CPP_OBJS) \
                   $(LOCAL_CXX_OBJS)
 
+# With CONFIG_LTO_FULL the compiler driver links the library: a partial
+# link (-r) must compile the LTO objects to machine code with the compile
+# options.
+
+ifneq ($(filter %gcc,$(firstword $(MODULELD))),)
+  ifneq ($(filter -r,$(LDMODULEFLAGS)),)
+    LDMODULEFLAGS += -flinker-output=nolto-rel \

Review Comment:
   ditto



##########
Application.mk:
##########
@@ -134,19 +134,37 @@ ifneq ($(strip $(PROGNAME)),)
     $(eval MODE_$(word $i,$(PROGLIST)) := $(MODE_$(word $i,$(REGLIST)))) \
   )
 
+  # With CONFIG_LTO_FULL the compiler driver links the module: a linker
+  # option needs -Wl, and a partial link (-r) must compile the LTO objects
+  # to machine code with the compile options (-mthumb, -mlong-calls, ...),
+  # as the loader cannot use LTO data.
+
+  ifneq ($(filter %gcc %clang,$(firstword $(MODULELD))),)
+    DEFSYM = -Wl,--defsym=
+  else
+    DEFSYM = --defsym=
+  endif
+
+  ifneq ($(filter %gcc,$(firstword $(MODULELD))),)
+    ifneq ($(filter -r,$(MODLDFLAGS)),)
+      MODLDFLAGS += -flinker-output=nolto-rel \

Review Comment:
   why not fix in the initial definition of MODLDFLAGS



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to