Skip to content

Commit

Permalink
build: unify target independent optimization options
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 37600
  • Loading branch information
Felix Fietkau committed Jul 29, 2013
1 parent 80dd552 commit 73c4d73
Show file tree
Hide file tree
Showing 33 changed files with 51 additions and 44 deletions.
6 changes: 6 additions & 0 deletions Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,12 @@ menuconfig DEVEL
in the package directory, pointing to the .git tree that you want
to pull the source code from

config EXTRA_OPTIMIZATION
string "Additional compiler options" if DEVEL
default "-fno-caller-saves"
help
Extra Target-independent optimizations to use when building for the target.

menuconfig TARGET_OPTIONS
bool "Target Options" if DEVEL

Expand Down
16 changes: 8 additions & 8 deletions include/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,17 @@ ifeq ($(DUMP),1)
# remove duplicates
FEATURES:=$(sort $(FEATURES))
endif
DEFAULT_CFLAGS_i386=-O2 -pipe -march=i486 -fno-caller-saves
DEFAULT_CFLAGS_x86_64=-O2 -pipe -march=athlon64 -fno-caller-saves
DEFAULT_CFLAGS_m68k=-Os -pipe -mcfv4e -fno-caller-saves
DEFAULT_CFLAGS_mips=-Os -pipe -mips32 -mtune=mips32 -fno-caller-saves -mno-branch-likely
DEFAULT_CFLAGS_i386=-O2 -pipe -march=i486
DEFAULT_CFLAGS_x86_64=-O2 -pipe -march=athlon64
DEFAULT_CFLAGS_m68k=-Os -pipe -mcfv4e
DEFAULT_CFLAGS_mips=-Os -pipe -mips32 -mtune=mips32 -mno-branch-likely
DEFAULT_CFLAGS_mipsel=$(DEFAULT_CFLAGS_mips)
DEFAULT_CFLAGS_mips64=-Os -pipe -mips64 -mtune=mips64 -mabi=64 -fno-caller-saves
DEFAULT_CFLAGS_mips64=-Os -pipe -mips64 -mtune=mips64 -mabi=64
DEFAULT_CFLAGS_mips64el=$(DEFAULT_CFLAGS_mips64)
DEFAULT_CFLAGS_sparc=-Os -pipe -mcpu=ultrasparc -fno-caller-saves
DEFAULT_CFLAGS_arm=-Os -pipe -march=armv5te -mtune=xscale -fno-caller-saves
DEFAULT_CFLAGS_sparc=-Os -pipe -mcpu=ultrasparc
DEFAULT_CFLAGS_arm=-Os -pipe -march=armv5te -mtune=xscale
DEFAULT_CFLAGS_armeb=$(DEFAULT_CFLAGS_arm)
DEFAULT_CFLAGS=$(if $(DEFAULT_CFLAGS_$(ARCH)),$(DEFAULT_CFLAGS_$(ARCH)),-Os -pipe -fno-caller-saves)
DEFAULT_CFLAGS=$(if $(DEFAULT_CFLAGS_$(ARCH)),$(DEFAULT_CFLAGS_$(ARCH)),-Os -pipe)
endif

define BuildTargets/DumpCurrent
Expand Down
3 changes: 2 additions & 1 deletion rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONF
ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES))
BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD))
TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION))
export EXTRA_OPTIMIZATION:=$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))
TARGET_SUFFIX=$(call qstrip,$(CONFIG_TARGET_SUFFIX))
BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX))
SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
Expand Down Expand Up @@ -127,7 +128,7 @@ BUILD_LOG_DIR:=$(TOPDIR)/logs
PKG_INFO_DIR := $(STAGING_DIR)/pkginfo

TARGET_PATH:=$(STAGING_DIR_HOST)/bin:$(subst $(space),:,$(filter-out .,$(filter-out ./,$(subst :,$(space),$(PATH)))))
TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)$(if $(CONFIG_DEBUG), -g3)
TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)$(if $(CONFIG_DEBUG), -g3) $(EXTRA_OPTIMIZATION)
TARGET_CXXFLAGS = $(TARGET_CFLAGS)
TARGET_ASFLAGS = $(TARGET_CFLAGS) $(TARGET_ASFLAGS_OVERRIDE)
TARGET_CPPFLAGS:=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
Expand Down
2 changes: 1 addition & 1 deletion target/linux/ar71xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=mips
BOARD:=ar71xx
BOARDNAME:=Atheros AR7xxx/AR9xxx
FEATURES:=squashfs targz mips16
CFLAGS:=-Os -pipe -mips32r2 -mtune=34kc -fno-caller-saves -mno-branch-likely
CFLAGS:=-Os -pipe -mips32r2 -mtune=34kc -mno-branch-likely
SUBTARGETS:=generic nand

