Skip to content

Commit

Permalink
Bug 680277 - Debug builds should always be compiled with frame pointe…
Browse files Browse the repository at this point in the history
…rs. r=khuey.

This patch creates a new MOZ_FRAMEPTR_FLAGS variable that is used only to
control the frame pointer flags passed to the compiler. It also computes this
flag in a macro so that the toplevel configure and js/src/configure stay in
sync.
  • Loading branch information
cixtor committed Sep 3, 2011
1 parent b0f6183 commit 562cee8
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 60 deletions.
1 change: 1 addition & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ builtin(include, build/autoconf/mozheader.m4)dnl
builtin(include, build/autoconf/acwinpaths.m4)dnl
builtin(include, build/autoconf/lto.m4)dnl
builtin(include, build/autoconf/gcc-pr49911.m4)dnl
builtin(include, build/autoconf/frameptr.m4)dnl

MOZ_PROG_CHECKMSYS()

Expand Down
25 changes: 25 additions & 0 deletions build/autoconf/frameptr.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
dnl Set MOZ_FRAMEPTR_FLAGS to the flags that should be used for enabling or
dnl disabling frame pointers in this architecture based on the configure
dnl options

AC_DEFUN([MOZ_SET_FRAMEPTR_FLAGS], [
if test "$GNU_CC"; then
MOZ_ENABLE_FRAME_PTR="-fno-omit-frame-pointer"
MOZ_DISABLE_FRAME_PTR="-fomit-frame-pointer"
else
case "$target" in
*-mingw*)
MOZ_ENABLE_FRAME_PTR="-Oy-"
MOZ_DISABLE_FRAME_PTR="-Oy"
;;
esac
fi
# if we are debugging or profiling, we want a frame pointer.
if test -z "$MOZ_OPTIMIZE" -o \
-n "$MOZ_PROFILING" -o -n "$MOZ_DEBUG"; then
MOZ_FRAMEPTR_FLAGS="$MOZ_ENABLE_FRAME_PTR"
else
MOZ_FRAMEPTR_FLAGS="$MOZ_DISABLE_FRAME_PTR"
fi
])
1 change: 1 addition & 0 deletions config/autoconf.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ ACDEFINES = @MOZ_DEFINES@
WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@

MOZ_OPTIMIZE = @MOZ_OPTIMIZE@
MOZ_FRAMEPTR_FLAGS = @MOZ_FRAMEPTR_FLAGS@
MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@
MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
Expand Down
3 changes: 3 additions & 0 deletions config/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ endif # MOZ_OPTIMIZE == 1
endif # MOZ_OPTIMIZE
endif # CROSS_COMPILE

CFLAGS += $(MOZ_FRAMEPTR_FLAGS)
CXXFLAGS += $(MOZ_FRAMEPTR_FLAGS)

# Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles
# to request that we use the 'warnings as errors' compile flags)

Expand Down
34 changes: 8 additions & 26 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -2071,12 +2071,7 @@ case "$target" in
*-darwin*)
MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer"
else
MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer"
fi
MOZ_OPTIMIZE_FLAGS="-O3"
_PEDANTIC=
CFLAGS="$CFLAGS -fno-common"
CXXFLAGS="$CXXFLAGS -fno-common"
Expand Down Expand Up @@ -2188,12 +2183,7 @@ ia64*-hpux*)
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'

MOZ_GFX_OPTIMIZE_MOBILE=1
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fomit-frame-pointer"
else
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fno-omit-frame-pointer"
fi
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
;;

*-*linux*)
Expand All @@ -2211,14 +2201,8 @@ ia64*-hpux*)
# -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
esac
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else
MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi
MOZ_PGO_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS"
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK $MOZ_FRAMEPTR_FLAGS"
MOZ_PGO_OPTIMIZE_FLAGS="-O3"
MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
MOZ_DEBUG_FLAGS="-g"
fi

