Skip to contentSkip to conversation

binutils/gcc: make it possible to use lto

PATCH New Peter Kümmel 2 participants 5 messages Nov 9, 2014 – Nov 10, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 binutils/gcc: make it possible to use lto

When -flto is used the compiler and binutils have to support lto. ar/ranlib needs to be called with the lto plugin, therefore use the wrappers provided by GCC: *-gcc-ar and *-gcc-ranlib.

---
 package/binutils/binutils.mk | 2 ++
 package/gcc/gcc.mk           | 2 ++
 2 files changed, 4 insertions(+)
package/binutils/binutils.mk +2 -0
index b8dab5d..e552abc 100644
@@ -48,6 +48,7 @@ BINUTILS_DISABLE_GDB_CONF_OPTS = \
 BINUTILS_CONF_OPTS = --disable-multilib --disable-werror \
 		--host=$(GNU_TARGET_NAME) \
 		--target=$(GNU_TARGET_NAME) \
+		--enable-plugins --enable-lto \
 		--enable-install-libiberty \
 		$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 		$(BINUTILS_EXTRA_CONFIG_OPTIONS)
@@ -67,6 +68,7 @@ endif
 HOST_BINUTILS_CONF_OPTS = --disable-multilib --disable-werror \
 			--target=$(GNU_TARGET_NAME) \
 			--disable-shared --enable-static \
+			--enable-plugins --enable-lto \
 			--with-sysroot=$(STAGING_DIR) \
 			$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 			$(BINUTILS_EXTRA_CONFIG_OPTIONS)
package/gcc/gcc.mk +2 -0
index cdd71aa..a8853f7 100644
@@ -92,6 +92,8 @@ HOST_GCC_COMMON_CONF_OPTS = \
 	--with-gnu-ld \
 	--disable-libssp \
 	--disable-multilib \
+	--enable-plugins \
+	--enable-lto \
 	--with-gmp=$(HOST_DIR)/usr \
 	--with-mpfr=$(HOST_DIR)/usr
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 binutils/gcc: make it possible to use lto

Dear Peter K?mmel,

Quoted 35 lines · Peter K?mmel

When -flto is used the compiler and binutils have to support lto. ar/ranlib needs to be called with the lto plugin, therefore use the wrappers provided by GCC: *-gcc-ar and *-gcc-ranlib.

---
 package/binutils/binutils.mk | 2 ++
 package/gcc/gcc.mk           | 2 ++
 2 files changed, 4 insertions(+)
package/binutils/binutils.mk +2 -0
index b8dab5d..e552abc 100644
@@ -48,6 +48,7 @@ BINUTILS_DISABLE_GDB_CONF_OPTS = \
 BINUTILS_CONF_OPTS = --disable-multilib --disable-werror \
 		--host=$(GNU_TARGET_NAME) \
 		--target=$(GNU_TARGET_NAME) \
+		--enable-plugins --enable-lto \
 		--enable-install-libiberty \
 		$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 		$(BINUTILS_EXTRA_CONFIG_OPTIONS)
@@ -67,6 +68,7 @@ endif
 HOST_BINUTILS_CONF_OPTS = --disable-multilib --disable-werror \
 			--target=$(GNU_TARGET_NAME) \
 			--disable-shared --enable-static \
+			--enable-plugins --enable-lto \
 			--with-sysroot=$(STAGING_DIR) \
 			$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 			$(BINUTILS_EXTRA_CONFIG_OPTIONS)
package/gcc/gcc.mk +0 -0
index cdd71aa..a8853f7 100644

package/gcc/gcc.mk HOST_GCC_COMMON_CONF_OPTS = \ · line 99

Quoted 8 lines
package/gcc/gcc.mk +2 -0
@@ -92,6 +92,8 @@ HOST_GCC_COMMON_CONF_OPTS = \
 	--with-gnu-ld \
 	--disable-libssp \
 	--disable-multilib \
+	--enable-plugins \
+	--enable-lto \
 	--with-gmp=$(HOST_DIR)/usr \
 	--with-mpfr=$(HOST_DIR)/usr
 

Should we make this optional?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 binutils/gcc: make it possible to use lto

Quoted 46 lines

Gesendet: Sonntag, 09. November 2014 um 14:00 Uhr
Von: "Thomas Petazzoni" <[email protected]>
An: "Peter K?mmel" <[email protected]>
Cc: buildroot at buildroot.org
Betreff: Re: [Buildroot] [PATCH 1/1] binutils/gcc: make it possible to use lto

Dear Peter K?mmel,

Quoted 37 lines · Peter K?mmel

When -flto is used the compiler and binutils have to support lto. ar/ranlib needs to be called with the lto plugin, therefore use the wrappers provided by GCC: *-gcc-ar and *-gcc-ranlib.

---
 package/binutils/binutils.mk | 2 ++
 package/gcc/gcc.mk           | 2 ++
 2 files changed, 4 insertions(+)
package/binutils/binutils.mk +2 -0
index b8dab5d..e552abc 100644
@@ -48,6 +48,7 @@ BINUTILS_DISABLE_GDB_CONF_OPTS = \
 BINUTILS_CONF_OPTS = --disable-multilib --disable-werror \
 		--host=$(GNU_TARGET_NAME) \
 		--target=$(GNU_TARGET_NAME) \
