diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-29 00:36:57 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-29 00:36:57 +0000 |
commit | e348b8f72b21aa7c645f392b6c11d51c255bb561 (patch) | |
tree | b5fc3629963d236762c0a7e216e983ac79951bd0 /Rules.mak | |
parent | e1ede7086d91def0b93db43f7526e50ccbdda608 (diff) |
build system: use a bit more aggressive gcc/ld optimizations,
mostly related to ELF section ans padding, not code gen.
Resulting reductions in size (only biggest ones are shown)
uClibc.t4 - new, uClibc.t3 - old:
15673 244 92 16009 3e89 uClibc.t4-stdcfg_so/lib/ld-uClibc-0.9.29.so
15673 244 92 16009 3e89 uClibc.t4-stdcfg_so/lib/ld-uClibc.so
15673 244 92 16009 3e89 uClibc.t4-stdcfg_so/lib/ld-uClibc.so.0
15678 244 92 16014 3e8e uClibc.t3-stdcfg_so/lib/ld-uClibc-0.9.29.so
15678 244 92 16014 3e8e uClibc.t3-stdcfg_so/lib/ld-uClibc.so
15678 244 92 16014 3e8e uClibc.t3-stdcfg_so/lib/ld-uClibc.so.0
39910 200 4 40114 9cb2 uClibc.t4-stdcfg_so/lib/libm-0.9.29.so
39910 200 4 40114 9cb2 uClibc.t4-stdcfg_so/lib/libm.so
39910 200 4 40114 9cb2 uClibc.t4-stdcfg_so/lib/libm.so.0
40179 200 4 40383 9dbf uClibc.t3-stdcfg_so/lib/libm-0.9.29.so
40179 200 4 40383 9dbf uClibc.t3-stdcfg_so/lib/libm.so
40179 200 4 40383 9dbf uClibc.t3-stdcfg_so/lib/libm.so.0
234104 1472 5980 241556 3af94 uClibc.t4-stdcfg_so/lib/libc.so.0
234104 1472 5980 241556 3af94 uClibc.t4-stdcfg_so/lib/libuClibc-0.9.29.so
235319 1472 5992 242783 3b45f uClibc.t3-stdcfg_so/lib/libc.so.0
235319 1472 5992 242783 3b45f uClibc.t3-stdcfg_so/lib/libuClibc-0.9.29.so
Diffstat (limited to 'Rules.mak')
-rw-r--r-- | Rules.mak | 54 |
1 files changed, 50 insertions, 4 deletions
@@ -138,6 +138,7 @@ check_ld=$(shell \ ARFLAGS:=cr +# Flags in OPTIMIZATION are used only for non-debug builds OPTIMIZATION:= # Use '-Os' optimization if available, else use -O2, allow Config to override OPTIMIZATION+=$(call check_gcc,-Os,-O2) @@ -167,8 +168,53 @@ PIEFLAG_NAME:=-fPIE # Some nice CPU specific optimizations ifeq ($(TARGET_ARCH),i386) + OPTIMIZATION+=$(call check_gcc,-fomit-frame-pointer,) + + # NB: this may make SSE insns segfault! + # -O1 -march=pentium3, -Os -msse etc are known to be affected. + # TODO: conditionally bump to 4 + # (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13685) OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,) - OPTIMIZATION+=$(call check_gcc,-falign-jumps=0 -falign-loops=0,-malign-jumps=0 -malign-loops=0) + + # Choice of alignment (please document why!) + # -falign-labels: in-line labels + # (reachable by normal code flow, aligning will insert nops + # which will be executed - may even make things slower) + # -falign-jumps: reachable only by a jump + # Generic: no alignment at all (smallest code) + GCC_FALIGN=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,-malign-jumps=1 -malign-loops=1) +ifeq ($(CONFIG_K7),y) + # Align functions to four bytes, use default for labels and loops (why?) + GCC_FALIGN=$(call check_gcc,-falign-functions=4 -falign-jumps=1,-malign-functions=4 -falign-jumps=1) +endif +ifeq ($(CONFIG_CRUSOE),y) + # Use compiler's default for functions, labels and loops (why?) + GCC_FALIGN=$(call check_gcc,-falign-functions=0 -falign-jumps=1,-malign-functions=0 -falign-jumps=1) +endif +ifeq ($(CONFIG_CYRIXIII),y) + # Use compiler's default for functions, labels and loops (why?) + GCC_FALIGN=$(call check_gcc,-falign-functions=0 -falign-jumps=1,-malign-functions=0 -falign-jumps=1) +endif + OPTIMIZATION+=$(GCC_FALIGN) + + # Putting each function and data object into its own section + # allows for kbytes of less text if users link against static uclibc + # using ld --gc-sections. + # ld 2.18 can't do that (yet?) for shared libraries, so we itself + # do not use --gc-sections at shared lib link time. + # However, in combination with sections being sorted by alignment + # it does result in much reduced padding: + # text data bss dec hex + # 235319 1472 5992 242783 3b45f old.so + # 234104 1472 5980 241556 3af94 new.so + # Without -ffunction-sections, all functions will get aligned + # to 4 byte boundary by as/ld. This is arguably a bug in as. + # It specifies 4 byte align for .text even if not told to do so: + # Idx Name Size VMA LMA File off Algn + # 0 .text xxxxxxxx 00000000 00000000 xxxxxxxx 2**2 <===! + CPU_CFLAGS-y += $(call check_gcc,-ffunction-sections -fdata-sections,) + CPU_LDFLAGS-y += -Wl,--sort-common -Wl,--sort-section -Wl,alignment + CPU_LDFLAGS-y+=-m32 CPU_CFLAGS-y+=-m32 CPU_CFLAGS-$(CONFIG_386)+=-march=i386 @@ -181,11 +227,11 @@ ifeq ($(TARGET_ARCH),i386) CPU_CFLAGS-$(CONFIG_PENTIUMIII)+=$(call check_gcc,-march=pentium3,-march=i686) CPU_CFLAGS-$(CONFIG_PENTIUM4)+=$(call check_gcc,-march=pentium4,-march=i686) CPU_CFLAGS-$(CONFIG_K6)+=$(call check_gcc,-march=k6,-march=i586) - CPU_CFLAGS-$(CONFIG_K7)+=$(call check_gcc,-march=athlon,-march=i686) $(call check_gcc,-falign-functions=4,-malign-functions=4) - CPU_CFLAGS-$(CONFIG_CRUSOE)+=-march=i686 $(call check_gcc,-falign-functions=0,-malign-functions=0) + CPU_CFLAGS-$(CONFIG_K7)+=$(call check_gcc,-march=athlon,-march=i686) + CPU_CFLAGS-$(CONFIG_CRUSOE)+=-march=i686 CPU_CFLAGS-$(CONFIG_WINCHIPC6)+=$(call check_gcc,-march=winchip-c6,-march=i586) CPU_CFLAGS-$(CONFIG_WINCHIP2)+=$(call check_gcc,-march=winchip2,-march=i586) - CPU_CFLAGS-$(CONFIG_CYRIXIII)+=$(call check_gcc,-march=c3,-march=i486) $(call check_gcc,-falign-functions=0,-malign-functions=0) + CPU_CFLAGS-$(CONFIG_CYRIXIII)+=$(call check_gcc,-march=c3,-march=i486) CPU_CFLAGS-$(CONFIG_NEHEMIAH)+=$(call check_gcc,-march=c3-2,-march=i686) endif |