LINUX_VERSION:=3.10.3
Expand Down
2 changes: 1 addition & 1 deletion target/linux/at91/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BOARD:=at91
MAINTAINER:=Claudio Mignanti <c.mignanti@gmail.com>
BOARDNAME:=Atmel AT91
FEATURES:=squashfs targz ext2 usb
CFLAGS:=-Os -pipe -march=armv5te -mtune=arm926ej-s -fno-caller-saves
CFLAGS:=-Os -pipe -march=armv5te -mtune=arm926ej-s

LINUX_VERSION:=3.8.13

Expand Down
2 changes: 1 addition & 1 deletion target/linux/cns21xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=arm
BOARD:=cns21xx
BOARDNAME:=Cavium Networks Econa CNS21xx
FEATURES:=squashfs
CFLAGS:=-Os -pipe -march=armv4 -mtune=fa526 -fno-caller-saves
CFLAGS:=-Os -pipe -march=armv4 -mtune=fa526

LINUX_VERSION:=3.8.13

Expand Down
2 changes: 1 addition & 1 deletion target/linux/cns3xxx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=arm
BOARD:=cns3xxx
BOARDNAME:=Cavium Networks Econa CNS3xxx
FEATURES:=squashfs fpu gpio pcie usb usbgadget
CFLAGS:=-Os -pipe -march=armv6k -mtune=mpcore -mfloat-abi=softfp -mfpu=vfp -fno-caller-saves
CFLAGS:=-Os -pipe -march=armv6k -mtune=mpcore -mfloat-abi=softfp -mfpu=vfp
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>

LINUX_VERSION:=3.8.13
Expand Down
2 changes: 1 addition & 1 deletion target/linux/cobalt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=mipsel
BOARD:=cobalt
BOARDNAME:=Cobalt Microservers
FEATURES:=targz pci ext4 display
CFLAGS:=-O2 -pipe -mtune=r5000 -fno-caller-saves
CFLAGS:=-O2 -pipe -mtune=r5000
MAINTAINER:=Florian Fainelli <florian@openwrt.org>

LINUX_VERSION:=3.3.8
Expand Down
2 changes: 1 addition & 1 deletion target/linux/ep93xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=arm
BOARD:=ep93xx
BOARDNAME:=Cirrus Logic EP93xx
FEATURES:=squashfs ext4 targz usb display sound
CFLAGS:=-Os -pipe -march=armv4t -fno-caller-saves
CFLAGS:=-Os -pipe -march=armv4t
MAINTAINER:=Florian Fainelli <florian@openwrt.org>

LINUX_VERSION:=3.8.13
Expand Down
2 changes: 1 addition & 1 deletion target/linux/gemini/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=arm
BOARD:=gemini
BOARDNAME:=Cortina Systems CS351x
FEATURES:=squashfs pci
CFLAGS:=-Os -pipe -march=armv4 -mtune=fa526 -fno-caller-saves
CFLAGS:=-Os -pipe -march=armv4 -mtune=fa526
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>

LINUX_VERSION:=3.9.11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
+KBUILD_CFLAGS += -Os -fno-caller-saves $(call cc-disable-warning,maybe-uninitialized,)
+KBUILD_CFLAGS += -Os $(EXTRA_OPTIMIZATION) $(call cc-disable-warning,maybe-uninitialized,)
else
-KBUILD_CFLAGS += -O2
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch -fno-caller-saves
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION)
endif

include $(srctree)/arch/$(SRCARCH)/Makefile
4 changes: 2 additions & 2 deletions target/linux/generic/patches-3.3/201-extra_optimization.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS += -Os
+KBUILD_CFLAGS += -Os -fno-caller-saves
+KBUILD_CFLAGS += -Os $(EXTRA_OPTIMIZATION)
else
-KBUILD_CFLAGS += -O2
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch -fno-caller-saves
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION)
endif

include $(srctree)/arch/$(SRCARCH)/Makefile
4 changes: 2 additions & 2 deletions target/linux/generic/patches-3.6/201-extra_optimization.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS += -Os
+KBUILD_CFLAGS += -Os -fno-caller-saves
+KBUILD_CFLAGS += -Os $(EXTRA_OPTIMIZATION)
else
-KBUILD_CFLAGS += -O2
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch -fno-caller-saves
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION)
endif

