Skip to contentSkip to conversation

common: Link with GCC instead of LD

PATCH New Marek Vasut 4 participants 12 messages Oct 31, 2012 – Nov 1, 2012

Subsystems (7)
x86 PowerPC Kbuild MIPS +3 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common: Link with GCC instead of LD

Flip over from linking with LD to linking with GCC. This has some long-term benefits, like easy path to enabling LTO.

Most of this patch is about passing parameters to the linker invoked by GCC at the linking stage. This involves prefixing most of these with -Wl,<param> . A few more adjustments had to be made though.

The LDFLAGS had to be extended by --build-id=none to prevent generation of the .note.gnu.build-id section, which contains unique build-id we don't care about. Moreover -nostdlib had to be added to LDFLAGS to link properly without pulling in GCC libs during partial link.

The LDFLAGS_FINAL had to be augmented by -Wl,-allow-multiple-definition to prevent GCC from complaining about multiple definitions of the register containing global data.

Cc Albert Aribaud <[email protected]>
Cc Joe Hershberger <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 Makefile                                       |    4 ++--
 arch/avr32/config.mk                           |    2 +-
 arch/blackfin/config.mk                        |    4 ++--
 arch/m68k/config.mk                            |    4 ++--
 arch/m68k/cpu/mcf5445x/config.mk               |    2 +-
 arch/m68k/cpu/mcf547x_8x/config.mk             |    2 +-
 arch/mips/config.mk                            |    4 ++--
 arch/mips/cpu/mips64/config.mk                 |    4 ++--
 arch/nds32/config.mk                           |    2 +-
 arch/nios2/config.mk                           |    2 +-
 arch/powerpc/config.mk                         |    2 +-
 arch/sh/config.mk                              |    4 ++--
 arch/x86/config.mk                             |    8 ++++----
 board/ait/cam_enc_4xx/config.mk                |    2 +-
 config.mk                                      |   15 +++++++--------
 examples/standalone/Makefile                   |    4 ++--
 nand_spl/board/amcc/acadia/Makefile            |    2 +-
 nand_spl/board/amcc/bamboo/Makefile            |    2 +-
 nand_spl/board/amcc/canyonlands/Makefile       |    2 +-
 nand_spl/board/amcc/kilauea/Makefile           |    2 +-
 nand_spl/board/amcc/sequoia/Makefile           |    2 +-
 nand_spl/board/freescale/mpc8313erdb/Makefile  |    2 +-
 nand_spl/board/freescale/mpc8315erdb/Makefile  |    2 +-
 nand_spl/board/freescale/mpc8536ds/Makefile    |    2 +-
 nand_spl/board/freescale/mpc8569mds/Makefile   |    2 +-
 nand_spl/board/freescale/mpc8572ds/Makefile    |    2 +-
 nand_spl/board/freescale/mx31pdk/Makefile      |    2 +-
 nand_spl/board/freescale/p1010rdb/Makefile     |    2 +-
 nand_spl/board/freescale/p1023rds/Makefile     |    2 +-
 nand_spl/board/freescale/p1_p2_rdb/Makefile    |    2 +-
 nand_spl/board/freescale/p1_p2_rdb_pc/Makefile |    2 +-
 nand_spl/board/karo/tx25/Makefile              |    2 +-
 nand_spl/board/samsung/smdk6400/Makefile       |    2 +-
 nand_spl/board/sheldon/simpc8313/Makefile      |    2 +-
 spl/Makefile                                   |    4 ++--
 35 files changed, 52 insertions(+), 53 deletions(-)

NOTE: It should mostly work, but _PLEASE_ test it properly. I definitelly
can not run it on most of the affected platforms. Besides, it might still hit some build issues, it's not properly compiler-tested. Any additional fixes are welcome ;-)

NOTE: I detected code size being smaller by a few bytes, but then it might
cause breakage, so I'd be really cautious here.

Makefile +2 -2
index 2fe1490..d6b3433 100644
@@ -539,8 +539,8 @@ GEN_UBOOT = \
 		sed  -n -e 's/.*\($(SYM_PREFIX)_u_boot_list_.*\)/-u\1/p'|sort|uniq`;\
 		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
 			$$UNDEF_LST $(__OBJS) \
-			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
-			-Map u-boot.map -o u-boot
+			-Wl,--start-group $(__LIBS) -Wl,--end-group \
+			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
 endif
 
 $(obj)u-boot:	depend \
arch/avr32/config.mk +1 -1
index a751a3d..151f232 100644
@@ -28,4 +28,4 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000
 PLATFORM_RELFLAGS	+= -ffixed-r5 -fPIC -mno-init-got -mrelax
 PLATFORM_RELFLAGS	+= -ffunction-sections -fdata-sections
 
-LDFLAGS_u-boot		= --gc-sections --relax
+LDFLAGS_u-boot		= -Wl,--gc-sections -Wl,--relax
arch/blackfin/config.mk +2 -2
index 3595aa2..cbfba5f 100644
@@ -37,8 +37,8 @@ CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE)))
 PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic
 PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN
 
-LDFLAGS_FINAL += --gc-sections
-LDFLAGS += -m elf32bfin
+LDFLAGS_FINAL += -Wl,--gc-sections
+LDFLAGS += -Wl,-m elf32bfin
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
 
 PLATFORM_RELFLAGS += -mcpu=$(CONFIG_BFIN_CPU)
arch/m68k/config.mk +2 -2
index 11ba334..2e5adb9 100644
@@ -26,6 +26,6 @@ CROSS_COMPILE ?= m68k-elf-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x20000
 
 PLATFORM_CPPFLAGS += -DCONFIG_M68K -D__M68K__
-PLATFORM_LDFLAGS  += -n
+PLATFORM_LDFLAGS  += -Wl,-n
 PLATFORM_RELFLAGS              += -ffunction-sections -fdata-sections
-LDFLAGS_FINAL                  += --gc-sections
+LDFLAGS_FINAL                  += -Wl,--gc-sections
arch/m68k/cpu/mcf5445x/config.mk +1 -1
index 0c48783..bd216a9 100644
@@ -38,6 +38,6 @@ endif
 
 ifneq (,$(findstring -linux-,$(shell $(CC) --version)))
 ifneq (,$(findstring GOT,$(shell $(LD) --help)))
-PLATFORM_LDFLAGS += --got=single
+PLATFORM_LDFLAGS += -Wl,--got=single
 endif
 endif
arch/m68k/cpu/mcf547x_8x/config.mk +1 -1
index 02fce5d..00907d3 100644
@@ -28,6 +28,6 @@ PLATFORM_CPPFLAGS += -mcpu=5485 -fPIC
 
 ifneq (,$(findstring -linux-,$(shell $(CC) --version)))
 ifneq (,$(findstring GOT,$(shell $(LD) --help)))
-PLATFORM_LDFLAGS += --got=single
+PLATFORM_LDFLAGS += -Wl,--got=single
 endif
 endif
arch/mips/config.mk +2 -2
index de9140b..c21d313 100644
@@ -63,6 +63,6 @@ PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
 #
 PLATFORM_CPPFLAGS		+= -G 0 -mabicalls -fpic $(ENDIANNESS)
 PLATFORM_CPPFLAGS		+= -msoft-float
-PLATFORM_LDFLAGS		+= -G 0 -static -n -nostdlib $(ENDIANNESS)
+PLATFORM_LDFLAGS		+= -G 0 -static -Wl,-n $(ENDIANNESS)
 PLATFORM_RELFLAGS		+= -ffunction-sections -fdata-sections
-LDFLAGS_FINAL			+= --gc-sections
+LDFLAGS_FINAL			+= -Wl,--gc-sections
arch/mips/cpu/mips64/config.mk +2 -2
index ebc1ceb..d9fbf27 100644
@@ -32,9 +32,9 @@ MIPSFLAGS = -march=mips64
 PLATFORM_CPPFLAGS += $(MIPSFLAGS)
 PLATFORM_CPPFLAGS += -mabi=64 -DCONFIG_64BIT
 ifdef CONFIG_SYS_BIG_ENDIAN
-PLATFORM_LDFLAGS  += -m elf64btsmip
+PLATFORM_LDFLAGS  += -Wl,-m elf64btsmip
 else
-PLATFORM_LDFLAGS  += -m elf64ltsmip
+PLATFORM_LDFLAGS  += -Wl,-m elf64ltsmip
 endif
 
 CONFIG_STANDALONE_LOAD_ADDR ?= 0xffffffff80200000 -T mips64.lds
arch/nds32/config.mk +1 -1
index c589829..eccd2e6 100644
@@ -32,4 +32,4 @@ PLATFORM_RELFLAGS	+= -fno-strict-aliasing -fno-common -mrelax
 PLATFORM_RELFLAGS	+= -gdwarf-2
 PLATFORM_CPPFLAGS	+= -DCONFIG_NDS32 -D__nds32__ -G0 -ffixed-10 -fpie
 
-LDFLAGS_u-boot		= --gc-sections --relax
+LDFLAGS_u-boot		= -Wl,--gc-sections -Wl,--relax
arch/nios2/config.mk +1 -1
index 7b03ed8..9f9f6ac 100644
@@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x02000000
 PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__
 PLATFORM_CPPFLAGS += -G0
 
-LDFLAGS_FINAL += --gc-sections
+LDFLAGS_FINAL += -Wl,--gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
arch/powerpc/config.mk +1 -1
index a307154..87e4934 100644
@@ -24,7 +24,7 @@
 CROSS_COMPILE ?= ppc_8xx-
 
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
-LDFLAGS_FINAL += --gc-sections
+LDFLAGS_FINAL += -Wl,--gc-sections
 PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections
 PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
 PLATFORM_LDFLAGS  += -n
arch/sh/config.mk +2 -2
index 07ff8b9..3451223 100644
@@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR += -EB
 endif
 
 PLATFORM_CPPFLAGS += -DCONFIG_SH -D__SH__
-PLATFORM_LDFLAGS += -e $(CONFIG_SYS_TEXT_BASE) --defsym reloc_dst=$(CONFIG_SYS_TEXT_BASE)
-LDFLAGS_FINAL = --gc-sections
+PLATFORM_LDFLAGS += -Wl,-e $(CONFIG_SYS_TEXT_BASE) -Wl,--defsym reloc_dst=$(CONFIG_SYS_TEXT_BASE)
+LDFLAGS_FINAL = -Wl,--gc-sections
arch/x86/config.mk +4 -4
index 23cacff..b3b07cc 100644
@@ -38,11 +38,11 @@ PLATFORM_CPPFLAGS += -DREALMODE_BASE=0x7c0
 
 PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
 
-PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions
+PLATFORM_LDFLAGS += -Wl,--emit-relocs -Wl,-Bsymbolic -Wl,-Bsymbolic-functions
 
-LDFLAGS_FINAL += --gc-sections -pie
-LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
-LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
+LDFLAGS_FINAL += -Wl,--gc-sections -pie
+LDFLAGS_FINAL += -Wl,--wrap=__divdi3 -Wl,--wrap=__udivdi3
+LDFLAGS_FINAL += -Wl,--wrap=__moddi3 -Wl,--wrap=__umoddi3
 
 NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
 PREFIXED_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/$(shell basename $(NORMAL_LIBGCC))
board/ait/cam_enc_4xx/config.mk +1 -1
index 744b927..0792c84 100644
@@ -18,5 +18,5 @@ else
 # the following error message:
 # arm-linux-ld: u-boot-spl: Not enough room for program headers, try linking
 # with -N
-LDFLAGS_u-boot-spl += -n
+LDFLAGS_u-boot-spl += -Wl,-n
 endif
config.mk +7 -8
index b7cd481..ec8cd6b 100644
@@ -137,9 +137,8 @@ binutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS))
 #
 AS	= $(CROSS_COMPILE)as
 
-# Always use GNU ld
-LD	= $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
-		then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;)
+# Link with GCC
+LD	= $(CROSS_COMPILE)gcc
 
 CC	= $(CROSS_COMPILE)gcc
 CPP	= $(CC) -E
@@ -202,7 +201,7 @@ CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
 # Enable garbage collection of un-used sections for SPL
 ifeq ($(CONFIG_SPL_BUILD),y)
 CPPFLAGS += -ffunction-sections -fdata-sections
-LDFLAGS_FINAL += --gc-sections
+LDFLAGS_FINAL += -Wl,--gc-sections -Wl,--build-id=none
 endif
 
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
@@ -265,17 +264,17 @@ endif
 
 AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
 
-LDFLAGS += $(PLATFORM_LDFLAGS)
-LDFLAGS_FINAL += -Bstatic
+LDFLAGS += $(PLATFORM_LDFLAGS) -Wl,--build-id=none -nostdlib
+LDFLAGS_FINAL += -Wl,-Bstatic -Wl,-allow-multiple-definition
 
 LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
-LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
+LDFLAGS_u-boot += -Wl,-Ttext -Wl,$(CONFIG_SYS_TEXT_BASE)
 endif
 
 LDFLAGS_u-boot-spl += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SPL_TEXT_BASE),)
-LDFLAGS_u-boot-spl += -Ttext $(CONFIG_SPL_TEXT_BASE)
+LDFLAGS_u-boot-spl += -Wl,-Ttext -Wl,$(CONFIG_SPL_TEXT_BASE)
 endif
 
 # Linus' kernel sanity checking tool
examples/standalone/Makefile +2 -2
index baaa2fb..eaf8bb3 100644
@@ -96,8 +96,8 @@ $(LIB):	$(obj).depend $(LIBOBJS)
 
 $(ELF):
 $(obj)%:	$(obj)%.o $(LIB)
-		$(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
-			-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
+		$(LD) $(LDFLAGS) -g -Wl,-Ttext -Wl,$(CONFIG_STANDALONE_LOAD_ADDR) \
+			-o $@ -Wl,-e -Wl,$(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
 			-L$(gcclibdir) -lgcc
 
 $(SREC):
nand_spl/board/amcc/acadia/Makefile +1 -1
index 84cb8ab..6a75e34 100644
@@ -27,7 +27,7 @@ include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/amcc/bamboo/Makefile +1 -1
index 6430219..5fa1a3b 100644
@@ -27,7 +27,7 @@ include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/amcc/canyonlands/Makefile +1 -1
index 509a46e..4e2eae4 100644
@@ -27,7 +27,7 @@ include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/amcc/kilauea/Makefile +1 -1
index 104b7e2..55900ed 100644
@@ -27,7 +27,7 @@ include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/amcc/sequoia/Makefile +1 -1
index 54e8a12..dc41c1f 100644
@@ -27,7 +27,7 @@ include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/freescale/mpc8313erdb/Makefile +1 -1
index cff2a43..9fe4472 100644
@@ -30,7 +30,7 @@ include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 	   $(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/freescale/mpc8315erdb/Makefile +1 -1
index cff2a43..9fe4472 100644
@@ -30,7 +30,7 @@ include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 	   $(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/freescale/mpc8536ds/Makefile +1 -1
index e5388d8..6d91269 100644
@@ -33,7 +33,7 @@ nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/freescale/mpc8569mds/Makefile +1 -1
index e5388d8..6d91269 100644
@@ -33,7 +33,7 @@ nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/freescale/mpc8572ds/Makefile +1 -1
index e5388d8..6d91269 100644
@@ -33,7 +33,7 @@ nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/freescale/mx31pdk/Makefile +1 -1
index 43e72c4..1213cf2 100644
@@ -7,7 +7,7 @@ nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
nand_spl/board/freescale/p1010rdb/Makefile +1 -1
index f270faa..8dfaf0c 100644
@@ -33,7 +33,7 @@ nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/freescale/p1023rds/Makefile +1 -1
index b288284..39b2588 100644
@@ -28,7 +28,7 @@ nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/freescale/p1_p2_rdb/Makefile +1 -1
index e5388d8..6d91269 100644
@@ -33,7 +33,7 @@ nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/freescale/p1_p2_rdb_pc/Makefile +1 -1
index 7146d16..b3514ac 100644
@@ -33,7 +33,7 @@ nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
nand_spl/board/karo/tx25/Makefile +1 -1
index becf7fa..628bfee 100644
@@ -28,7 +28,7 @@ nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
nand_spl/board/samsung/smdk6400/Makefile +1 -1
index c9e75ba..75b7b0f 100644
@@ -32,7 +32,7 @@ include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 		$(LDFLAGS_FINAL) -gc-sections
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL -ffunction-sections
nand_spl/board/sheldon/simpc8313/Makefile +1 -1
index 2a3ddac..a73fa87 100644
@@ -30,7 +30,7 @@ include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 	   $(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
spl/Makefile +2 -2
index 3195390..6d9b4ae 100644
@@ -139,8 +139,8 @@ $(obj)u-boot-spl.bin:	$(obj)u-boot-spl
 
 GEN_UBOOT = \
 	cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \
-		--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
-		-Map u-boot-spl.map -o u-boot-spl
+		-Wl,--start-group -Wl,$(__LIBS) -Wl,--end-group -Wl,$(PLATFORM_LIBS) \
+		-Wl,-Map=u-boot-spl.map -o u-boot-spl
 
 $(obj)u-boot-spl:	depend $(START) $(LIBS) $(obj)u-boot-spl.lds
 	$(GEN_UBOOT)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 common: Link with GCC instead of LD

Dear Marek Vasut,

Quoted 33 lines · Marek Vasut

Flip over from linking with LD to linking with GCC. This has some long-term benefits, like easy path to enabling LTO.

Most of this patch is about passing parameters to the linker invoked by GCC at the linking stage. This involves prefixing most of these with -Wl,<param> . A few more adjustments had to be made though.

The LDFLAGS had to be extended by --build-id=none to prevent generation of the .note.gnu.build-id section, which contains unique build-id we don't care about. Moreover -nostdlib had to be added to LDFLAGS to link properly without pulling in GCC libs during partial link.

The LDFLAGS_FINAL had to be augmented by -Wl,-allow-multiple-definition to prevent GCC from complaining about multiple definitions of the register containing global data.

Cc Albert Aribaud <[email protected]>
Cc Joe Hershberger <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>

---

NOTE: It should mostly work, but _PLEASE_ test it properly. I definitelly
can not run it on most of the affected platforms. Besides, it might still hit some build issues, it's not properly compiler-tested. Any additional fixes are welcome ;-)

NOTE: I detected code size being smaller by a few bytes, but then it might
cause breakage, so I'd be really cautious here.

<snip>

config.mk binutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS)) · line 141

Quoted 13 lines
config.mk +2 -3
index b7cd481..ec8cd6b 100644
@@ -137,9 +137,8 @@ binutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS))
 #
 AS	= $(CROSS_COMPILE)as
 
-# Always use GNU ld
-LD	= $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
-		then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;)
+# Link with GCC
+LD	= $(CROSS_COMPILE)gcc

with this change we should also remove LD_VERSION_STRING from $(VERSION_FILE). Currently it will call 'gcc -v' which will print compile switches to stderr.

Compiled and runtime tested on avr32 atngw100mkii, on first sight it seems sane.

Best regards

Andreas Bie?mann

#2 lore raw

PATCH 1/1 common: Link with GCC instead of LD

Dear Andreas Bie?mann,

[...]

Quoted 3 lines

config.mk binutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS))

Quoted 3 lines
config.mk +0 -3
-# Always use GNU ld
-LD	= $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
-		then echo "$(CROSS_COMPILE)ld.bfd"; else echo 

"$(CROSS_COMPILE)ld";

Quoted 9 lines
Quoted 2 lines

fi;) +# Link with GCC
+LD = $(CROSS_COMPILE)gcc

with this change we should also remove LD_VERSION_STRING from $(VERSION_FILE). Currently it will call 'gcc -v' which will print compile switches to stderr.

Compiled and runtime tested on avr32 atngw100mkii, on first sight it seems sane.

Good catch. I added it to u-boot-testing/dm-gcclink branch already, but will repost after I get a bit more feedback.

Thanks!

Best regards,
Marek Vasut

#3 lore raw

PATCH 1/1 common: Link with GCC instead of LD

In reply to Marek Vasut

Dear Marek Vasut,

Quoted 2 lines · In message <[email protected]> you wrote:

Flip over from linking with LD to linking with GCC. This has some long-term benefits, like easy path to enabling LTO.

Could you please explain these supposed benefits in a bit more detail? Please excuse my ignorance, but so far I see just added complexity, but I don't see what it buys us.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If the facts don't fit the theory, change the facts.
                                                   -- Albert Einstein
#4 lore raw

PATCH 1/1 common: Link with GCC instead of LD

Quoted 9 lines · Wolfgang Denk

Dear Marek Vasut,

Quoted 2 lines · In message <[email protected]> you wrote:

Flip over from linking with LD to linking with GCC. This has some long-term benefits, like easy path to enabling LTO.

Could you please explain these supposed benefits in a bit more detail? Please excuse my ignorance, but so far I see just added complexity, but I don't see what it buys us.

Complexity is arguable. Most projects don't call ld directly but let gcc call ld. Doing this brings us in line with what other projects do. As an aside, from my time with CodeSourcery folks directly calling ld was discouraged I swear, but I don't have some reference to back that up. Finally, as Marek said but didn't explain, this brings us a step closer to being able to enable LTO (link time optimization) which may (but we need to experiment) be beneficial in terms of size and performance (since in short gcc re-decides things like positioning, inlining based on the whole program state at link time).

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121031/a4863bc0/attachment.pgp>
#5 lore raw

PATCH 1/1 common: Link with GCC instead of LD

Dear Tom,

Quoted 10 lines · In message <20121031224825.GA24095@bill-the-cat> you wrote:
Quoted 7 lines
Quoted 3 lines

Flip over from linking with LD to linking with GCC. This has some long-term benefits, like easy path to enabling LTO.

Could you please explain these supposed benefits in a bit more detail? Please excuse my ignorance, but so far I see just added complexity, but I don't see what it buys us.

Complexity is arguable. Most projects don't call ld directly but let gcc call ld. Doing this brings us in line with what other projects do.

The question is if there are good reasons for these other projects doing it this way - I tend to belive most projects just don't care that much about specific linker options - on the other hand, for bare metal code like U-Boot it is essential to know _exactly_ how the linker is being run. Depending here on the GCC framework which may meddle with options in subtle ways that are not always perfectly understood is something that needs thorough consideration.

Quoted 2 lines

As an aside, from my time with CodeSourcery folks directly calling ld was discouraged I swear, but I don't have some reference to back that

I agree with this for "normal programs", i. e. standard conformng code in a standard C environment, where correct use of the appropriate GCC runtime environment and standard libraries is essential. But none of this applies to U-Boot.

Quoted 5 lines

up. Finally, as Marek said but didn't explain, this brings us a step closer to being able to enable LTO (link time optimization) which may (but we need to experiment) be beneficial in terms of size and performance (since in short gcc re-decides things like positioning, inlining based on the whole program state at link time).

I do understand this argument. But unless I've seen this working in a real test case I don't feel conficent to acept this. Changing "things like positioning" etc. is something we usually do now want to allow here - instead, we want to have absolute control over such things.

Until I see any such things implemented (and working), this patch falls for me in the group of "unused code" - and given the added complexity (which is definitely non-trivial) it takes me a lot of discipline not to NAK this right away.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
There is, however, a strange, musty smell in the air that reminds  me
of something...hmm...yes...I've got it...there's a VMS nearby, or I'm
a Blit.          - Larry Wall in Configure from the perl distribution
#6 lore raw

PATCH 1/1 common: Link with GCC instead of LD

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 15 lines · Wolfgang Denk

Dear Tom,

Quoted 11 lines · In message <20121031224825.GA24095@bill-the-cat> you wrote:
Quoted 7 lines
Quoted 3 lines

Flip over from linking with LD to linking with GCC. This has some long-term benefits, like easy path to enabling LTO.

Could you please explain these supposed benefits in a bit more detail? Please excuse my ignorance, but so far I see just added complexity, but I don't see what it buys us.

Complexity is arguable. Most projects don't call ld directly but let gcc call ld. Doing this brings us in line with what other projects do.

Quoted 8 lines

The question is if there are good reasons for these other projects
doing it this way - I tend to belive most projects just don't care that much about specific linker options - on the other hand, for
bare metal code like U-Boot it is essential to know _exactly_ how the linker is being run. Depending here on the GCC framework which may meddle with options in subtle ways that are not always perfectly understood is something that needs thorough consideration.

Right. The flip side to this is that the Linux kernel also uses gcc to link, depends on gcc doing what it's told and telling the linker what we want and has a tad more clout than we do when problems arise.
If we switch and we find a problem, it's likely the kernel can or
does fail as well, which can be useful in getting people to address bugs.

[snip]

Quoted 13 lines
Quoted 6 lines

up. Finally, as Marek said but didn't explain, this brings us a step closer to being able to enable LTO (link time optimization) which may (but we need to experiment) be beneficial in terms of size and performance (since in short gcc re-decides things like positioning, inlining based on the whole program state at link time).

I do understand this argument. But unless I've seen this working in a real test case I don't feel conficent to acept this. Changing "things like positioning" etc. is something we usually do now want to allow here - instead, we want to have absolute control over such things.

Quoted 4 lines

Until I see any such things implemented (and working), this patch falls for me in the group of "unused code" - and given the added complexity (which is definitely non-trivial) it takes me a lot of discipline not to NAK this right away.

I appreciate your restraint here. And, I agree that we don't need to bring this in until we've investigated LTO and found it brings benefits to the project. It could indeed mess up and not obey the times we've re-ordered code segments out of necessity rather than space optimization. But it might also let us stop playing those games and get better results with all of the text together.

- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQkbalAAoJENk4IS6UOR1WdMIP/RjcFHw0kvi17TJRvNq8sPzb kEODknbkE/tw8GFa0QA3+Cp4AsmadDPA/KM4jfOypR3lpWey5oI25I5RRdnHvXbT Cagp8Oyg9rqjD+VS8iVYIFMGy3/ivvwXzgysQlqhF/KFx07kcu+g2EG9rgZEP3cA rNdZKG5NT1aq8iiu28Il1vY/nnYtDFBi1undhOzVi9pOlt5k9Vc3VhHB+3ZIzzrf 9ptvo1ORObQ1M3BISA7dZfYdITUElbqDQKLbqldUbWbBN/gaOsNvGWaAtCjOgoXo O70mqe7Tqjl8p7S55jCBrZPuxNOHOs5HSOt/Q+o164RFXspvXV5fL9dX7HWE3wtL y4asCLS3rmLkuY14dn7eXP3Mg4ZumtJST06SWfYYsAqD8EfFWfdye1gMpLUMwrKR kWsmflyQbaXqAMhxdbhHeYPA3Spmwm0Ebgf8MjvZTpzWjyvKKsNm8Cgszr5n9Crz YLIYFqG1NIopZ3SewsWckOkGbC9RatpfydDhbZ/F+u/oGu1jbWOLyuvUkTN75E/r YPN5CZ7EOSVCuKz5NeUwuTdnVQqPxO1Hq3mtvxfbRIPDlEQ4XO5PdKqj+iwjqTyy +0NYXyFSSf5ulPY7YeAHEj12kTBLvDD2QMgK0AHgMJ42N1ir4PQJrfP4DwZKxUdm NHX2XryIFZs+C4hCiCgq
=q/MN
-----END PGP SIGNATURE-----

#7 lore raw

PATCH 1/1 common: Link with GCC instead of LD

In reply to Wolfgang Denk

Dear Wolfgang Denk,

Quoted 7 lines

Dear Marek Vasut,

Quoted 2 lines · In message <[email protected]> you wrote:

Flip over from linking with LD to linking with GCC. This has some long-term benefits, like easy path to enabling LTO.

Could you please explain these supposed benefits in a bit more detail?

Yes, thanks for the review (I really needed one from you on this)!

So, here comes the list:
1) It's cool to link with gcc, duh ;-)
2) You can enable LTO eventually -- long term plan -- which proved can shrink the code size a bit
3) Usage of LLVM/CLANG is now much more straightforward
4) Binutils usually lag behind the GCC development a bit, by using GCC to do the link, we can remedy this problem

But actually, the 2) is the most important part. LTO will hopefully help us optimize U-Boot for size even better than it is now. But that will still need much more research. So this is only a patch that shall prepare the groundwork for this further research.

Quoted 6 lines

Please excuse my ignorance, but so far I see just added complexity, but I don't see what it buys us.

Best regards,

Wolfgang Denk

Best regards,
Marek Vasut

#8 lore raw

PATCH 1/1 common: Link with GCC instead of LD

Dear Marek,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 2 lines

Could you please explain these supposed benefits in a bit more detail?

Yes, thanks for the review (I really needed one from you on this)!

So, here comes the list:
1) It's cool to link with gcc, duh ;-)

Is it - and why exactly?

Quoted 2 lines

2) You can enable LTO eventually -- long term plan -- which proved can shrink the code size a bit

Do you have a workign example? You know, we don;t like adding dead code...

Quoted 1 line

3) Usage of LLVM/CLANG is now much more straightforward

Please elucidate?

Quoted 2 lines

4) Binutils usually lag behind the GCC development a bit, by using GCC to do the link, we can remedy this problem

Grrrrghhhg. I lost you here. By not calling ld directly (where we know exactly what we are doing), but through a (somewhat unknown) GCC framework, we can magicly adjust any (claimed - by you) version
differences? I cannot parse this.

Quoted 4 lines

But actually, the 2) is the most important part. LTO will hopefully help us optimize U-Boot for size even better than it is now. But that will still need much more research. So this is only a patch that shall prepare the groundwork for this further research.

As is, it's just unused or dead code that adds a lot of complexity and buys nothing. Please submit as part of a patch series that makes successfull (and tested) use of LTO.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
To understand a program you must become  both  the  machine  and  the
program.
#9 lore raw

PATCH 1/1 common: Link with GCC instead of LD

Dear Wolfgang Denk,

Quoted 11 lines

Dear Marek,

Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 1 line

Could you please explain these supposed benefits in a bit more detail?

Yes, thanks for the review (I really needed one from you on this)!

So, here comes the list:
1) It's cool to link with gcc, duh ;-)

Is it - and why exactly?

It's all the rage now (better ignore this point) ;-)

Quoted 5 lines
Quoted 2 lines

2) You can enable LTO eventually -- long term plan -- which proved can shrink the code size a bit

Do you have a workign example? You know, we don;t like adding dead code...

We've been digging with Albert, but nothing we can release just yet. This is a groundwork patch.

Quoted 3 lines
Quoted 1 line

3) Usage of LLVM/CLANG is now much more straightforward

Please elucidate?

Now you can simply replace gcc with clang and that _should_ work. Sure, I expect more work will be needed here, but this patch gives you all the ground to do that.

Quoted 7 lines
Quoted 2 lines

4) Binutils usually lag behind the GCC development a bit, by using GCC to do the link, we can remedy this problem

Grrrrghhhg. I lost you here. By not calling ld directly (where we know exactly what we are doing), but through a (somewhat unknown) GCC framework, we can magicly adjust any (claimed - by you) version
differences? I cannot parse this.

GCC can do all the optimization magic (LTO ...) and then just let linker do the linking.

Quoted 8 lines
Quoted 4 lines

But actually, the 2) is the most important part. LTO will hopefully help us optimize U-Boot for size even better than it is now. But that will still need much more research. So this is only a patch that shall prepare the groundwork for this further research.

As is, it's just unused or dead code that adds a lot of complexity and buys nothing. Please submit as part of a patch series that makes successfull (and tested) use of LTO.

No, I won't, I don't have that part ready yet.

Besides, the sandbox target already uses gcc linking. Shall we also convert it to use LD instead then ?

Best regards,
Marek Vasut

#10 lore raw

PATCH 1/1 common: Link with GCC instead of LD

Dear Marek,

Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 6 lines
Quoted 3 lines

2) You can enable LTO eventually -- long term plan -- which proved can shrink the code size a bit

Do you have a workign example? You know, we don;t like adding dead code...

We've been digging with Albert, but nothing we can release just yet. This is a groundwork patch.

Dead code, which will not be added, then.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

3) Usage of LLVM/CLANG is now much more straightforward

Please elucidate?

Now you can simply replace gcc with clang and that _should_ work. Sure, I expect more work will be needed here, but this patch gives you all the ground to do that.

I. e. it's all speculation only? Such doesn't by much...

Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

4) Binutils usually lag behind the GCC development a bit, by using GCC to do the link, we can remedy this problem

Grrrrghhhg. I lost you here. By not calling ld directly (where we know exactly what we are doing), but through a (somewhat unknown) GCC framework, we can magicly adjust any (claimed - by you) version
differences? I cannot parse this.

GCC can do all the optimization magic (LTO ...) and then just let linker do the linking.

You were talking about "Binutils usually lag behind the GCC development". Now I would like you to explain how "by using GCC to do the link, we can remedy this problem".

You fail to provide any such explanation.

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

But actually, the 2) is the most important part. LTO will hopefully help us optimize U-Boot for size even better than it is now. But that will still need much more research. So this is only a patch that shall prepare the groundwork for this further research.

As is, it's just unused or dead code that adds a lot of complexity and buys nothing. Please submit as part of a patch series that makes successfull (and tested) use of LTO.

No, I won't, I don't have that part ready yet.

Then please _re_submit when you have the rest that actually needs any such changes.

Quoted 2 lines

Besides, the sandbox target already uses gcc linking. Shall we also convert it to use LD instead then ?

Note that sandbox is actually very different, in such as it really tried to implement a standard onforming C program, running in a standard C execution environment. This is totally different from the bare metal code we have on any real hardware.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The most difficult thing in the world is to know how to  do  a  thing
and to watch someone else doing it wrong, without commenting.
                                                        -- T.H. White
#11 lore raw

PATCH 1/1 common: Link with GCC instead of LD

Dear Wolfgang Denk,

Quoted 6 lines

Dear Marek,

Quoted 3 lines · In message <[email protected]> you wrote:
Quoted 3 lines
Quoted 2 lines

2) You can enable LTO eventually -- long term plan -- which proved can shrink the code size a bit

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Do you have a workign example? You know, we don;t like adding dead code...

We've been digging with Albert, but nothing we can release just yet. This is a groundwork patch.

Dead code, which will not be added, then.

[...]

Ok, let's end the discussion here then. Patch is NAK'ed and I'll resubmit it when I have something with LTO.

Best regards,
Marek Vasut