treewide: add support for "lto" in PKG_BUILD_FLAGS
This reduces open coding and allows to easily add a knob to enable it treewide, where chosen packages can still opt-out via "no-lto". Some packages used LTO, but not the linker plugin. This unifies 'em all to attempt to produce better code. Quoting man gcc(1): "This improves the quality of optimization by exposing more code to the link-time optimizer." Also use -flto=auto instead of -flto=jobserver, as it's not guaranteed that every buildsystem uses +$(MAKE) correctly. Signed-off-by: Andre Heider <a.heider@gmail.com>
This commit is contained in:
committed by
Christian Marangi
parent
da3700988d
commit
07730ff346
@@ -30,7 +30,7 @@ ifneq ($(strip $(PKG_USE_MIPS16)),1)
|
||||
PKG_BUILD_FLAGS+=no-mips16
|
||||
endif
|
||||
|
||||
__unknown_flags=$(filter-out no-iremap no-mips16 gc-sections no-gc-sections,$(PKG_BUILD_FLAGS))
|
||||
__unknown_flags=$(filter-out no-iremap no-mips16 gc-sections no-gc-sections lto no-lto,$(PKG_BUILD_FLAGS))
|
||||
ifneq ($(__unknown_flags),)
|
||||
$(error unknown PKG_BUILD_FLAGS: $(__unknown_flags))
|
||||
endif
|
||||
@@ -56,6 +56,11 @@ ifeq ($(call pkg_build_flag,gc-sections,0),1)
|
||||
TARGET_CXXFLAGS+= -ffunction-sections -fdata-sections
|
||||
TARGET_LDFLAGS+= -Wl,--gc-sections
|
||||
endif
|
||||
ifeq ($(call pkg_build_flag,lto,0),1)
|
||||
TARGET_CFLAGS+= -flto=auto -fno-fat-lto-objects
|
||||
TARGET_CXXFLAGS+= -flto=auto -fno-fat-lto-objects
|
||||
TARGET_LDFLAGS+= -flto=auto -fuse-linker-plugin
|
||||
endif
|
||||
|
||||
include $(INCLUDE_DIR)/hardening.mk
|
||||
include $(INCLUDE_DIR)/prereq.mk
|
||||
|
||||
Reference in New Issue
Block a user