treewide: add support for "lto" in PKG_BUILD_FLAGS
authorAndre Heider <a.heider@gmail.com>
Thu, 2 Feb 2023 20:33:38 +0000 (21:33 +0100)
committerChristian Marangi <ansuelsmth@gmail.com>
Tue, 21 Mar 2023 17:28:22 +0000 (18:28 +0100)
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>
23 files changed:
include/package.mk
package/libs/jansson/Makefile
package/libs/libevent2/Makefile
package/libs/libnftnl/Makefile
package/libs/wolfssl/Makefile
package/network/config/firewall/Makefile
package/network/config/netifd/Makefile
package/network/config/swconfig/Makefile
package/network/services/dnsmasq/Makefile
package/network/services/dropbear/Makefile
package/network/services/hostapd/Makefile
package/network/services/lldpd/Makefile
package/network/services/ppp/Makefile
package/network/services/ustp/Makefile
package/network/utils/iproute2/Makefile
package/network/utils/iw/Makefile
package/network/utils/nftables/Makefile
package/system/mtd/Makefile
package/system/procd/Makefile
package/system/ubus/Makefile
package/system/usign/Makefile
package/utils/busybox/Makefile
package/utils/e2fsprogs/Makefile

index 4d97cda00f0b5c66fba3398d0292166034d3ecef..0fb947f035c21d3177cb5b99923b2739722fb8bc 100644 (file)
@@ -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
index d8567ed79a4f11ffe87b5e2d8b165d357b5836b4..e2b5206acb35bd77e0ddebd925628b0c09653171 100644 (file)
@@ -19,6 +19,8 @@ PKG_LICENSE:=MIT
 PKG_LICENSE_FILES:=LICENSE
 PKG_CPE_ID:=cpe:/a:jansson_project:jansson
 
+PKG_BUILD_FLAGS:=lto
+
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
 
@@ -41,9 +43,6 @@ define Package/jansson/description
   Jansson is a C library for encoding, decoding and manipulating JSON data
 endef
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto
-
 define Package/jansson/install
        $(INSTALL_DIR) $(1)/usr/lib
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjansson*so.* $(1)/usr/lib/
index 50dd19bf00054df5ff660a67f5a4f8e84613fc28..92602607aea25368184889e249e3674983bbe86b 100644 (file)
@@ -26,7 +26,7 @@ PKG_CONFIG_DEPENDS:= \
        CONFIG_PACKAGE_libevent2-pthreads \
        CONFIG_PACKAGE_libevent2-mbedtls
 
-PKG_BUILD_FLAGS:=gc-sections
+PKG_BUILD_FLAGS:=gc-sections lto
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
@@ -114,8 +114,8 @@ define Package/libevent2-pthreads/description
        threading & locking.
 endef
 
-TARGET_CFLAGS += $(FPIC) -flto
-TARGET_LDFLAGS += -Wl,--as-needed -flto
+TARGET_CFLAGS += $(FPIC)
+TARGET_LDFLAGS += -Wl,--as-needed
 
 CMAKE_OPTIONS += \
        -DEVENT__DISABLE_BENCHMARK:BOOL=ON \
index f92fb91eea1211676c0a89d71c3abf08f00f6014..8d8c8c25e37f6901433234912b5766a5375c7df4 100644 (file)
@@ -22,6 +22,7 @@ PKG_LICENSE_FILES:=COPYING
 
 PKG_INSTALL:=1
 PKG_BUILD_PARALLEL:=1
+PKG_BUILD_FLAGS:=lto
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -41,8 +42,7 @@ define Package/libnftnl/description
  programming interface (API) to the in-kernel nf_tables subsystem.
 endef
 
-TARGET_CFLAGS += $(FPIC) -flto
-TARGET_LDFLAGS += -flto
+TARGET_CFLAGS += $(FPIC)
 
 CONFIGURE_ARGS += \
        --enable-static \
index 48e85b0bce8b256989fcf656d412ce61eb1ab72f..04d9d3ef66404037ef5597ae525566c1dce4da47 100644 (file)
@@ -17,7 +17,7 @@ PKG_HASH:=b7ee150e49def77c765bc02aac92ddeb0bebefd4cb12aa263d8f95e405221fb8
 
 PKG_FIXUP:=libtool libtool-abiver
 PKG_INSTALL:=1
