OSDN Git Service

Support arch specific optimizations (examples shown for x86 and ARM).
authorEric Andersen <andersen@codepoet.org>
Tue, 1 Jan 2002 22:16:45 +0000 (22:16 -0000)
committerEric Andersen <andersen@codepoet.org>
Tue, 1 Jan 2002 22:16:45 +0000 (22:16 -0000)
Autodetect target architecture by asking the compiler.
 -Erik

Rules.mak
extra/Configs/Config.arm
extra/Configs/Config.cross.arm.uclinux
extra/Configs/Config.i386
extra/Configs/Config.m68k
extra/Configs/Config.m68k.coff
extra/Configs/Config.mips
extra/Configs/Config.mipsel
extra/Configs/Config.powerpc
extra/Configs/Config.sh
extra/Configs/Config.v850e

index 534a978..6dbc96f 100644 (file)
--- a/Rules.mak
+++ b/Rules.mak
@@ -38,11 +38,28 @@ BUILDTIME = ${shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z"}
 GCCINCDIR = ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
 NATIVE_ARCH = ${shell uname -m | sed -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
                -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/ppc/powerpc/g'}
+TARGET_ARCH=${shell $(CC) -dumpmachine | sed -e s'/-linux//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
+               -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/ppc/powerpc/g'}
 
-# use '-Os' optimization if available, else use -O2, allow Config to override
+# Some nice architecture specific optimizations
 ifndef OPTIMIZATION
+# use '-Os' optimization if available, else use -O2, allow Config to override
 OPTIMIZATION = ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
     then echo "-Os"; else echo "-O2" ; fi}
+ifeq ($(strip $(TARGET_ARCH)),arm)
+       OPTIMIZATION+=-fstrict-aliasing
+endif
+ifeq ($(strip $(TARGET_ARCH)),i386)
+       OPTIMIZATION+=-march=i386
+       OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
+               /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
+       OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -malign-loops=0 \
+               -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo \
+               "-malign-functions=0 -malign-jumps=0 -malign-loops=0"; fi}
+       CPUFLAGS+=-pipe
+else
+       CPUFLAGS+=-pipe
+endif
 endif
 
 ARFLAGS=r
@@ -75,7 +92,7 @@ ifeq ($(strip $(HAVE_SHARED)),true)
 ifeq ($(strip $(BUILD_UCLIBC_LDSO)),true)
        LDSO=$(TOPDIR)lib/$(UCLIBC_LDSO)
        DYNAMIC_LINKER=$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO)
-       BUILD_DYNAMIC_LINKER=$(shell cd $(TOPDIR)lib; pwd)/$(UCLIBC_LDSO)
+       BUILD_DYNAMIC_LINKER=${shell cd $(TOPDIR)lib && pwd}/$(UCLIBC_LDSO)
 else
        LDSO=$(SYSTEM_LDSO)
        DYNAMIC_LINKER=/lib/$(notdir $(SYSTEM_LDSO))
index d68a3e2..95ebe84 100644 (file)
 # other sundry sources.  Files within this library are copyright by their
 # respective copyright holders.
 
-# What arch do you want to compile for...
-TARGET_ARCH=arm
-#TARGET_ARCH=i386
-#TARGET_ARCH=m68k
-#TARGET_ARCH=powerpc
-#TARGET_ARCH=sh
-#TARGET_ARCH=sparc
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 CROSS = #arm-linux-
 CC = $(CROSS)gcc
index 5058c4e..d90c1ee 100644 (file)
 # other sundry sources.  Files within this library are copyright by their
 # respective copyright holders.
 
-# What arch do you want to compile for...
-TARGET_ARCH=arm
-#TARGET_ARCH=i386
-#TARGET_ARCH=m68k
-#TARGET_ARCH=powerpc
-#TARGET_ARCH=sh
-#TARGET_ARCH=sparc
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 CROSS = arm-elf-
 CC = $(CROSS)gcc
index 11e3566..c7c2025 100644 (file)
 # other sundry sources.  Files within this library are copyright by their
 # respective copyright holders.
 
-# What arch do you want to compile for...
-#TARGET_ARCH=arm
-TARGET_ARCH=i386
-#TARGET_ARCH=m68k
-#TARGET_ARCH=powerpc
-#TARGET_ARCH=sh
-#TARGET_ARCH=sparc
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 CROSS = #$(TARGET_ARCH)-linux-
 CC = $(CROSS)gcc
index 1ebe7b0..b6bb64d 100644 (file)
 # other sundry sources.  Files within this library are copyright by their
 # respective copyright holders.
 
-# What arch do you want to compile for...
-#TARGET_ARCH=arm
-#TARGET_ARCH=i386
-TARGET_ARCH=m68k
-#TARGET_ARCH=powerpc
-#TARGET_ARCH=sh
-#TARGET_ARCH=sparc
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 #CROSS = m68k-elf-
 CC = $(CROSS)gcc
index c452433..0794431 100644 (file)
 # other sundry sources.  Files within this library are copyright by their
 # respective copyright holders.
 
-# What arch do you want to compile for...
-#TARGET_ARCH=arm
-#TARGET_ARCH=i386
-TARGET_ARCH=m68k
-#TARGET_ARCH=powerpc
-#TARGET_ARCH=sh
-#TARGET_ARCH=sparc
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 CROSS = m68k-coff-
 CC = $(CROSS)gcc
index 817a608..d2ba472 100644 (file)
 # other sundry sources.  Files within this library are copyright by their
 # respective copyright holders.
 
-# What arch do you want to compile for...
-#TARGET_ARCH=arm
-#TARGET_ARCH=i386
-#TARGET_ARCH=m68k
-#TARGET_ARCH=powerpc
-#TARGET_ARCH=sh
-#TARGET_ARCH=sparc
-TARGET_ARCH=mipsel
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 CROSS = mipsel-linux-
 CC = $(CROSS)gcc
index 817a608..d2ba472 100644 (file)
 # other sundry sources.  Files within this library are copyright by their
 # respective copyright holders.
 
-# What arch do you want to compile for...
-#TARGET_ARCH=arm
-#TARGET_ARCH=i386
-#TARGET_ARCH=m68k
-#TARGET_ARCH=powerpc
-#TARGET_ARCH=sh
-#TARGET_ARCH=sparc
-TARGET_ARCH=mipsel
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 CROSS = mipsel-linux-
 CC = $(CROSS)gcc
index 7022dfd..fe20607 100644 (file)
 # other sundry sources.  Files within this library are copyright by their
 # respective copyright holders.
 
-# What arch do you want to compile for...
-#TARGET_ARCH=arm
-#TARGET_ARCH=i386
-#TARGET_ARCH=m68k
-TARGET_ARCH=powerpc
-#TARGET_ARCH=sh
-#TARGET_ARCH=sparc
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 CROSS = #$(TARGET_ARCH)-linux-
 CC = $(CROSS)gcc
index 5b56457..4e337e6 100644 (file)
 # other sundry sources.  Files within this library are copyright by their
 # respective copyright holders.
 
-# What arch do you want to compile for...
-#TARGET_ARCH=arm
-#TARGET_ARCH=i386
-#TARGET_ARCH=m68k
-#TARGET_ARCH=powerpc
-TARGET_ARCH=sh
-#TARGET_ARCH=sparc
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 CROSS = /usr/cygnus/yapp-001013/H-i686-pc-linux-gnulibc2.1/bin/sh-linux-gnu-
 CC = $(CROSS)gcc
index 25031dd..d7d93e5 100644 (file)
@@ -30,11 +30,9 @@ PROJ_UCLINUX=/proj/soft2/uclinux
 # Cross compile on i386-pc-linux-gnu
 DESTDIR=$(PROJ_UCLINUX)/i386-pc-linux-gnu/v850e-linux
 
-# What arch do you want to compile for...
-TARGET_ARCH = v850
-
 # If you are running a cross compiler, you may want to set this
-# to something more interesting...
+# to something more interesting...  Target architecture is determined
+# by asking this compiler what arch it compiles stuff for.
 NATIVE_CC = gcc
 CROSS = v850e-elf-
 CC = $(CROSS)gcc