build: add a config knob to enable LTO for all packages
[openwrt/staging/hauke.git] / include / package.mk
index 0fb947f035c21d3177cb5b99923b2739722fb8bc..d80f3bce49f4c946f9d6c814c976e9f31f6cdb0b 100644 (file)
@@ -51,12 +51,12 @@ ifdef CONFIG_USE_MIPS16
     TARGET_CXXFLAGS += -mips16 -minterlink-mips16
   endif
 endif
-ifeq ($(call pkg_build_flag,gc-sections,0),1)
+ifeq ($(call pkg_build_flag,gc-sections,$(if $(CONFIG_USE_GC_SECTIONS),1,0)),1)
   TARGET_CFLAGS+= -ffunction-sections -fdata-sections
   TARGET_CXXFLAGS+= -ffunction-sections -fdata-sections
   TARGET_LDFLAGS+= -Wl,--gc-sections
 endif
-ifeq ($(call pkg_build_flag,lto,0),1)
+ifeq ($(call pkg_build_flag,lto,$(if $(CONFIG_USE_LTO),1,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