Skip to contentSkip to conversation

lto: Add global LTO distro policy file

PATCH Superseded Khem Raj 2 participants 4 messages Nov 7, 2020

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/2 lto: Add global LTO distro policy file

Distros which want to enable LTO can utilize this file, it only covers packages from OE-Core, other layers should include there own exclusion list for recipe which dont work with LTO

Document the needed changes in local.conf.extended

debug file generator does not generate debugsrc packages when lto is enabled therefore disable it

---
v2: Include feeedback for adding DISTRO_FEATURE knob

 meta/conf/distro/include/lto.inc     | 30 ++++++++++++++++++++++++++++
 meta/conf/local.conf.sample.extended |  4 ++++
 2 files changed, 34 insertions(+)
 create mode 100644 meta/conf/distro/include/lto.inc
meta/conf/distro/include/lto.inc new file +30 -0
new file mode 100644
index 0000000000..1f76ec7c16
@@ -0,0 +1,30 @@
+# To enable LTO, add following in local.conf
+# require conf/distro/include/lto.inc
+# DISTRO_FEATURES_append = " lto"
+#
+
+# Disable LTO for following packages
+LTO_pn-glibc = ""
+LTO_pn-gcc-runtime = ""
+LTO_pn-libgcc-initial = ""
+LTO_pn-libgcc = ""
+LTO_pn-libpam = ""
+LTO_pn-elfutils = ""
+LTO_pn-perl = ""
+LTO_pn-busybox = ""
+LTO_pn-libxcrypt = ""
+LTO_pn-curl = ""
+LTO_pn-libcap = ""
+LTO_pn-libproxy = ""
+LTO_pn-libbsd = ""
+
+# Override it for additional or different options if needed e.g.
+# with clang thin-lto might be better for compile speed
+LTO ?= "-flto"
+
+SELECTED_OPTIMIZATION_append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"
+TARGET_LDFLAGS_append_class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"
+
+SELECTED_OPTIMIZATION[vardeps] += "LTO"
+
+PACKAGE_DEBUG_SPLIT_STYLE_lto = "debug-without-src"
meta/conf/local.conf.sample.extended +4 -0
index 9aa226a2d0..2c4b8ad8cb 100644
@@ -417,3 +417,7 @@
 # ERR_REPORT_UPLOAD_ALL = "1"
 #
 # INHERIT += "report-error"
+
+# Enable LTO Distro-wide
+# require conf/distro/include/lto.inc
+# DISTRO_FEATURES_append = " lto"
Signature · 1 line
2.29.2
author
#1 lore raw

PATCH v2 2/2 python3: Enable lto if its in DISTRO_FEATURES

---
 meta/recipes-devtools/python/python3_3.9.0.bb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/recipes-devtools/python/python3_3.9.0.bb +2 -1
index 6402760a1b..7080312ccf 100644
@@ -88,7 +88,7 @@ def possibly_include_pgo(d):
     
     return ''
 
-PACKAGECONFIG_class-target ??= "readline ${@possibly_include_pgo(d)} gdbm"
+PACKAGECONFIG_class-target ??= "readline ${@possibly_include_pgo(d)} gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}"
 PACKAGECONFIG_class-native ??= "readline gdbm"
 PACKAGECONFIG_class-nativesdk ??= "readline gdbm"
 PACKAGECONFIG[readline] = ",,readline"
@@ -96,6 +96,7 @@ PACKAGECONFIG[readline] = ",,readline"
 PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native"
 PACKAGECONFIG[tk] = ",,tk"
 PACKAGECONFIG[gdbm] = ",,gdbm"