Expand Down Expand Up @@ -2315,12 +2299,7 @@ ia64*-hpux*)
MOZ_DEBUG_FLAGS='-Zi'
MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
WARNINGS_AS_ERRORS='-WX'
# If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_OPTIMIZE_FLAGS='-O1'
else
MOZ_OPTIMIZE_FLAGS='-O1 -Oy-'
fi
MOZ_OPTIMIZE_FLAGS='-O1'
MOZ_FIX_LINK_PATHS=
DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
Expand Down Expand Up @@ -6897,6 +6876,8 @@ else
MOZ_OPTIMIZE=
fi ], MOZ_OPTIMIZE=1)

MOZ_SET_FRAMEPTR_FLAGS

if test "$COMPILE_ENVIRONMENT"; then
if test -n "$MOZ_OPTIMIZE"; then
AC_MSG_CHECKING([for valid optimization flags])
Expand All @@ -6915,6 +6896,7 @@ fi
fi # COMPILE_ENVIRONMENT

AC_SUBST(MOZ_OPTIMIZE)
AC_SUBST(MOZ_FRAMEPTR_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
Expand Down
1 change: 1 addition & 0 deletions js/src/aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ builtin(include, build/autoconf/mozprog.m4)dnl
builtin(include, build/autoconf/acwinpaths.m4)dnl
builtin(include, build/autoconf/lto.m4)dnl
builtin(include, build/autoconf/gcc-pr49911.m4)dnl
builtin(include, build/autoconf/frameptr.m4)dnl

MOZ_PROG_CHECKMSYS()
25 changes: 25 additions & 0 deletions js/src/build/autoconf/frameptr.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
dnl Set MOZ_FRAMEPTR_FLAGS to the flags that should be used for enabling or
dnl disabling frame pointers in this architecture based on the configure
dnl options

AC_DEFUN([MOZ_SET_FRAMEPTR_FLAGS], [
if test "$GNU_CC"; then
MOZ_ENABLE_FRAME_PTR="-fno-omit-frame-pointer"
MOZ_DISABLE_FRAME_PTR="-fomit-frame-pointer"
else
case "$target" in
*-mingw*)
MOZ_ENABLE_FRAME_PTR="-Oy-"
MOZ_DISABLE_FRAME_PTR="-Oy"
;;
esac
fi
# if we are debugging or profiling, we want a frame pointer.
if test -z "$MOZ_OPTIMIZE" -o \
-n "$MOZ_PROFILING" -o -n "$MOZ_DEBUG"; then
MOZ_FRAMEPTR_FLAGS="$MOZ_ENABLE_FRAME_PTR"
else
MOZ_FRAMEPTR_FLAGS="$MOZ_DISABLE_FRAME_PTR"
fi
])
1 change: 1 addition & 0 deletions js/src/config/autoconf.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@
FAIL_ON_WARNINGS = @FAIL_ON_WARNINGS@

MOZ_OPTIMIZE = @MOZ_OPTIMIZE@
MOZ_FRAMEPTR_FLAGS = @MOZ_FRAMEPTR_FLAGS@
MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@
MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
Expand Down
3 changes: 3 additions & 0 deletions js/src/config/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ endif # MOZ_OPTIMIZE == 1
endif # MOZ_OPTIMIZE
endif # CROSS_COMPILE

CFLAGS += $(MOZ_FRAMEPTR_FLAGS)
CXXFLAGS += $(MOZ_FRAMEPTR_FLAGS)

# Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles
# to request that we use the 'warnings as errors' compile flags)

Expand Down
37 changes: 8 additions & 29 deletions js/src/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1972,13 +1972,7 @@ case "$target" in
*-darwin*)
MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else
MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi
MOZ_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS -fno-stack-protector"
MOZ_OPTIMIZE_FLAGS="-O3 -fno-stack-protector"
_PEDANTIC=
CFLAGS="$CFLAGS -fpascal-strings -fno-common"
CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common"
Expand Down Expand Up @@ -2083,13 +2077,7 @@ ia64*-hpux*)
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'

