Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 1 | # To enable LTO, add following in local.conf |
| 2 | # require conf/distro/include/lto.inc |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 3 | # DISTRO_FEATURES:append = " lto" |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 4 | # |
| 5 | |
| 6 | # Disable LTO for following packages |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 7 | LTO:pn-glibc = "" |
| 8 | LTO:pn-gcc-runtime = "" |
| 9 | LTO:pn-libgcc-initial = "" |
| 10 | LTO:pn-libgcc = "" |
| 11 | LTO:pn-libaio = "" |
| 12 | LTO:pn-libpam = "" |
| 13 | LTO:pn-elfutils = "" |
| 14 | LTO:pn-perl = "" |
| 15 | LTO:pn-busybox = "" |
| 16 | LTO:pn-libxcrypt = "" |
| 17 | LTO:pn-curl = "" |
| 18 | LTO:pn-libcap = "" |
| 19 | LTO:pn-libproxy = "" |
| 20 | LTO:pn-libbsd = "" |
| 21 | LTO:pn-perf = "" |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 22 | # webkit is not linking properly with LTO, disable until next time |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 23 | LTO:pn-webkitgtk = "" |
| 24 | LTO:pn-xserver-xorg = "" |
| 25 | LTO:pn-grub = "" |
| 26 | LTO:pn-grub-efi = "" |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 27 | |
| 28 | # Custom LTO flags |
| 29 | # disable partitioning/streaming algorithm since its uses ASM |
| 30 | # constructs not compatible with lto |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 31 | LTOEXTRA:pn-alsa-lib = "-flto-partition=none" |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 32 | |
| 33 | LTOEXTRA ?= "" |
| 34 | |
| 35 | # Override it for additional or different options if needed e.g. |
| 36 | # with clang thin-lto might be better for compile speed |
| 37 | # |
| 38 | # ffat-lto-objects |
| 39 | # object files that contain both the intermediate |
| 40 | # language and the object code. This makes them |
| 41 | # usable for both LTO linking and normal linking |
| 42 | # |
| 43 | # -fuse-linker-plugin |
| 44 | # ensures that libraries participate in LTO by supplying intermediate |
| 45 | # code from .a files to linker |
| 46 | LTO ?= "-flto -ffat-lto-objects -fuse-linker-plugin ${LTOEXTRA}" |
| 47 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 48 | SELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" |
| 49 | TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 50 | |
| 51 | SELECTED_OPTIMIZATION[vardeps] += "LTO LTOEXTRA" |