include $(srctree)/arch/$(SRCARCH)/Makefile
4 changes: 2 additions & 2 deletions target/linux/generic/patches-3.8/201-extra_optimization.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS += -Os
+KBUILD_CFLAGS += -Os -fno-caller-saves
+KBUILD_CFLAGS += -Os $(EXTRA_OPTIMIZATION)
else
-KBUILD_CFLAGS += -O2
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch -fno-caller-saves
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION)
endif

include $(srctree)/arch/$(SRCARCH)/Makefile
4 changes: 2 additions & 2 deletions target/linux/generic/patches-3.9/201-extra_optimization.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS += -Os
+KBUILD_CFLAGS += -Os -fno-caller-saves
+KBUILD_CFLAGS += -Os $(EXTRA_OPTIMIZATION)
else
-KBUILD_CFLAGS += -O2
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch -fno-caller-saves
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION)
endif

include $(srctree)/arch/$(SRCARCH)/Makefile
2 changes: 1 addition & 1 deletion target/linux/imx23/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=arm
BOARD:=imx23
BOARDNAME:=Freescale i.MX23 series
FEATURES:=ext4 rtc usb gpio
CFLAGS:=-Os -pipe -march=armv5te -mtune=arm926ej-s -fno-caller-saves
CFLAGS:=-Os -pipe -march=armv5te -mtune=arm926ej-s
MAINTAINER:=Zoltan HERPAI <wigyori@uid0.hu>
LINUX_VERSION:=3.10.3
KERNELNAME:="zImage dtbs"
Expand Down
2 changes: 1 addition & 1 deletion target/linux/lantiq/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SUBTARGETS=xway ase falcon

LINUX_VERSION:=3.8.13

CFLAGS=-Os -pipe -mips32r2 -fno-caller-saves -mno-branch-likely
CFLAGS=-Os -pipe -mips32r2 -mno-branch-likely

define Target/Description
Build firmware images for Lantiq SoC
Expand Down
2 changes: 1 addition & 1 deletion target/linux/malta/be/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARCH_PACKAGES:=malta_mips
SUBTARGET:=be
BOARDNAME:=Big Endian
FEATURES:=ramdisk mips16
CFLAGS:=-Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves
CFLAGS:=-Os -pipe -mips32r2 -mtune=mips32r2

define Target/Description
Build BE firmware images for MIPS Malta CoreLV board running in
Expand Down
2 changes: 1 addition & 1 deletion target/linux/malta/be64/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARCH:=mips64
ARCH_PACKAGES:=malta_mips64
SUBTARGET:=be64
BOARDNAME:=Big Endian (64-bits)
CFLAGS:=-Os -pipe -mips64 -mtune=mips64 -fno-caller-saves
CFLAGS:=-Os -pipe -mips64 -mtune=mips64
FEATURES:=ramdisk

define Target/Description
Expand Down
2 changes: 1 addition & 1 deletion target/linux/malta/le/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARCH_PACKAGES:=malta_mipsel
SUBTARGET:=le
BOARDNAME:=Little Endian
FEATURES:=ramdisk mips16
CFLAGS:=-Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves
CFLAGS:=-Os -pipe -mips32r2 -mtune=mips32r2

define Target/Description
Build LE firmware images for MIPS Malta CoreLV board running in
Expand Down
2 changes: 1 addition & 1 deletion target/linux/malta/le64/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARCH:=mips64el
ARCH_PACKAGES:=malta_mipsel64
SUBTARGET:=le64
BOARDNAME:=Little Endian (64-bits)
CFLAGS:=-Os -pipe -mips64 -mtune=mips64 -fno-caller-saves
CFLAGS:=-Os -pipe -mips64 -mtune=mips64
FEATURES:=ramdisk

define Target/Description
Expand Down
2 changes: 1 addition & 1 deletion target/linux/mcs814x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=arm
BOARD:=mcs814x
BOARDNAME:=Moschip MCS814x
FEATURES:=usb squashfs
CFLAGS=-Os -pipe -march=armv5te -mtune=arm926ej-s -fno-caller-saves
CFLAGS=-Os -pipe -march=armv5te -mtune=arm926ej-s
MAINTAINER:=Florian Fainelli <florian@openwrt.org>

LINUX_VERSION:=3.3.8
Expand Down
2 changes: 1 addition & 1 deletion target/linux/mpc52xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
ARCH:=powerpc
BOARD:=mpc52xx
BOARDNAME:=Freescale MPC52xx
CFLAGS:=-Os -pipe -fno-caller-saves -mcpu=603e
CFLAGS:=-Os -pipe -mcpu=603e
FEATURES:=targz ext4