MOZ_GFX_OPTIMIZE_MOBILE=1
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else
MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi
MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks -fno-reorder-functions $MOZ_FRAMEPTR_FLAGS"
MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks -fno-reorder-functions"
# The Maemo builders don't know about this flag
MOZ_ARM_VFP_FLAGS="-mfpu=vfp"
;;
Expand All @@ -2109,14 +2097,8 @@ ia64*-hpux*)
# -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
esac
# If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else
MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi
MOZ_PGO_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS"
MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK $MOZ_FRAMEPTR_FLAGS"
MOZ_PGO_OPTIMIZE_FLAGS="-O3"
MOZ_OPTIMIZE_FLAGS="-O3 -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
MOZ_DEBUG_FLAGS="-g"
fi

Expand Down Expand Up @@ -2236,13 +2218,7 @@ ia64*-hpux*)
MOZ_DEBUG_FLAGS='-Zi'
MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
WARNINGS_AS_ERRORS='-WX'
# If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer.
if test -z "$MOZ_PROFILING"; then
MOZ_FRAMEPTR_FLAGS=
else
MOZ_FRAMEPTR_FLAGS='-Oy-'
fi
MOZ_OPTIMIZE_FLAGS="-O2 $MOZ_FRAMEPTR_FLAGS"
MOZ_OPTIMIZE_FLAGS="-O2"
MOZ_JS_LIBS='$(libdir)/mozjs.lib'
MOZ_FIX_LINK_PATHS=
DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
Expand Down Expand Up @@ -4393,6 +4369,8 @@ else
MOZ_OPTIMIZE=
fi ], MOZ_OPTIMIZE=1)

MOZ_SET_FRAMEPTR_FLAGS

if test "$COMPILE_ENVIRONMENT"; then
if test -n "$MOZ_OPTIMIZE"; then
AC_MSG_CHECKING([for valid optimization flags])
Expand All @@ -4411,6 +4389,7 @@ fi
fi # COMPILE_ENVIRONMENT

AC_SUBST(MOZ_OPTIMIZE)
AC_SUBST(MOZ_FRAMEPTR_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ifdef MOZ_THUMB2 #{
# work around it by telling gcc that the THUMB frame pointer is a
# vanilla callee-save register.
OS_CXXFLAGS += -fomit-frame-pointer
MOZ_OPTIMIZE_FLAGS := $(filter-out -fno-omit-frame-pointer,$(MOZ_OPTIMIZE_FLAGS))
MOZ_FRAMEPTR_FLAGS := -fomit-frame-pointer
endif #}

MODULE = handler
Expand Down
12 changes: 8 additions & 4 deletions xpcom/reflect/xptcall/src/md/unix/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ ifeq (Darwin,$(OS_ARCH))
ifeq (86,$(findstring 86,$(OS_TEST)))
ifneq (x86_64,$(OS_TEST))
# If we compile xptcinvoke_unixish_x86.cpp with -fomit-frame-pointer
# we end up crashing on startup, presumably because of the %esp munging we do
# when KEEP_STACK_16_BYTE_ALIGNED. So let's not use that flag here.
# NOTE: MODULE_OPTIMIZE_FLAGS must be set before including config.mk
MODULE_OPTIMIZE_FLAGS=-O3
# we end up crashing on startup. This is because
# "movl %5, %%eax\n\t" /* function index */
# becomes
# mov 0x1c(%esp),%eax
# but we have modified esp.
# NOTE: MOZ_FRAMEPTR_FLAGS must be set before including config.mk
# FIXME: change the file instead of using this hack.
MOZ_FRAMEPTR_FLAGS=-fno-omit-frame-pointer
endif
endif
endif
Expand Down

0 comments on commit 562cee8

Please sign in to comment.