Skip to contentSkip to conversation

Add support for ld.gold in toolchain.

PATCH New Steve Thomas 3 participants 3 messages May 20, 2014 – May 21, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add support for ld.gold in toolchain.

The ld.gold linker has been around for about six years, and is quite well supported. It also used to be the only linker for gcc that supported the plugin option needed for LTO.

This patch enables a system to be build with the gold linker which is very well supported on recent builds.

---
 package/binutils/Config.in.host         | 4 ++++
 package/binutils/binutils.mk            | 7 +++++++
 package/gcc/Config.in.host              | 6 ++++++
 package/gcc/gcc.mk                      | 7 +++++++
 toolchain/toolchain-buildroot/Config.in | 9 +++++++++
 5 files changed, 33 insertions(+)
package/binutils/Config.in.host +4 -0
index 2f86f51..3bc9349 100644
@@ -1,5 +1,8 @@
 comment "Binutils Options"
 
+config BR2_BINUTILS_SUPPORTS_GOLD
+	bool
+
 choice
 	prompt "Binutils Version"
 	depends on !BR2_arc
@@ -42,6 +45,7 @@ choice
 
 	config BR2_BINUTILS_VERSION_2_24
 		depends on !BR2_avr32
+		select BR2_BINUTILS_SUPPORTS_GOLD
 		bool "binutils 2.24"
 
 endchoice
package/binutils/binutils.mk +7 -0
index b5a2dc7..2caa045 100644
@@ -67,6 +67,13 @@ HOST_BINUTILS_CONF_OPT = --disable-multilib --disable-werror \
 			--with-sysroot=$(STAGING_DIR) \
 			$(BINUTILS_EXTRA_CONFIG_OPTIONS)
 
+# disable ld explicitely and use ld.gold exclusively
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT_GOLD),y)
+HOST_BINUTILS_CONF_OPT += \
+			--enable-gold \
+			--enable-ld=no
+endif
+
 # We just want libbfd and libiberty, not the full-blown binutils in staging
 define BINUTILS_INSTALL_STAGING_CMDS
 	$(MAKE) -C $(@D)/bfd DESTDIR=$(STAGING_DIR) install
package/gcc/Config.in.host +6 -0
index ca991da..cf04fd6 100644
@@ -3,6 +3,9 @@ comment "GCC Options"
 config BR2_GCC_NEEDS_MPC
 	bool
 
+config BR2_GCC_SUPPORTS_GOLD
+	bool
+
 choice
 	prompt "GCC compiler Version"
 	default BR2_GCC_VERSION_4_4_X if BR2_sparc_sparchfleon || BR2_sparc_sparchfleonv8 || BR2_sparc_sparcsfleon || BR2_sparc_sparcsfleonv8
@@ -52,6 +55,7 @@ choice
 	config BR2_GCC_VERSION_4_8_X
 		depends on !BR2_microblaze && !BR2_arc && !BR2_avr32 && !BR2_bfin && !BR2_cortex_a12 && !BR2_sparc_sparchfleon && !BR2_sparc_sparchfleonv8 && !BR2_sparc_sparcsfleon && !BR2_sparc_sparcsfleonv8
 		select BR2_GCC_NEEDS_MPC
+		select BR2_GCC_SUPPORTS_GOLD
 		bool "gcc 4.8.x"
 
 	config BR2_GCC_VERSION_4_8_ARC
@@ -62,6 +66,7 @@ choice
 	config BR2_GCC_VERSION_4_9_X
 		depends on !BR2_arc && !BR2_avr32 && !BR2_bfin && !BR2_sparc_sparchfleon && !BR2_sparc_sparchfleonv8 && !BR2_sparc_sparcsfleon && !BR2_sparc_sparcsfleonv8
 		select BR2_GCC_NEEDS_MPC
+		select BR2_GCC_SUPPORTS_GOLD
 		bool "gcc 4.9.x"
 
 	config BR2_GCC_VERSION_4_9_MICROBLAZE
@@ -72,6 +77,7 @@ choice
 	config BR2_GCC_VERSION_SNAP
 		depends on !BR2_microblaze && !BR2_arc && !BR2_avr32 && !BR2_sparc_sparchfleon && !BR2_sparc_sparchfleonv8 && !BR2_sparc_sparcsfleon && !BR2_sparc_sparcsfleonv8
 		select BR2_GCC_NEEDS_MPC
+		select BR2_GCC_SUPPORTS_GOLD
 		bool "gcc snapshot"
 endchoice
 
package/gcc/gcc.mk +7 -0
index 32219cc..1971187 100644
@@ -160,6 +160,13 @@ ifneq ($(BR2_arc)$(BR2_GCC_VERSION_SNAP),)
 HOST_GCC_COMMON_DEPENDENCIES += host-flex host-bison
 endif
 
+# disable ld explicitely and use ld.gold exclusively
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT_GOLD),y)
+HOST_GCC_COMMON_CONF_OPT += \
+	--enable-gold \
+	--enable-ld=no
+endif
+
 ifeq ($(BR2_SOFT_FLOAT),y)
 # only mips*-*-*, arm*-*-* and sparc*-*-* accept --with-float
 # powerpc seems to be needing it as well
toolchain/toolchain-buildroot/Config.in +9 -0
index 42166d2..527ad5b 100644
@@ -79,6 +79,15 @@ comment "(e)glibc only available with shared lib support"
 
 endchoice
 
+config BR2_TOOLCHAIN_BUILDROOT_GOLD
+	bool "Use the GOLD linker"
+	depends on BR2_GCC_SUPPORTS_GOLD
+	depends on BR2_BINUTILS_SUPPORTS_GOLD
+	default n
+	help
+	  This option selects the gold linker exclusively for
+	  the cross-compilation toolchain.
+
 config BR2_TOOLCHAIN_BUILDROOT_LIBC
 	string
 	default "uclibc" if BR2_TOOLCHAIN_BUILDROOT_UCLIBC
Signature · 1 line
1.9.3
#1 lore raw

PATCH 1/1 Add support for ld.gold in toolchain.

Hi Steve,
Steve Thomas wrote,

Quoted 6 lines

The ld.gold linker has been around for about six years, and is quite well supported. It also used to be the only linker for gcc that supported the plugin option needed for LTO.

This patch enables a system to be build with the gold linker which is very well supported on recent builds.

But gold is not available for all architectures. I am sure it does not work for MIPS f.e.

best regards
Waldemar

#2 lore raw

PATCH 1/1 Add support for ld.gold in toolchain.

Quoted 7 lines · Waldemar Brodkorb

Hi Steve,
Steve Thomas wrote,

Quoted 4 lines

The ld.gold linker has been around for about six years, and is quite well supported. It also used to be the only linker for gcc that supported the plugin option needed for LTO.

Quoted 5 lines
Quoted 2 lines

This patch enables a system to be build with the gold linker which is very well supported on recent builds.

But gold is not available for all architectures. I am sure it does not work for MIPS f.e.

gold also has problems (or at least did) building working kernels on ARM.