-PKG_BUILD_FLAGS:=no-mips16
+PKG_BUILD_FLAGS:=no-mips16 lto
 PKG_BUILD_PARALLEL:=1
 PKG_LICENSE:=GPL-2.0-or-later
 PKG_LICENSE_FILES:=LICENSING COPYING
@@ -118,12 +118,9 @@ endef
 TARGET_CFLAGS += \
        $(FPIC) \
        -fomit-frame-pointer \
-       -flto \
        -DFP_MAX_BITS=8192 \
        $(if $(CONFIG_WOLFSSL_ALT_NAMES),-DWOLFSSL_ALT_NAMES)
 
-TARGET_LDFLAGS += -flto
-
 # --enable-stunnel needed for OpenSSL API compatibility bits
 CONFIGURE_ARGS += \
        --enable-reproducible-build \
index 95e2ae4b674dd313d8368ac917c29e9bf6efd4ec..0e00f386897a7c404f1f3990eec1874aaafdd7ee 100644 (file)
@@ -21,7 +21,7 @@ PKG_LICENSE:=ISC
 
 PKG_CONFIG_DEPENDS := CONFIG_IPV6
 
-PKG_BUILD_FLAGS:=gc-sections
+PKG_BUILD_FLAGS:=gc-sections lto
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
@@ -44,8 +44,6 @@ define Package/firewall/conffiles
 /etc/firewall.user
 endef
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto
 CMAKE_OPTIONS += $(if $(CONFIG_IPV6),,-DDISABLE_IPV6=1)
 
 define Package/firewall/install
index d9d1bce26f04bcf6312a90f17bbabadfb3523ca2..9b5fb08ab033311b96bbc01448f1b63b87cfc0a6 100644 (file)
@@ -13,6 +13,8 @@ PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
 PKG_LICENSE:=GPL-2.0
 PKG_LICENSE_FILES:=
 
+PKG_BUILD_FLAGS:=lto
+
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
 
@@ -30,10 +32,7 @@ endef
 
 TARGET_CFLAGS += \
        -I$(STAGING_DIR)/usr/include/libnl-tiny \
-       -I$(STAGING_DIR)/usr/include \
-       -flto
-
-TARGET_LDFLAGS += -flto -fuse-linker-plugin
+       -I$(STAGING_DIR)/usr/include
 
 CMAKE_OPTIONS += \
        -DLIBNL_LIBS=-lnl-tiny \
index 4d3e572d824a6ad03dbf21922408f80da3ddc541..6549075e5c59013e65206e5264133826b5d7ef7c 100644 (file)
@@ -13,6 +13,8 @@ PKG_RELEASE:=12
 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
 PKG_LICENSE:=GPL-2.0
 
+PKG_BUILD_FLAGS:=lto
+
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/kernel.mk
 
@@ -23,9 +25,6 @@ define Package/swconfig
   TITLE:=Switch configuration utility
 endef
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto=jobserver
-
 TARGET_CPPFLAGS := \
        -D_GNU_SOURCE \
        -I$(STAGING_DIR)/usr/include/libnl-tiny \
index f555712a7f2bb338b660e81052b86b3ec5dce526..d8e2e29a87d937bc2c42d44d32946fa1fd698ad2 100644 (file)
@@ -24,6 +24,7 @@ PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_UPSTR
 
 PKG_INSTALL:=1
 PKG_BUILD_PARALLEL:=1
+PKG_BUILD_FLAGS:=lto
 PKG_ASLR_PIE_REGULAR:=1
 PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcp \
        CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcpv6 \
@@ -133,9 +134,6 @@ endef
 Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
 Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto=jobserver
-
 COPTS = -DHAVE_UBUS -DHAVE_POLL_H \
        $(if $(CONFIG_IPV6),,-DNO_IPV6)
 
index 1b3fdad067bc46ee71eecc96b8a77c6000a60c71..f05248054ecfe0c3b972abbeb797d6b3177463e8 100644 (file)
@@ -23,7 +23,7 @@ PKG_CPE_ID:=cpe:/a:matt_johnston:dropbear_ssh_server
 
 PKG_BUILD_PARALLEL:=1
 PKG_ASLR_PIE_REGULAR:=1
-PKG_BUILD_FLAGS:=no-mips16 gc-sections
+PKG_BUILD_FLAGS:=no-mips16 gc-sections lto
 PKG_FIXUP:=autoreconf
 PKG_FLAGS:=nonshared
 
