lto: Add global LTO distro policy file
PATCH v3 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
---
v2: Include feeedback for adding DISTRO_FEATURE knob
v3: Drop unused PACKAGE_DEBUG_SPLIT_STYLE settings
meta/conf/distro/include/lto.inc | 28 ++++++++++++++++++++++++++++ meta/conf/local.conf.sample.extended | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 meta/conf/distro/include/lto.inc
meta/conf/distro/include/lto.inc new file +28 -0
@@ -0,0 +1,28 @@ +# 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"
meta/conf/local.conf.sample.extended +4 -0
@@ -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
PATCH v3 2/2 python3: Enable lto if its in DISTRO_FEATURES
python3 configure compiles on object file and then greps for strings in it for endianness for target ,when using LTO the .o files are not nomal ELF onjects so this test fails, since we are using --enable-lto to enable this here we dont need to inject extra paths via bitbake anyway therefore reset LTO variable for target
---
v3: Reset LTO variable and use --with-lto instead of --enable-lto
meta/recipes-devtools/python/python3_3.9.0.bb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
meta/recipes-devtools/python/python3_3.9.0.bb +5 -1
@@ -74,6 +74,9 @@ export CROSSPYTHONPATH="${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynl EXTRANATIVEPATH += "python3-native" +# LTO will be enabled via packageconfig depending upong distro features +LTO_class-target = "" + CACHED_CONFIGUREVARS = " \ ac_cv_file__dev_ptmx=yes \ ac_cv_file__dev_ptc=no \
@@ -88,7 +91,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 +99,7 @@ PACKAGECONFIG[readline] = ",,readline" PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native" PACKAGECONFIG[tk] = ",,tk" PACKAGECONFIG[gdbm] = ",,gdbm" +PACKAGECONFIG[lto] = "--with-lto,," do_configure_prepend () { mkdir -p ${B}/Modules
Signature · 1 line
2.29.2