+		--enable-plugins --enable-lto \
 		--enable-install-libiberty \
 		$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 		$(BINUTILS_EXTRA_CONFIG_OPTIONS)
@@ -67,6 +68,7 @@ endif
 HOST_BINUTILS_CONF_OPTS = --disable-multilib --disable-werror \
 			--target=$(GNU_TARGET_NAME) \
 			--disable-shared --enable-static \
+			--enable-plugins --enable-lto \
 			--with-sysroot=$(STAGING_DIR) \
 			$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 			$(BINUTILS_EXTRA_CONFIG_OPTIONS)
package/gcc/gcc.mk +0 -0
index cdd71aa..a8853f7 100644
@@ -92,6 +92,8 @@ HOST_GCC_COMMON_CONF_OPTS = \
 	--with-gnu-ld \
 	--disable-libssp \
Quoted 9 lines

package/gcc/gcc.mk HOST_GCC_COMMON_CONF_OPTS = \ · line 99

Quoted 6 lines
package/gcc/gcc.mk +2 -0
 	--disable-multilib \
+	--enable-plugins \
+	--enable-lto \
 	--with-gmp=$(HOST_DIR)/usr \
 	--with-mpfr=$(HOST_DIR)/usr
 

Should we make this optional?

I've tested with binutils 2.24 and gcc 4.9.2. Also binutils 2.22 configures with this flags.

So I think it doesn't hurt to enable by default, at least when the buidroot compiler is used. Not sure about very old external GCCs, which have no lto.

Peter

Quoted 6 lines

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH 1/1 binutils/gcc: make it possible to use lto

In reply to Thomas Petazzoni
Quoted 48 lines

Gesendet: Sonntag, 09. November 2014 um 14:00 Uhr
Von: "Thomas Petazzoni" <[email protected]>
An: "Peter K?mmel" <[email protected]>
Cc: buildroot at buildroot.org
Betreff: Re: [Buildroot] [PATCH 1/1] binutils/gcc: make it possible to use lto

Dear Peter K?mmel,

Quoted 37 lines · Peter K?mmel

When -flto is used the compiler and binutils have to support lto. ar/ranlib needs to be called with the lto plugin, therefore use the wrappers provided by GCC: *-gcc-ar and *-gcc-ranlib.

---
 package/binutils/binutils.mk | 2 ++
 package/gcc/gcc.mk           | 2 ++
 2 files changed, 4 insertions(+)
package/binutils/binutils.mk +2 -0
index b8dab5d..e552abc 100644
@@ -48,6 +48,7 @@ BINUTILS_DISABLE_GDB_CONF_OPTS = \
 BINUTILS_CONF_OPTS = --disable-multilib --disable-werror \
 		--host=$(GNU_TARGET_NAME) \
 		--target=$(GNU_TARGET_NAME) \
+		--enable-plugins --enable-lto \
 		--enable-install-libiberty \
 		$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 		$(BINUTILS_EXTRA_CONFIG_OPTIONS)
@@ -67,6 +68,7 @@ endif
 HOST_BINUTILS_CONF_OPTS = --disable-multilib --disable-werror \
 			--target=$(GNU_TARGET_NAME) \
 			--disable-shared --enable-static \
+			--enable-plugins --enable-lto \
 			--with-sysroot=$(STAGING_DIR) \
 			$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 			$(BINUTILS_EXTRA_CONFIG_OPTIONS)
package/gcc/gcc.mk +0 -0
index cdd71aa..a8853f7 100644
@@ -92,6 +92,8 @@ HOST_GCC_COMMON_CONF_OPTS = \
 	--with-gnu-ld \
 	--disable-libssp \
Quoted 8 lines

package/gcc/gcc.mk HOST_GCC_COMMON_CONF_OPTS = \ · line 99

Quoted 6 lines
package/gcc/gcc.mk +2 -0
 	--disable-multilib \
+	--enable-plugins \
+	--enable-lto \
 	--with-gmp=$(HOST_DIR)/usr \
 	--with-mpfr=$(HOST_DIR)/usr
 

Should we make this optional?

Thought more about it: it is not necessary to make it optional. Using --enable-plugins --enable-lto in binutils only allows using lto, but when not used, it doesn't change anything. And these options are available in the binutils versions supported by buildroot.

Also all buildroot's builds of the GCC (>=4.7) support the lto flags, and when -flto is not used nothing changed.

So in both cases optional support of lto is provided without changing behavior when lto is not used.

Peter

Quoted 7 lines

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 1/1 binutils/gcc: make it possible to use lto

Dear Peter Kuemmel,

Quoted 10 lines · Peter Kuemmel

Thought more about it: it is not necessary to make it optional. Using --enable-plugins --enable-lto in binutils only allows using lto, but when not used, it doesn't change anything. And these options are available in the binutils versions supported by buildroot.

Also all buildroot's builds of the GCC (>=4.7) support the lto flags, and when -flto is not used nothing changed.

So in both cases optional support of lto is provided without changing behavior when lto is not used.

Ok. What about older versions of gcc/binutils, such as gcc 4.2, gcc 4.5, or binutils 2.18. We still support gcc 4.2 and binutils 2.18 for the AVR32 architecture (even though it's marked deprecated, we still haven't removed the support for this arch). We still have gcc 4.5 as the default for Blackfin.

I guess some of those older versions don't support LTO, so maybe a Config.in knob BR2_GCC_SUPPORTS_LTO will be needed, and ditto for binutils.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com