Bug 409803 - gcc (4.1 only) zealously avoids inlining at -Os. make -finline-limit=50 the default on linux -Os builds. r=ted, blocking1.9+
authordwitte@stanford.edu
Sat, 15 Mar 2008 19:48:01 -0700
changeset 13134 8076a7de7c463827baafb97dcc87c6ae748a3cf1
parent 13133 ee8eac3d37f607c56f74f0b1f8762bbcdbfffa62
child 13135 adb094e785e183a85e7d07bd6d1b1e4cb27bb397
push idunknown
push userunknown
push dateunknown
reviewersted, blocking1.9
bugs409803
milestone1.9b5pre
Bug 409803 - gcc (4.1 only) zealously avoids inlining at -Os. make -finline-limit=50 the default on linux -Os builds. r=ted, blocking1.9+
config/autoconf.mk.in
configure.in
xpcom/io/Makefile.in
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -276,16 +276,17 @@ OS_INCLUDES	= $(NSPR_CFLAGS) $(JPEG_CFLA
 OS_LIBS		= @LIBS@
 ACDEFINES	= @MOZ_DEFINES@
 
 WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@
 
 MOZ_OPTIMIZE	= @MOZ_OPTIMIZE@
 MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
 MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
+MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@
 
 MOZ_RTTI_FLAGS_ON = @_MOZ_RTTI_FLAGS_ON@
 
 MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE = @MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE@
 PROFILE_GEN_CFLAGS = @PROFILE_GEN_CFLAGS@
 PROFILE_GEN_LDFLAGS = @PROFILE_GEN_LDFLAGS@
 PROFILE_USE_CFLAGS = @PROFILE_USE_CFLAGS@
 PROFILE_USE_LDFLAGS = @PROFILE_USE_LDFLAGS@
--- a/configure.in
+++ b/configure.in
@@ -1739,18 +1739,27 @@ case "$target" in
        MOZ_FIX_LINK_PATHS=
     fi
     if test -z "$GNU_CXX"; then
       MIPSPRO_CXX=1
     fi
     ;;
 
 *-*linux*)
+    if test "$GNU_CC"; then
+        GCC_VERSION=`$CC -v 2>&1 | awk '/version/ { print $3 }'`
+        case $GCC_VERSION in
+        4.1.*)
+            # -Os is broken on gcc 4.1.x, we need to tweak it to get good results.
+            MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
+        esac
+    fi
+
     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
-    MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
+    MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions $MOZ_OPTIMIZE_SIZE_TWEAK"
     MOZ_DEBUG_FLAGS="-g -fno-inline"  # most people on linux use gcc/gdb,
                                       # and that combo is not yet good at
                                       # debugging inlined functions (even
                                       # when using DWARF2 as the debugging
                                       # format)    
 
     MOZ_MEMORY=1
 
@@ -5981,16 +5990,17 @@ if test -n "$MOZ_OPTIMIZE"; then
     fi
     CFLAGS=$_SAVE_CFLAGS
 fi
 fi # COMPILE_ENVIRONMENT
 
 AC_SUBST(MOZ_OPTIMIZE)
 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
+AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
 
 dnl ========================================================
 dnl = Enable/disable debug for specific modules only
 dnl =   module names beginning with ^ will be disabled 
 dnl ========================================================
 MOZ_ARG_ENABLE_STRING(debug-modules,
 [  --enable-debug-modules  Enable/disable debug info for specific modules],
 [ MOZ_DEBUG_MODULES=`echo $enableval| sed 's/,/ /g'` ] )
--- a/xpcom/io/Makefile.in
+++ b/xpcom/io/Makefile.in
@@ -48,17 +48,17 @@ LIBRARY_NAME	= xpcomio_s
 GRE_MODULE	= 1
 MOZILLA_INTERNAL_API = 1
 REQUIRES	= string \
 		  $(NULL)
 
 # work around bug 408258
 ifdef GNU_CC 
 ifneq ($(OS_ARCH), Darwin)
-MODULE_OPTIMIZE_FLAGS = -Os -fno-strict-aliasing
+MODULE_OPTIMIZE_FLAGS = -Os -fno-strict-aliasing $(MOZ_OPTIMIZE_SIZE_TWEAK)
 endif
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 REQUIRES		+= macmorefiles
 endif
 
 CPPSRCS		= \