busybox: compile with LTO enabled
In the default configuration on MIPS, it reduces the .ipk size from 214k to 207k Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
4e56af5ab4
commit
8c11133c9d
2 changed files with 42 additions and 5 deletions
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=busybox
|
PKG_NAME:=busybox
|
||||||
PKG_VERSION:=1.28.4
|
PKG_VERSION:=1.28.4
|
||||||
PKG_RELEASE:=2
|
PKG_RELEASE:=3
|
||||||
PKG_FLAGS:=essential
|
PKG_FLAGS:=essential
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||||
|
@ -20,7 +20,6 @@ PKG_HASH:=e3c14a3699dc7e82fed397392957afc78e37bdf25398ac38ead6e84621b2ae6a
|
||||||
PKG_BUILD_DEPENDS:=BUSYBOX_USE_LIBRPC:librpc BUSYBOX_CONFIG_PAM:libpam
|
PKG_BUILD_DEPENDS:=BUSYBOX_USE_LIBRPC:librpc BUSYBOX_CONFIG_PAM:libpam
|
||||||
PKG_BUILD_PARALLEL:=1
|
PKG_BUILD_PARALLEL:=1
|
||||||
PKG_CHECK_FORMAT_SECURITY:=0
|
PKG_CHECK_FORMAT_SECURITY:=0
|
||||||
PKG_INSTALL:=1
|
|
||||||
|
|
||||||
#Busybox use it's own PIE config flag and LDFLAGS are used with ld, not gcc.
|
#Busybox use it's own PIE config flag and LDFLAGS are used with ld, not gcc.
|
||||||
PKG_ASLR_PIE:=0
|
PKG_ASLR_PIE:=0
|
||||||
|
@ -75,7 +74,10 @@ endef
|
||||||
export KCONFIG_NOTIMESTAMP=1
|
export KCONFIG_NOTIMESTAMP=1
|
||||||
|
|
||||||
|
|
||||||
|
ifndef CONFIG_USE_MUSL
|
||||||
LDLIBS:=m crypt
|
LDLIBS:=m crypt
|
||||||
|
endif
|
||||||
|
|
||||||
LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
|
LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
|
||||||
ifdef CONFIG_BUSYBOX_USE_LIBRPC
|
ifdef CONFIG_BUSYBOX_USE_LIBRPC
|
||||||
LDLIBS += rpc
|
LDLIBS += rpc
|
||||||
|
@ -84,24 +86,32 @@ ifeq ($(CONFIG_USE_GLIBC),y)
|
||||||
LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
|
LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
TARGET_CFLAGS += -flto
|
||||||
|
TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
|
||||||
|
|
||||||
MAKE_VARS :=
|
MAKE_VARS :=
|
||||||
MAKE_FLAGS += \
|
MAKE_FLAGS += \
|
||||||
EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
|
EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
|
||||||
EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
|
EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||||
LDLIBS="$(LDLIBS)" \
|
LDLIBS="$(LDLIBS)" \
|
||||||
|
LD="$(TARGET_CC)" \
|
||||||
SKIP_STRIP=y
|
SKIP_STRIP=y
|
||||||
ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
|
ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
|
||||||
MAKE_FLAGS += V=1
|
MAKE_FLAGS += V=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
MAKE_INSTALL_FLAGS += CONFIG_PREFIX="$(PKG_INSTALL_DIR)"
|
|
||||||
|
|
||||||
|
|
||||||
define Build/Configure
|
define Build/Configure
|
||||||
grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
|
grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
|
||||||
yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
|
yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(call Build/Compile/Default, \
|
||||||
|
CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
|
||||||
|
all install \
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
define Package/busybox/install
|
define Package/busybox/install
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
$(CP) $(PKG_INSTALL_DIR)/* $(1)/
|
$(CP) $(PKG_INSTALL_DIR)/* $(1)/
|
||||||
|
|
27
package/utils/busybox/patches/120-lto-jobserver.patch
Normal file
27
package/utils/busybox/patches/120-lto-jobserver.patch
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--- a/scripts/Kbuild.include
|
||||||
|
+++ b/scripts/Kbuild.include
|
||||||
|
@@ -130,7 +130,7 @@ make-cmd = $(subst \#,\\\#,$(subst $$,$$
|
||||||
|
#
|
||||||
|
if_changed = $(if $(strip $(filter-out $(PHONY),$?) \
|
||||||
|
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
|
||||||
|
- @set -e; \
|
||||||
|
+ +@set -e; \
|
||||||
|
$(echo-cmd) $(cmd_$(1)); \
|
||||||
|
echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
|
||||||
|
|
||||||
|
@@ -139,7 +139,7 @@ if_changed = $(if $(strip $(filter-out $
|
||||||
|
if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \
|
||||||
|
$(filter-out FORCE $(wildcard $^),$^) \
|
||||||
|
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
|
||||||
|
- @set -e; \
|
||||||
|
+ +@set -e; \
|
||||||
|
$(echo-cmd) $(cmd_$(1)); \
|
||||||
|
scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
|
||||||
|
rm -f $(depfile); \
|
||||||
|
@@ -150,5 +150,5 @@ if_changed_dep = $(if $(strip $(filter-o
|
||||||
|
# and if so will execute $(rule_foo)
|
||||||
|
if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \
|
||||||
|
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
|
||||||
|
- @set -e; \
|
||||||
|
+ +@set -e; \
|
||||||
|
$(rule_$(1)))
|
Loading…
Reference in a new issue