LINUX_VERSION:=3.8.13
Expand Down
2 changes: 1 addition & 1 deletion target/linux/mpc83xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
ARCH:=powerpc
BOARD:=mpc83xx
BOARDNAME:=Freescale MPC83xx
CFLAGS:=-Os -pipe -fno-caller-saves -mcpu=603e
CFLAGS:=-Os -pipe -mcpu=603e
FEATURES:=squashfs targz
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>

Expand Down
2 changes: 1 addition & 1 deletion target/linux/mpc85xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
ARCH:=powerpc
BOARD:=mpc85xx
BOARDNAME:=Freescale MPC85xx
CFLAGS:=-Os -pipe -fno-caller-saves -mcpu=8540
CFLAGS:=-Os -pipe -mcpu=8540
FEATURES:=spe_fpu squashfs
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>
SUBTARGETS=generic p1020
Expand Down
2 changes: 1 addition & 1 deletion target/linux/omap24xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define Target/Description
TI OMAP-24xx
endef

CFLAGS:=-Os -pipe -march=armv6 -mtune=arm1136j-s -fno-caller-saves
CFLAGS:=-Os -pipe -march=armv6 -mtune=arm1136j-s

KERNELNAME:="zImage"

Expand Down
2 changes: 1 addition & 1 deletion target/linux/orion/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=arm
BOARD:=orion
BOARDNAME:=Marvell Orion
SUBTARGETS:=generic harddisk
CFLAGS=-Os -pipe -march=armv5te -mtune=xscale -fno-caller-saves
CFLAGS=-Os -pipe -march=armv5te -mtune=xscale
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>

LINUX_VERSION:=3.3.8
Expand Down
2 changes: 1 addition & 1 deletion target/linux/ppc40x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=powerpc
BOARD:=ppc40x
BOARDNAME:=AMCC/IBM PPC40x
FEATURES:=squashfs
CFLAGS:=-Os -pipe -fno-caller-saves -mcpu=405
CFLAGS:=-Os -pipe -mcpu=405
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>

LINUX_VERSION:=3.8.13
Expand Down
2 changes: 1 addition & 1 deletion target/linux/ppc44x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=powerpc
BOARD:=ppc44x
BOARDNAME:=AMCC/IBM PPC44x
FEATURES:=squashfs broken
CFLAGS:=-Os -pipe -fno-caller-saves -mcpu=440
CFLAGS:=-Os -pipe -mcpu=440
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>

LINUX_VERSION:=3.8.13
Expand Down
2 changes: 1 addition & 1 deletion target/linux/ramips/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=mipsel
BOARD:=ramips
BOARDNAME:=Ralink RT288x/RT3xxx
SUBTARGETS:=rt288x rt305x rt3883 mt7620a
CFLAGS:=-Os -pipe -fno-caller-saves -mno-branch-likely
CFLAGS:=-Os -pipe -mno-branch-likely
FEATURES:=squashfs gpio

LINUX_VERSION:=3.10.3
Expand Down
2 changes: 1 addition & 1 deletion target/linux/realview/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=arm
BOARD:=realview
BOARDNAME:=ARM Ltd. Realview board (qemu)
FEATURES:=fpu ramdisk
CFLAGS:=-Os -pipe -march=armv6k -mtune=mpcore -mfloat-abi=softfp -mfpu=vfp -fno-caller-saves
CFLAGS:=-Os -pipe -march=armv6k -mtune=mpcore -mfloat-abi=softfp -mfpu=vfp
MAINTAINER:=Florian Fainelli <florian@openwrt.org>

LINUX_VERSION:=3.10.3
Expand Down
2 changes: 1 addition & 1 deletion target/linux/sibyte/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH:=mips
BOARD:=sibyte
BOARDNAME:=Broadcom/SiByte SB-1
FEATURES:=fpu ramdisk broken
CFLAGS:=-Os -pipe -march=sb1 -fno-caller-saves
CFLAGS:=-Os -pipe -march=sb1
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>

LINUX_VERSION:=3.3.8
Expand Down
2 changes: 1 addition & 1 deletion target/linux/x86/rdc/target.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BOARDNAME:=RDC R-321x
FEATURES:=squashfs pci usb gpio pcmcia
CFLAGS:=-Os -pipe -march=i486 -mtune=i486 -fno-caller-saves
CFLAGS:=-Os -pipe -march=i486 -mtune=i486
MAINTAINER:=Florian Fainelli <florian@openwrt.org>

DEFAULT_PACKAGES += kmod-llc kmod-stp kmod-bridge kmod-8021q \
Expand Down

0 comments on commit 73c4d73

Please sign in to comment.