@@ -142,8 +142,7 @@ DB_OPT_CONFIG = \
        DROPBEAR_SVR_AGENTFWD|CONFIG_DROPBEAR_AGENTFORWARD|1|0 \
 
 
-TARGET_CFLAGS += -DARGTYPE=3 -flto
-TARGET_LDFLAGS += -flto=jobserver
+TARGET_CFLAGS += -DARGTYPE=3
 
 db_opt_add     =echo '\#define $(1) $(2)' >> $(PKG_BUILD_DIR)/localoptions.h
 db_opt_replace =$(ESED) 's,^(\#define $(1)) .*$$$$,\1 $(2),g' $(PKG_BUILD_DIR)/sysoptions.h
index 1b077530e13d9ec1f24892e2654eab8c6c6ca882..f184830be3aea66a9702901f08bdf351d9ed6eef 100644 (file)
@@ -32,7 +32,7 @@ PKG_CONFIG_DEPENDS:= \
        CONFIG_DRIVER_11AX_SUPPORT \
        CONFIG_WPA_ENABLE_WEP
 
-PKG_BUILD_FLAGS:=gc-sections
+PKG_BUILD_FLAGS:=gc-sections lto
 
 EAPOL_TEST_PROVIDERS:=eapol-test eapol-test-openssl eapol-test-wolfssl
 
@@ -587,8 +587,7 @@ TARGET_CPPFLAGS := \
        -D_GNU_SOURCE \
        $(if $(CONFIG_WPA_MSG_MIN_PRIORITY),-DCONFIG_MSG_MIN_PRIORITY=$(CONFIG_WPA_MSG_MIN_PRIORITY))
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin -lubox -lubus
+TARGET_LDFLAGS += -lubox -lubus
 
 ifdef CONFIG_PACKAGE_kmod-cfg80211
   TARGET_LDFLAGS += -lm -lnl-tiny
index a08626366f9d1137ae7a449abfbd1529e3c82f24..c3753534a682ff68d8a901818bb233ce158ae6a3 100644 (file)
@@ -21,6 +21,7 @@ PKG_CPE_ID:=cpe:/a:lldpd_project:lldpd
 
 PKG_FIXUP:=autoreconf
 PKG_BUILD_PARALLEL:=1
+PKG_BUILD_FLAGS:=lto
 PKG_INSTALL:=1
 
 include $(INCLUDE_DIR)/package.mk
@@ -111,7 +112,6 @@ CONFIGURE_ARGS += \
        $(if $(CONFIG_LLDPD_WITH_SNMP),--with-snmp,) \
        $(if $(CONFIG_USE_GLIBC),,--without-libbsd)
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto -Wl,--gc-sections,--as-needed
+TARGET_LDFLAGS += -Wl,--gc-sections,--as-needed
 
 $(eval $(call BuildPackage,lldpd))
index 48f2091a1fce7fe1307b068fcc1174888b91da9c..80d5e46c348a707108734ba44900127351007ad9 100644 (file)
@@ -26,7 +26,7 @@ PKG_VERSION:=$(PKG_RELEASE_VERSION).git-$(PKG_SOURCE_DATE)
 PKG_BUILD_DEPENDS:=libpcap
 
 PKG_ASLR_PIE_REGULAR:=1
-PKG_BUILD_FLAGS:=gc-sections
+PKG_BUILD_FLAGS:=gc-sections lto
 PKG_BUILD_PARALLEL:=1
 PKG_INSTALL:=1
 
