[asterisk-commits] kpfleming: trunk r310332 - in /trunk: ./ codecs/gsm/ codecs/lpc10/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 11 09:09:28 CST 2011


Author: kpfleming
Date: Fri Mar 11 09:09:23 2011
New Revision: 310332

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=310332
Log:
Use "-march=native" when possible.

Recent versions of GCC have a tuning option value of 'native', which causes
the compiler to optimize the build for the CPU the compile is performed on.
Since most people are building Asterisk on the machine they plan to run it on,
the configure script and build system will now use this value unless a different
value is specified by the user in CFLAGS when the configure script is executed.
In addition, this value will be used for building the GSM and LPC10 codecs as
well, in preference to the logic that has been in their Makefiles forever to
optimize for certain types of CPUs.


Modified:
    trunk/Makefile
    trunk/codecs/gsm/Makefile
    trunk/codecs/lpc10/Makefile
    trunk/configure
    trunk/configure.ac
    trunk/makeopts.in

Modified: trunk/Makefile
URL: http://svnview.digium.com/svn/asterisk/trunk/Makefile?view=diff&rev=310332&r1=310331&r2=310332
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Fri Mar 11 09:09:23 2011
@@ -223,8 +223,12 @@
 endif
 
 ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
-  ifneq ($(PROC),ultrasparc)
-    _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
+  ifneq ($(AST_MARCH_NATIVE),)
+    _ASTCFLAGS+=$(AST_MARCH_NATIVE)
+  else
+    ifneq ($(PROC),ultrasparc)
+      _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
+    endif
   endif
 endif
 
@@ -233,8 +237,10 @@
 endif
 
 ifeq ($(OSARCH),FreeBSD)
-  ifeq ($(PROC),i386)
-    _ASTCFLAGS+=-march=i686
+  ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
+    ifeq ($(PROC),i386)
+      _ASTCFLAGS+=-march=i686
+    endif
   endif
   # -V is understood by BSD Make, not by GNU make.
   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)

Modified: trunk/codecs/gsm/Makefile
URL: http://svnview.digium.com/svn/asterisk/trunk/codecs/gsm/Makefile?view=diff&rev=310332&r1=310331&r2=310332
==============================================================================
--- trunk/codecs/gsm/Makefile (original)
+++ trunk/codecs/gsm/Makefile Fri Mar 11 09:09:23 2011
@@ -45,28 +45,33 @@
 OPTIMIZE=-O2
 endif
 
-ifeq (,$(findstring $(shell uname -s),Darwin SunOS))
-  ifeq (,$(strip $(findstring $(PROC) ,"x86_64 amd64 ultrasparc sparc64 arm armv5b armeb ppc powerpc ppc64 ia64 s390 bfin mipsel mips ")))
-    ifeq (,$(strip $(findstring $(shell uname -m) ,"ppc ppc64 alpha armv4l s390 ")))
-      OPTIMIZE+=-march=$(PROC)
+# If the compiler's '-march' flag has been specified already, then assume it's a value
+# that is what the user wants (or has been determined by the configure script). If not,
+# do some simple logic to set a decent value
+ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
+  ifeq (,$(findstring $(shell uname -s),Darwin SunOS))
+    ifeq (,$(strip $(findstring $(PROC) ,"x86_64 amd64 ultrasparc sparc64 arm armv5b armeb ppc powerpc ppc64 ia64 s390 bfin mipsel mips ")))
+      ifeq (,$(strip $(findstring $(shell uname -m) ,"ppc ppc64 alpha armv4l s390 ")))
+        OPTIMIZE+=-march=$(PROC)
+      endif
+    endif
+  else
+    ifneq (,$(findstring $(OSARCH),Darwin))
+      ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6)
+        # Snow Leopard reports i386, even though it's really x86_64
+        OPTIMIZE+=-mtune=native
+      endif
     endif
   endif
-else
-  ifneq (,$(findstring $(OSARCH),Darwin))
-    ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6)
-      # Snow Leopard reports i386, even though it's really x86_64
-      OPTIMIZE+=-mtune=native
-    endif
+
+  #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
+  #This works for even old (2.96) versions of gcc and provides a small boost either way.
+  #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
+  #So we go lowest common available by gcc and go a step down, still a step up from
+  #the default as we now have a better instruction set to work with. - Belgarath
+  ifeq ($(PROC),ultrasparc)
+  OPTIMIZE+=-mcpu=v8 -mtune=$(PROC) -O3 
   endif
