blob: b8193725a15a06a0ecfd1fff37c9a7d6238b72a8 [file] [log] [blame]
Andrew Geissler6ce62a22020-11-30 19:58:47 -06001# To enable LTO, add following in local.conf
2# require conf/distro/include/lto.inc
Patrick Williams213cb262021-08-07 19:21:33 -05003# DISTRO_FEATURES:append = " lto"
Andrew Geissler6ce62a22020-11-30 19:58:47 -06004#
5
6# Disable LTO for following packages
Patrick Williams213cb262021-08-07 19:21:33 -05007LTO:pn-glibc = ""
8LTO:pn-gcc-runtime = ""
9LTO:pn-libgcc-initial = ""
10LTO:pn-libgcc = ""
11LTO:pn-libaio = ""
12LTO:pn-libpam = ""
13LTO:pn-elfutils = ""
14LTO:pn-perl = ""
15LTO:pn-busybox = ""
16LTO:pn-libxcrypt = ""
17LTO:pn-curl = ""
18LTO:pn-libcap = ""
19LTO:pn-libproxy = ""
20LTO:pn-libbsd = ""
21LTO:pn-perf = ""
Andrew Geissler6ce62a22020-11-30 19:58:47 -060022# webkit is not linking properly with LTO, disable until next time
Patrick Williams213cb262021-08-07 19:21:33 -050023LTO:pn-webkitgtk = ""
24LTO:pn-xserver-xorg = ""
25LTO:pn-grub = ""
26LTO:pn-grub-efi = ""
Andrew Geissler6ce62a22020-11-30 19:58:47 -060027
28# Custom LTO flags
29# disable partitioning/streaming algorithm since its uses ASM
30# constructs not compatible with lto
Patrick Williams213cb262021-08-07 19:21:33 -050031LTOEXTRA:pn-alsa-lib = "-flto-partition=none"
Andrew Geissler6ce62a22020-11-30 19:58:47 -060032
33LTOEXTRA ?= ""
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
46LTO ?= "-flto -ffat-lto-objects -fuse-linker-plugin ${LTOEXTRA}"
47
Patrick Williams213cb262021-08-07 19:21:33 -050048SELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"
49TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}"
Andrew Geissler6ce62a22020-11-30 19:58:47 -060050
51SELECTED_OPTIMIZATION[vardeps] += "LTO LTOEXTRA"