@@ -193,9 +193,6 @@ $(call Build/Configure/Default,, \
                $(PKG_BUILD_DIR)/pppd/plugins/pppoatm/linux/
 endef
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto -fuse-linker-plugin
-
 MAKE_FLAGS += COPTS="$(TARGET_CFLAGS)" \
                PRECOMPILED_FILTER=1 \
                STAGING_DIR="$(STAGING_DIR)"
index 88bc993bb652af36dd088a2ea62dbcda544395b6..2cdd033754922cb3ca12d4b2d2388cf4dfcef4f9 100644 (file)
@@ -19,6 +19,8 @@ PKG_MIRROR_HASH:=0e96edc983cf437b95874e5715d743f30bb826d8757dc3771ff872ab9cf18f3
 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
 PKG_LICENSE:=GPL-2.0
 
+PKG_BUILD_FLAGS:=lto
+
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
 
@@ -29,8 +31,7 @@ define Package/ustp
   DEPENDS:=+libubox +libubus
 endef
 
-TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include -flto
-TARGET_LDFLAGS += -flto -fuse-linker-plugin
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
 
 define Package/ustp/install
        $(INSTALL_DIR) $(1)/sbin $(1)/etc/init.d
index b3a809e0b57e880d30c4b614a5551fc7f4fe6c27..2cd14fe83dcab3d902d249fae2d1b693d572b900 100644 (file)
@@ -19,7 +19,7 @@ PKG_BUILD_DEPENDS:=iptables
 PKG_LICENSE:=GPL-2.0
 PKG_CPE_ID:=cpe:/a:iproute2_project:iproute2
 
-PKG_BUILD_FLAGS:=gc-sections
+PKG_BUILD_FLAGS:=gc-sections lto
 
 include $(INCLUDE_DIR)/kernel.mk
 include $(INCLUDE_DIR)/package.mk
@@ -173,7 +173,6 @@ define Build/Configure
                > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
 endef
 
-TARGET_CFLAGS += -flto
 TARGET_LDFLAGS += -Wl,--as-needed
 TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
 
index 1eb3cd721a2de6ee39f137dfd257813773be5355..746c2c3c129cd3e19b3486c71b04cf0b8a626fd0 100644 (file)
@@ -18,7 +18,7 @@ PKG_HASH:=f167bbe947dd53bb9ebc0c1dcef5db6ad73ac1d6084f2c6f9376c5c360cc4d4e
 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
 PKG_LICENSE:=GPL-2.0
 
-PKG_BUILD_FLAGS:=gc-sections
+PKG_BUILD_FLAGS:=gc-sections lto
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -48,8 +48,7 @@ TARGET_CPPFLAGS:= \
        -I$(STAGING_DIR)/usr/include/libnl-tiny \
        $(TARGET_CPPFLAGS) \
        -DCONFIG_LIBNL20 \
-       -D_GNU_SOURCE \
-       -flto
+       -D_GNU_SOURCE
 
 ifeq ($(BUILD_VARIANT),full)
   TARGET_CPPFLAGS += -DIW_FULL
@@ -58,7 +57,7 @@ endif
 
 MAKE_FLAGS += \
        CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
-       LDFLAGS="$(TARGET_LDFLAGS) -flto" \
+       LDFLAGS="$(TARGET_LDFLAGS)" \
        NL1FOUND="" NL2FOUND=Y \
        NLLIBNAME="libnl-tiny" \
        LIBS="-lm -lnl-tiny" \
index 9a180a09539e2f636d5765fc8dd9f85af40e4314..55a6a4bcf69c34f3d71f378613746a6d154331ec 100644 (file)
@@ -20,6 +20,8 @@ PKG_LICENSE_FILES:=COPYING
 PKG_FIXUP:=autoreconf
 PKG_INSTALL:=1
 
+PKG_BUILD_FLAGS:=lto
+
 include $(INCLUDE_DIR)/package.mk
 
 DISABLE_NLS:=
@@ -60,9 +62,6 @@ ifeq ($(BUILD_VARIANT),json)
   CONFIGURE_ARGS += --with-json
 endif
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto
-
 define Build/InstallDev
        $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/
index 1a70a64b7d20040ebd61bed63811b7fb20317555..d45f06fc4354de145861060b40286bae992b4f41 100644 (file)
@@ -18,6 +18,7 @@ PKG_LICENSE:=GPL-2.0+
 PKG_LICENSE_FILES:=
 
 PKG_FLAGS:=nonshared
+PKG_BUILD_FLAGS:=lto
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -36,8 +37,7 @@ endef
 target=$(firstword $(subst -, ,$(BOARD)))
 
 MAKE_FLAGS += TARGET="$(target)"
-TARGET_CFLAGS += -Dtarget_$(target)=1 -Wall -flto
-TARGET_LDFLAGS += -flto=jobserver
+TARGET_CFLAGS += -Dtarget_$(target)=1 -Wall
 
 ifdef CONFIG_MTD_REDBOOT_PARTS
   MAKE_FLAGS += FIS_SUPPORT=1
index 56aa9e0b358a00ac8dddd038667aed399b61d4d6..2d51b51ad72dad1c95d419f00c30673007ab82e9 100644 (file)
@@ -22,6 +22,7 @@ PKG_LICENSE_FILES:=
 
 PKG_MAINTAINER:=John Crispin <john@phrozen.org>
 
+PKG_BUILD_FLAGS:=lto
 PKG_ASLR_PIE_REGULAR:=1
 PKG_CONFIG_DEPENDS:= \
        CONFIG_TARGET_INIT_PATH CONFIG_KERNEL_SECCOMP CONFIG_PROCD_SHOW_BOOT \
@@ -36,9 +37,6 @@ endif
 
 CMAKE_OPTIONS += -DEARLY_PATH="$(TARGET_INIT_PATH)"
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto
-
 define Package/procd/Default
   SECTION:=base
   CATEGORY:=Base system
index 4c72780703b5372db857450f8e5b0deb69763b11..5a951ac2495907d98becdfe760e7e4e29f7b035a 100644 (file)
@@ -15,6 +15,7 @@ PKG_LICENSE:=LGPL-2.1
 PKG_LICENSE_FILES:=
 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
 
+PKG_BUILD_FLAGS:=lto
 PKG_ASLR_PIE_REGULAR:=1
 
 include $(INCLUDE_DIR)/package.mk
@@ -50,8 +51,7 @@ define Package/libubus-lua
   TITLE:=Lua binding for the OpenWrt RPC client
 endef
 
-TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include -flto
-TARGET_LDFLAGS += -flto
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
 
 CMAKE_OPTIONS += \
        -DLUAPATH=/usr/lib/lua \
index 0d2d07017cd445c11dac62b3bb1cfff3b6c5b078..3c28318028c1e059023413510915f84e034bd058 100644 (file)
@@ -10,7 +10,7 @@ PKG_SOURCE_VERSION:=f1f65026a94137c91b5466b149ef3ea3f20091e9
 PKG_MIRROR_HASH:=3f6569a5e63fdfd032976ac0f79d736d3935101ac1b97fb370514b013c5e6bb6
 CMAKE_INSTALL:=1
 PKG_CHECK_FORMAT_SECURITY:=1
-PKG_BUILD_FLAGS:=no-mips16
+PKG_BUILD_FLAGS:=no-mips16 lto
 
 PKG_LICENSE:=ISC
 PKG_LICENSE_FILES:=
@@ -30,9 +30,6 @@ define Package/usign
   TITLE:=OpenWrt signature verification utility
 endef
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto=jobserver
-
 CMAKE_OPTIONS += \
        -DUSE_LIBUBOX=on
 
index 9573278945133423d5cb1a94a71988fbc97604d9..d7ad8ca8fa2d76e521d3f2a76fbe23417ead359a 100644 (file)
@@ -16,6 +16,7 @@ PKG_HASH:=542750c8af7cb2630e201780b4f99f3dcceeb06f505b479ec68241c1e6af61a5
 
 PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam
 PKG_BUILD_PARALLEL:=1
+PKG_BUILD_FLAGS:=lto
 PKG_CHECK_FORMAT_SECURITY:=0
 
 PKG_LICENSE:=GPL-2.0
@@ -103,9 +104,6 @@ ifeq ($(BUILD_VARIANT),selinux)
   LDLIBS += selinux sepol
 endif
 
-TARGET_CFLAGS += -flto
-TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
-
 MAKE_VARS :=
 MAKE_FLAGS += \
        EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
index cd9b10e17596a610e71c6d6248424134f19471cd..9437947ab6949541324ac3fcf286e23dd2e935d9 100644 (file)
@@ -23,7 +23,7 @@ PKG_BUILD_DEPENDS:=util-linux e2fsprogs/host
 PKG_INSTALL:=1
 
 PKG_BUILD_PARALLEL:=1
-PKG_BUILD_FLAGS:=gc-sections
+PKG_BUILD_FLAGS:=gc-sections lto
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/host-build.mk
@@ -143,9 +143,7 @@ $(call Package/e2fsprogs)
   DEPENDS:= +e2fsprogs
 endef
 
-TARGET_CFLAGS += $(FPIC) -flto
-
-TARGET_LDFLAGS += -flto
+TARGET_CFLAGS += $(FPIC)
 
 CONFIGURE_ARGS += \
        --disable-testio-debug \