-endif
-
-#The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
-#This works for even old (2.96) versions of gcc and provides a small boost either way.
-#A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
-#So we go lowest common available by gcc and go a step down, still a step up from
-#the default as we now have a better instruction set to work with. - Belgarath
-ifeq ($(PROC),ultrasparc)
-OPTIMIZE+=-mcpu=v8 -mtune=$(PROC) -O3 
 endif
 
 PG =

Modified: trunk/codecs/lpc10/Makefile
URL: http://svnview.digium.com/svn/asterisk/trunk/codecs/lpc10/Makefile?view=diff&rev=310332&r1=310331&r2=310332
==============================================================================
--- trunk/codecs/lpc10/Makefile (original)
+++ trunk/codecs/lpc10/Makefile Fri Mar 11 09:09:23 2011
@@ -27,30 +27,35 @@
 # fails miserably. Remove it for the time being.
 _ASTCFLAGS:=$(_ASTCFLAGS:-Werror=)
 
-#fix for PPC processors and ALPHA, And UltraSparc too
-ifneq ($(OSARCH),Darwin)
- ifneq ($(findstring BSD,${OSARCH}),BSD)
-  ifneq ($(PROC),ppc)
-   ifneq ($(PROC),x86_64)
-    ifneq ($(PROC),alpha)
-#The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
-#This works for even old (2.96) versions of gcc and provides a small boost either way.
-#A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn.t support it.
-#So we go lowest common available by gcc and go a step down, still a step up from
-#the default as we now have a better instruction set to work with. - Belgarath
-     ifeq ($(PROC),ultrasparc)
-        CFLAGS+= -mtune=$(PROC) -mcpu=v8 -O3 -fomit-frame-pointer
-     else
-      ifneq ($(OSARCH),SunOS)
-       ifneq  ($(OSARCH),arm)
-#        CFLAGS+= -march=$(PROC)
+# If the compiler's '-march' flag has been specified already, then assume it's a value
+# that is what the user wants (or has been determined by the configure script). If not,
+# do some simple logic to set a decent value
+ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
+  #fix for PPC processors and ALPHA, And UltraSparc too
+  ifneq ($(OSARCH),Darwin)
+   ifneq ($(findstring BSD,${OSARCH}),BSD)
+    ifneq ($(PROC),ppc)
+     ifneq ($(PROC),x86_64)
+      ifneq ($(PROC),alpha)
+  #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
+  #This works for even old (2.96) versions of gcc and provides a small boost either way.
+  #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn.t support it.
+  #So we go lowest common available by gcc and go a step down, still a step up from
+  #the default as we now have a better instruction set to work with. - Belgarath
+       ifeq ($(PROC),ultrasparc)
+          CFLAGS+= -mtune=$(PROC) -mcpu=v8 -O3 -fomit-frame-pointer
+       else
+        ifneq ($(OSARCH),SunOS)
+         ifneq  ($(OSARCH),arm)
+  #        CFLAGS+= -march=$(PROC)
+         endif
+        endif
        endif
       endif
      endif
     endif
    endif
   endif
- endif
 endif
 
 LIB = $(LIB_TARGET_DIR)/liblpc10.a

Modified: trunk/configure.ac
URL: http://svnview.digium.com/svn/asterisk/trunk/configure.ac?view=diff&rev=310332&r1=310331&r2=310332
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Mar 11 09:09:23 2011
@@ -918,6 +918,16 @@
 fi
 AC_SUBST(AST_SHADOW_WARNINGS)
 
+AC_MSG_CHECKING(for -march=native)
+if $(${CC} -march=native -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
+	AC_MSG_RESULT(yes)
+	AST_MARCH_NATIVE="-march=native"
+else
+	AC_MSG_RESULT(no)
+	AST_MARCH_NATIVE=
+fi
+AC_SUBST(AST_MARCH_NATIVE)
+
 AC_MSG_CHECKING(for sysinfo)
 AC_LINK_IFELSE(
         AC_LANG_PROGRAM([#include <sys/sysinfo.h>],

Modified: trunk/makeopts.in
URL: http://svnview.digium.com/svn/asterisk/trunk/makeopts.in?view=diff&rev=310332&r1=310331&r2=310332
==============================================================================
--- trunk/makeopts.in (original)
+++ trunk/makeopts.in Fri Mar 11 09:09:23 2011
@@ -100,6 +100,7 @@
 AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@
 AST_SHADOW_WARNINGS=@AST_SHADOW_WARNINGS@
 AST_FORTIFY_SOURCE=@AST_FORTIFY_SOURCE@
+AST_MARCH_NATIVE=@AST_MARCH_NATIVE@
 
 ALSA_INCLUDE=@ALSA_INCLUDE@
 ALSA_LIB=@ALSA_LIB@




More information about the asterisk-commits mailing list