Skip to contentSkip to conversation

package/valgrind: Add a setting for LTO build

PATCH New Gleb Mazovetskiy 3 participants 5 messages Apr 18, 2021 – Jul 25, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/valgrind: Add a setting for LTO build

Valgrind LTO build takes over an hour on my Ryzen 3950x.

This is not always worth it for the ~10% size reduction and a small performance improvement it offers (see https://www.valgrind.org/docs/manual/dist.news.html)

Adds a new BR2_VALGRIND_ENABLE_LTO setting to control LTO enablement for Valgrind separately from the global BR2_GCC_ENABLE_LTO setting.

---
 package/valgrind/Config.in   | 10 ++++++++++
 package/valgrind/valgrind.mk |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)
package/valgrind/Config.in +10 -0
index 56e4af21fa..eff54e7949 100644
@@ -84,4 +84,14 @@ config BR2_PACKAGE_VALGRIND_NULGRIND
 	help
 	  This option allows to install the Nulgrind tool
 
+if BR2_GCC_ENABLE_LTO
+
+config BR2_VALGRIND_ENABLE_LTO
+	bool "Build Valgrind with link-time optimization"
+	help
+	  This produces a faster / smaller valgrind (up to 10%) at the cost
+	  of massively increased build time (can be over an hour).
+
+endif
+
 endif
package/valgrind/valgrind.mk +1 -1
index b87e1e518f..07fb1f7d42 100644
@@ -50,7 +50,7 @@ VALGRIND_CONF_OPTS += \
 	--host=$(patsubst arm-%,armv7-%,$(GNU_TARGET_NAME))
 endif
 
-ifeq ($(BR2_GCC_ENABLE_LTO),y)
+ifeq ($(BR2_VALGRIND_ENABLE_LTO),y)
 VALGRIND_CONF_OPTS += --enable-lto
 else
 VALGRIND_CONF_OPTS += --disable-lto
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 package/valgrind: Add a setting for LTO build

Hello Gleb,

Quoted 2 lines · Gleb Mazovetskiy

Valgrind LTO build takes over an hour on my Ryzen 3950x.

Can confirm a build time increase (AMD Ryzen 7 1800X):

- without LTO:

real 0m54,741s
user 3m29,941s
sys 0m10,949s

- with LTO:

real 5m48,009s
user 6m23,040s
sys 0m13,197s

Quoted 17 lines

This is not always worth it for the ~10% size reduction and a small performance improvement it offers (see https://www.valgrind.org/docs/manual/dist.news.html)

Adds a new BR2_VALGRIND_ENABLE_LTO setting to control LTO enablement for Valgrind separately from the global BR2_GCC_ENABLE_LTO setting.

---
 package/valgrind/Config.in   | 10 ++++++++++
 package/valgrind/valgrind.mk |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)
package/valgrind/Config.in +0 -0
index 56e4af21fa..eff54e7949 100644

package/valgrind/Config.in config BR2_PACKAGE_VALGRIND_NULGRIND · line 93

Quoted 10 lines
package/valgrind/Config.in +7 -0
@@ -84,4 +84,14 @@ config BR2_PACKAGE_VALGRIND_NULGRIND
 	help
 	  This option allows to install the Nulgrind tool
 
+if BR2_GCC_ENABLE_LTO
+
+config BR2_VALGRIND_ENABLE_LTO
+	bool "Build Valgrind with link-time optimization"
+	help
+	  This produces a faster / smaller valgrind (up to 10%) at the cost
+	  of massively increased build time (can be over an hour).

Be careful with absolute times, depends strongly on the used hardware... (out of interest, what is your baseline compile time?)...

Would move this section up-to/before the tools selection section...

Regards,
Peter

Quoted 17 lines
package/valgrind/Config.in +3 -0
+
+endif
+
 endif
package/valgrind/valgrind.mk +1 -1
index b87e1e518f..07fb1f7d42 100644
@@ -50,7 +50,7 @@ VALGRIND_CONF_OPTS += \
 	--host=$(patsubst arm-%,armv7-%,$(GNU_TARGET_NAME))
 endif
 
-ifeq ($(BR2_GCC_ENABLE_LTO),y)
+ifeq ($(BR2_VALGRIND_ENABLE_LTO),y)
 VALGRIND_CONF_OPTS += --enable-lto
 else
 VALGRIND_CONF_OPTS += --disable-lto
#2 lore raw

PATCH 1/1 package/valgrind: Add a setting for LTO build

By the way, I should've mentioned that it's over 1 hour for MIPS32R2 with uclibc

Quoted 70 lines · Peter Seiderer

Hello Gleb,

Quoted 2 lines · Gleb Mazovetskiy

Valgrind LTO build takes over an hour on my Ryzen 3950x.

Can confirm a build time increase (AMD Ryzen 7 1800X):

- without LTO:

real    0m54,741s
user    3m29,941s
sys     0m10,949s

- with LTO:

real    5m48,009s
user    6m23,040s
sys     0m13,197s
Quoted 2 lines

This is not always worth it for the ~10% size reduction and a small performance improvement it offers (see

https://www.valgrind.org/docs/manual/dist.news.html)

Quoted 15 lines

Adds a new BR2_VALGRIND_ENABLE_LTO setting to control LTO enablement for Valgrind separately from the global BR2_GCC_ENABLE_LTO setting.

---
 package/valgrind/Config.in   | 10 ++++++++++
 package/valgrind/valgrind.mk |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)
package/valgrind/Config.in +0 -0
index 56e4af21fa..eff54e7949 100644

package/valgrind/Config.in config BR2_PACKAGE_VALGRIND_NULGRIND · line 93

Quoted 10 lines
package/valgrind/Config.in +7 -0
@@ -84,4 +84,14 @@ config BR2_PACKAGE_VALGRIND_NULGRIND
      help
        This option allows to install the Nulgrind tool
 
+if BR2_GCC_ENABLE_LTO
+
+config BR2_VALGRIND_ENABLE_LTO
+     bool "Build Valgrind with link-time optimization"
+     help
+       This produces a faster / smaller valgrind (up to 10%) at the cost
+       of massively increased build time (can be over an hour).

Be careful with absolute times, depends strongly on the used hardware... (out of interest, what is your baseline compile time?)...

Would move this section up-to/before the tools selection section...

Regards,
Peter

Quoted 12 lines
package/valgrind/Config.in +3 -0
+
+endif
+
 endif
package/valgrind/valgrind.mk +0 -0
index b87e1e518f..07fb1f7d42 100644
@@ -50,7 +50,7 @@ VALGRIND_CONF_OPTS += \
      --host=$(patsubst arm-%,armv7-%,$(GNU_TARGET_NAME))
 endif
 
Quoted 7 lines

package/valgrind/valgrind.mk VALGRIND_CONF_OPTS += \ · line 56

Quoted 5 lines
package/valgrind/valgrind.mk +1 -1
-ifeq ($(BR2_GCC_ENABLE_LTO),y)
+ifeq ($(BR2_VALGRIND_ENABLE_LTO),y)
 VALGRIND_CONF_OPTS += --enable-lto
 else
 VALGRIND_CONF_OPTS += --disable-lto

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20210419/2b9346e5/attachment.html>

#3 lore raw
In reply to Peter Seiderer
Quoted 14 lines · Peter Seiderer

Hello Gleb,

Quoted 2 lines · Gleb Mazovetskiy

Valgrind LTO build takes over an hour on my Ryzen 3950x.

Can confirm a build time increase (AMD Ryzen 7 1800X):

- without LTO:

real 0m54,741s
user 3m29,941s
sys 0m10,949s

Quoted 11 lines

- with LTO:

real 5m48,009s
user 6m23,040s
sys 0m13,197s

Quoted 5 lines