+PACKAGECONFIG[lto] = "--enable-lto,,"
 
 do_configure_prepend () {
     mkdir -p ${B}/Modules
Signature · 1 line
2.29.2
#2 lore raw
In reply to Khem Raj

Does this actually work (I don't see lto added to OVERRIDES) and why is this needed?

PACKAGE_DEBUG_SPLIT_STYLE_lto = "debug-without-src"

Quoted 77 lines · Khem Raj

Distros which want to enable LTO can utilize this file, it only covers packages from OE-Core, other layers should include there own exclusion list for recipe which dont work with LTO

Document the needed changes in local.conf.extended

debug file generator does not generate debugsrc packages when lto is enabled therefore disable it

---
v2: Include feeedback for adding DISTRO_FEATURE knob

 meta/conf/distro/include/lto.inc     | 30 ++++++++++++++++++++++++++++
 meta/conf/local.conf.sample.extended |  4 ++++
 2 files changed, 34 insertions(+)
 create mode 100644 meta/conf/distro/include/lto.inc
meta/conf/distro/include/lto.inc new file +25 -0
new file mode 100644
index 0000000000..1f76ec7c16
@@ -0,0 +1,30 @@
+# To enable LTO, add following in local.conf
+# require conf/distro/include/lto.inc
+# DISTRO_FEATURES_append = " lto"
+#
+
+# Disable LTO for following packages
+LTO_pn-glibc = ""
+LTO_pn-gcc-runtime = ""
+LTO_pn-libgcc-initial = ""
+LTO_pn-libgcc = ""
+LTO_pn-libpam = ""
+LTO_pn-elfutils = ""
+LTO_pn-perl = ""
+LTO_pn-busybox = ""
+LTO_pn-libxcrypt = ""
+LTO_pn-curl = ""
+LTO_pn-libcap = ""
+LTO_pn-libproxy = ""
+LTO_pn-libbsd = ""
+
+# Override it for additional or different options if needed e.g.
+# with clang thin-lto might be better for compile speed
+LTO ?= "-flto"
+
+SELECTED_OPTIMIZATION_append = "${@bb.utils.contains('DISTRO_FEATURES',

'lto', ' ${LTO}', '', d)}" +TARGET_LDFLAGS_append_class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"

meta/conf/distro/include/lto.inc new file +4 -0
+
+SELECTED_OPTIMIZATION[vardeps] += "LTO"
+
+PACKAGE_DEBUG_SPLIT_STYLE_lto = "debug-without-src"
meta/conf/local.conf.sample.extended +4 -1
index 9aa226a2d0..2c4b8ad8cb 100644
@@ -417,3 +417,7 @@
 # ERR_REPORT_UPLOAD_ALL = "1"
 #
 # INHERIT += "report-error"
+
+# Enable LTO Distro-wide
+# require conf/distro/include/lto.inc
+# DISTRO_FEATURES_append = " lto"
--

2.29.2

author
#3 lore raw
Quoted 4 lines · Martin Jansa

Does this actually work (I don't see lto added to OVERRIDES) and why is this needed?

PACKAGE_DEBUG_SPLIT_STYLE_lto = "debug-without-src"

Right, it is a nop, which means it's not needed anymore, it was needed in the past as packaging failed for some packages.
Let me remove it and do the image build and perhaps remove it in v3.

Quoted 75 lines · Khem Raj
Quoted 73 lines

Distros which want to enable LTO can utilize this file, it only covers packages from OE-Core, other layers should include there own exclusion list for recipe which dont work with LTO

Document the needed changes in local.conf.extended

debug file generator does not generate debugsrc packages when lto is enabled therefore disable it

---
v2: Include feeedback for adding DISTRO_FEATURE knob

 meta/conf/distro/include/lto.inc     | 30 ++++++++++++++++++++++++++++
 meta/conf/local.conf.sample.extended |  4 ++++
 2 files changed, 34 insertions(+)
 create mode 100644 meta/conf/distro/include/lto.inc
meta/conf/distro/include/lto.inc new file +30 -0
new file mode 100644
index 0000000000..1f76ec7c16
@@ -0,0 +1,30 @@
+# To enable LTO, add following in local.conf
+# require conf/distro/include/lto.inc
+# DISTRO_FEATURES_append = " lto"
+#
+
+# Disable LTO for following packages
+LTO_pn-glibc = ""
+LTO_pn-gcc-runtime = ""
+LTO_pn-libgcc-initial = ""
+LTO_pn-libgcc = ""
+LTO_pn-libpam = ""
+LTO_pn-elfutils = ""
+LTO_pn-perl = ""
+LTO_pn-busybox = ""
+LTO_pn-libxcrypt = ""
+LTO_pn-curl = ""
+LTO_pn-libcap = ""
+LTO_pn-libproxy = ""
+LTO_pn-libbsd = ""
+
+# Override it for additional or different options if needed e.g.
+# with clang thin-lto might be better for compile speed
+LTO ?= "-flto"
+
+SELECTED_OPTIMIZATION_append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"
+TARGET_LDFLAGS_append_class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"
+
+SELECTED_OPTIMIZATION[vardeps] += "LTO"
+
+PACKAGE_DEBUG_SPLIT_STYLE_lto = "debug-without-src"
meta/conf/local.conf.sample.extended +4 -1
index 9aa226a2d0..2c4b8ad8cb 100644
@@ -417,3 +417,7 @@
 # ERR_REPORT_UPLOAD_ALL = "1"
 #
 # INHERIT += "report-error"
+
+# Enable LTO Distro-wide
+# require conf/distro/include/lto.inc
+# DISTRO_FEATURES_append = " lto"
--

2.29.2