You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/06/27 18:31:59 UTC

(nuttx) branch master updated: x86_64: hide --whole-archive behind Kconfig option

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.git


The following commit(s) were added to refs/heads/master by this push:
     new 09146beee9 x86_64: hide --whole-archive behind Kconfig option
09146beee9 is described below

commit 09146beee94c06635012eed2bab6c4a52ec89450
Author: p-szafonimateusz <p-...@xiaomi.com>
AuthorDate: Thu Jun 27 12:21:29 2024 +0200

    x86_64: hide --whole-archive behind Kconfig option
    
    Hide --whole-archive behind Kconfig option for x86.
    This option is not needed and breaks ELF modules build.
    
    Signed-off-by: p-szafonimateusz <p-...@xiaomi.com>
---
 arch/x86_64/src/Makefile              | 2 +-
 arch/x86_64/src/cmake/Toolchain.cmake | 4 ++++
 arch/x86_64/src/common/Toolchain.defs | 4 ++++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86_64/src/Makefile b/arch/x86_64/src/Makefile
index 0c97c4bc6b..c436a6996e 100644
--- a/arch/x86_64/src/Makefile
+++ b/arch/x86_64/src/Makefile
@@ -113,7 +113,7 @@ nuttx$(EXEEXT): board/libboard$(LIBEXT) $(ARCHSCRIPT)
 	@echo "LD: nuttx$(EXEEXT)"
 	$(Q) $(LD) $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
 		-o $(NUTTX) $(EXTRA_OBJS) \
-		$(LDSTARTGROUP) $(EXTRA_LIBS) --whole-archive --no-relax $(LDLIBS) $(LDENDGROUP)
+		$(LDSTARTGROUP) $(EXTRA_LIBS) --no-relax $(LDLIBS) $(LDENDGROUP)
 ifneq ($(CONFIG_WINDOWS_NATIVE),y)
 	$(Q) $(NM) $(NUTTX) | \
 	grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
diff --git a/arch/x86_64/src/cmake/Toolchain.cmake b/arch/x86_64/src/cmake/Toolchain.cmake
index f28384815b..3d79887381 100644
--- a/arch/x86_64/src/cmake/Toolchain.cmake
+++ b/arch/x86_64/src/cmake/Toolchain.cmake
@@ -116,6 +116,10 @@ if(CONFIG_DEBUG_OPT_UNUSED_SECTIONS)
   add_compile_options(-ffunction-sections -fdata-sections)
 endif()
 
+if(CONFIG_DEBUG_LINK_WHOLE_ARCHIVE)
+  add_link_options(-Wl,--whole-archive)
+endif()
+
 if(CONFIG_ARCH_INTEL64_HAVE_RDRAND)
   add_compile_options(-mrdrnd)
 endif()
diff --git a/arch/x86_64/src/common/Toolchain.defs b/arch/x86_64/src/common/Toolchain.defs
index 68ef67cf5f..32264de3cc 100644
--- a/arch/x86_64/src/common/Toolchain.defs
+++ b/arch/x86_64/src/common/Toolchain.defs
@@ -43,6 +43,10 @@ ifeq ($(CONFIG_HOST_MACOS),y)
 CROSSDEV = x86_64-elf-
 endif
 
+ifeq ($(CONFIG_DEBUG_LINK_WHOLE_ARCHIVE),y)
+  LDFLAGS += --whole-archive
+endif
+
 CC = $(CROSSDEV)gcc
 CPP = $(CROSSDEV)gcc -E -x c
 LD = $(CROSSDEV)ld