This is not always worth it for the ~10% size reduction and a small performance improvement it offers (see https://www.valgrind.org/docs/manual/dist.news.html)

Adds a new BR2_VALGRIND_ENABLE_LTO setting to control LTO enablement for Valgrind separately from the global BR2_GCC_ENABLE_LTO setting.

Adding per-package options to enable debug and optimisation features is really
not the way to go.

Instead what I've done is to create a series [1] that turns the LTO option in
a global option, that clearly explains in the help text that it may have a big impact on build time. I've removed the BR2_GCC_ENABLE_LTO option entirely because it was not actually doing what it advertises.

Let me know what you think.

I've marked this patch as Rejected.

Regards,
Arnout

[1] https://patchwork.ozlabs.org/project/buildroot/list/?series=311175

Quoted 43 lines
Quoted 12 lines
---
  package/valgrind/Config.in   | 10 ++++++++++
  package/valgrind/valgrind.mk |  2 +-
  2 files changed, 11 insertions(+), 1 deletion(-)
package/valgrind/Config.in +0 -0
index 56e4af21fa..eff54e7949 100644

package/valgrind/Config.in config BR2_PACKAGE_VALGRIND_NULGRIND · line 93

Quoted 10 lines
package/valgrind/Config.in +7 -0
@@ -84,4 +84,14 @@ config BR2_PACKAGE_VALGRIND_NULGRIND
  	help
  	  This option allows to install the Nulgrind tool
 
+if BR2_GCC_ENABLE_LTO
+
+config BR2_VALGRIND_ENABLE_LTO
+	bool "Build Valgrind with link-time optimization"
+	help
+	  This produces a faster / smaller valgrind (up to 10%) at the cost
+	  of massively increased build time (can be over an hour).

Be careful with absolute times, depends strongly on the used hardware... (out of interest, what is your baseline compile time?)...

Would move this section up-to/before the tools selection section...

Regards,
Peter

Quoted 12 lines
package/valgrind/Config.in +3 -0
+
+endif
+
  endif
package/valgrind/valgrind.mk +0 -0
index b87e1e518f..07fb1f7d42 100644
@@ -50,7 +50,7 @@ VALGRIND_CONF_OPTS += \
  	--host=$(patsubst arm-%,armv7-%,$(GNU_TARGET_NAME))
  endif
 
Quoted 10 lines

package/valgrind/valgrind.mk VALGRIND_CONF_OPTS += \ · line 56

Quoted 5 lines
package/valgrind/valgrind.mk +1 -1
-ifeq ($(BR2_GCC_ENABLE_LTO),y)
+ifeq ($(BR2_VALGRIND_ENABLE_LTO),y)
  VALGRIND_CONF_OPTS += --enable-lto
  else
  VALGRIND_CONF_OPTS += --disable-lto

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

We don't want to disable LTO globally only for certain packages We want LTO generally but not for a development tool that takes over 1 hour to build with LTO vs 1 minute without it.

Is it possible to do it on a per-package basis?

By the way, it would also be useful to control BR2_STATIC_LIBS on a per-package basis (recent example:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/
)

Quoted 82 lines · Arnout Vandecappelle
Quoted 2 lines · Peter Seiderer

Hello Gleb,
On Sun, 18 Apr 2021 19:36:58 +0100, Gleb Mazovetskiy <[email protected]>

Quoted 12 lines · wrote:
Quoted 3 lines

Valgrind LTO build takes over an hour on my Ryzen 3950x.

Can confirm a build time increase (AMD Ryzen 7 1800X):

- without LTO:

real  0m54,741s
user  3m29,941s
sys   0m10,949s
Quoted 8 lines

- with LTO:

real  5m48,009s
user  6m23,040s
sys   0m13,197s
Quoted 2 lines

This is not always worth it for the ~10% size reduction and a small performance improvement it offers (see

https://www.valgrind.org/docs/manual/dist.news.html)

Quoted 3 lines
Quoted 3 lines

Adds a new BR2_VALGRIND_ENABLE_LTO setting to control LTO enablement for Valgrind separately from the global BR2_GCC_ENABLE_LTO setting.

Adding per-package options to enable debug and optimisation features is
really
not the way to go.

Instead what I've done is to create a series [1] that turns the LTO
option in
a global option, that clearly explains in the help text that it may have a big
impact on build time. I've removed the BR2_GCC_ENABLE_LTO option entirely because it was not actually doing what it advertises.

Let me know what you think.

I've marked this patch as Rejected.

Regards,
Arnout

[1] https://patchwork.ozlabs.org/project/buildroot/list/?series=311175

Quoted 31 lines
Quoted 12 lines
---
  package/valgrind/Config.in   | 10 ++++++++++
  package/valgrind/valgrind.mk |  2 +-
  2 files changed, 11 insertions(+), 1 deletion(-)
package/valgrind/Config.in +0 -0
index 56e4af21fa..eff54e7949 100644

package/valgrind/Config.in config BR2_PACKAGE_VALGRIND_NULGRIND · line 93

Quoted 10 lines
package/valgrind/Config.in +7 -0
@@ -84,4 +84,14 @@ config BR2_PACKAGE_VALGRIND_NULGRIND
     help
       This option allows to install the Nulgrind tool
 
+if BR2_GCC_ENABLE_LTO
+
+config BR2_VALGRIND_ENABLE_LTO
+    bool "Build Valgrind with link-time optimization"
+    help
+      This produces a faster / smaller valgrind (up to 10%) at the cost
+      of massively increased build time (can be over an hour).

Be careful with absolute times, depends strongly on the used hardware... (out of interest, what is your baseline compile time?)...

Would move this section up-to/before the tools selection section...

Regards,
Peter

Quoted 24 lines
Quoted 5 lines

package/valgrind/

Quoted 5 lines
package/valgrind/Config.in +3 -0
+
+endif
+
  endif
package/valgrind/ renamed from package/valgrind/valgrind.mk +0 -0

valgrind.mk

Quoted 17 lines

package/valgrind/valgrind.mk VALGRIND_CONF_OPTS += \ · line 56

Quoted 12 lines

index b87e1e518f..07fb1f7d42 100644

package/valgrind/valgrind.mk +1 -1
@@ -50,7 +50,7 @@ VALGRIND_CONF_OPTS += \
     --host=$(patsubst arm-%,armv7-%,$(GNU_TARGET_NAME))
  endif
 
-ifeq ($(BR2_GCC_ENABLE_LTO),y)
+ifeq ($(BR2_VALGRIND_ENABLE_LTO),y)
  VALGRIND_CONF_OPTS += --enable-lto
  else
  VALGRIND_CONF_OPTS += --disable-lto

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot