зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1557583 - Add a --enable-frame-pointers option. r=chmanchester
We've been relying on frame pointers being indirectly enabled via things like --enable-profiling for some time, but this doesn't scale because some things may want frame pointers while wanting --disable-profiling. So we move MOZ_FRAMEPTR_FLAGS to python configure and add a new option to decide whether to enable frame pointers or not. Differential Revision: https://phabricator.services.mozilla.com/D34117 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
958968bcdc
Коммит
85e29d1e3b
|
@ -15,7 +15,6 @@ builtin(include, build/autoconf/codeset.m4)dnl
|
|||
builtin(include, build/autoconf/altoptions.m4)dnl
|
||||
builtin(include, build/autoconf/mozprog.m4)dnl
|
||||
builtin(include, build/autoconf/mozheader.m4)dnl
|
||||
builtin(include, build/autoconf/frameptr.m4)dnl
|
||||
builtin(include, build/autoconf/compiler-opts.m4)dnl
|
||||
builtin(include, build/autoconf/expandlibs.m4)dnl
|
||||
builtin(include, build/autoconf/arch.m4)dnl
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
dnl This Source Code Form is subject to the terms of the Mozilla Public
|
||||
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
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 -funwind-tables"
|
||||
MOZ_DISABLE_FRAME_PTR="-fomit-frame-pointer -funwind-tables"
|
||||
else
|
||||
case "$target" in
|
||||
dnl some versions of clang-cl don't support -Oy-; accommodate them.
|
||||
aarch64-windows*)
|
||||
if test "$CC_TYPE" = "clang-cl"; then
|
||||
MOZ_ENABLE_FRAME_PTR="-Xclang -mdisable-fp-elim"
|
||||
MOZ_DISABLE_FRAME_PTR="-Xclang -mdisable-fp-elim"
|
||||
else
|
||||
MOZ_ENABLE_FRAME_PTR="-Oy-"
|
||||
MOZ_DISABLE_FRAME_PTR="-Oy"
|
||||
fi
|
||||
;;
|
||||
dnl Oy (Frame-Pointer Omission) is only support on x86 compilers
|
||||
*-mingw32*)
|
||||
MOZ_ENABLE_FRAME_PTR="-Oy-"
|
||||
MOZ_DISABLE_FRAME_PTR="-Oy"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# If we are debugging, profiling, using sanitizers, or on win32 we want a
|
||||
# frame pointer. It is not required to enable frame pointers on AArch64
|
||||
# Windows, but we enable it for compatibility with ETW.
|
||||
if test -z "$MOZ_OPTIMIZE" -o \
|
||||
-n "$MOZ_PROFILING" -o \
|
||||
-n "$MOZ_DEBUG" -o \
|
||||
-n "$MOZ_MSAN" -o \
|
||||
-n "$MOZ_ASAN" -o \
|
||||
-n "$MOZ_UBSAN" -o \
|
||||
"$OS_ARCH:$CPU_ARCH" = "WINNT:x86" -o \
|
||||
"$OS_ARCH:$CPU_ARCH" = "WINNT:aarch64"; then
|
||||
MOZ_FRAMEPTR_FLAGS="$MOZ_ENABLE_FRAME_PTR"
|
||||
else
|
||||
MOZ_FRAMEPTR_FLAGS="$MOZ_DISABLE_FRAME_PTR"
|
||||
fi
|
||||
])
|
|
@ -30,8 +30,8 @@ js_option('--disable-optimize',
|
|||
help='Disable optimizations via compiler flags')
|
||||
|
||||
|
||||
@depends('--enable-optimize')
|
||||
def moz_optimize(option):
|
||||
@depends('--enable-optimize', '--help')
|
||||
def moz_optimize(option, _):
|
||||
flags = None
|
||||
|
||||
if len(option):
|
||||
|
@ -2481,3 +2481,45 @@ ar = check_prog('AR', ar_config.names, paths=toolchain_search_path)
|
|||
add_old_configure_assignment('AR', ar)
|
||||
|
||||
set_config('AR_FLAGS', ar_config.flags)
|
||||
|
||||
# Frame pointers
|
||||
# ==============================================================
|
||||
@depends(c_compiler, target)
|
||||
def frame_pointer_flags(compiler, target):
|
||||
if compiler.type == 'clang-cl':
|
||||
if target.cpu == 'aarch64':
|
||||
# Some version of clang-cl don't support -Oy-; accomodate them.
|
||||
return namespace(
|
||||
enable=['-Xclang', '-mdisable-fp-elim'],
|
||||
disable=['-Xclang', '-mdisable-fp-elim'],
|
||||
)
|
||||
return namespace(
|
||||
enable=['-Oy-'],
|
||||
disable=['-Oy'],
|
||||
)
|
||||
return namespace(
|
||||
enable=['-fno-omit-frame-pointer', '-funwind-tables'],
|
||||
disable=['-fomit-frame-pointer', '-funwind-tables'],
|
||||
)
|
||||
|
||||
|
||||
@depends(moz_optimize.optimize, moz_debug, target,
|
||||
'--enable-memory-sanitizer', '--enable-address-sanitizer',
|
||||
'--enable-undefined-sanitizer')
|
||||
def frame_pointer_default(optimize, debug, target, msan, asan, ubsan):
|
||||
return bool(not optimize or debug or msan or asan or ubsan or \
|
||||
(target.os == 'WINNT' and target.cpu in ('x86', 'aarch64')))
|
||||
|
||||
|
||||
js_option('--enable-frame-pointers', default=frame_pointer_default,
|
||||
help='{Enable|Disable} frame pointers')
|
||||
|
||||
|
||||
@depends('--enable-frame-pointers', frame_pointer_flags)
|
||||
def frame_pointer_flags(enable, flags):
|
||||
if enable:
|
||||
return flags.enable
|
||||
return flags.disable
|
||||
|
||||
|
||||
set_config('MOZ_FRAMEPTR_FLAGS', frame_pointer_flags)
|
||||
|
|
|
@ -208,6 +208,10 @@ def profiling(value):
|
|||
|
||||
add_old_configure_assignment('MOZ_PROFILING', profiling)
|
||||
|
||||
with only_when('--enable-compile-environment'):
|
||||
imply_option('--enable-frame-pointers', True, when=profiling)
|
||||
|
||||
|
||||
@depends(profiling, target)
|
||||
def imply_vtune(value, target):
|
||||
ok_cpu = target.cpu in ['x86', 'x86_64']
|
||||
|
|
|
@ -14,7 +14,6 @@ builtin(include, ../../build/autoconf/codeset.m4)dnl
|
|||
builtin(include, ../../build/autoconf/altoptions.m4)dnl
|
||||
builtin(include, ../../build/autoconf/mozprog.m4)dnl
|
||||
builtin(include, ../../build/autoconf/mozheader.m4)dnl
|
||||
builtin(include, ../../build/autoconf/frameptr.m4)dnl
|
||||
builtin(include, ../../build/autoconf/compiler-opts.m4)dnl
|
||||
builtin(include, ../../build/autoconf/expandlibs.m4)dnl
|
||||
builtin(include, ../../build/autoconf/arch.m4)dnl
|
||||
|
|
|
@ -1231,8 +1231,6 @@ if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
|
|||
MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
|
||||
fi
|
||||
|
||||
MOZ_SET_FRAMEPTR_FLAGS
|
||||
|
||||
if test "$COMPILE_ENVIRONMENT"; then
|
||||
if test -n "$MOZ_OPTIMIZE"; then
|
||||
AC_MSG_CHECKING([for valid optimization flags])
|
||||
|
@ -1261,7 +1259,6 @@ if test -n "$MOZ_OPTIMIZE"; then
|
|||
fi
|
||||
fi # COMPILE_ENVIRONMENT
|
||||
|
||||
AC_SUBST_LIST(MOZ_FRAMEPTR_FLAGS)
|
||||
AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
|
||||
AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
|
||||
AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
|
||||
|
|
|
@ -2345,8 +2345,6 @@ if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
|
|||
MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
|
||||
fi
|
||||
|
||||
MOZ_SET_FRAMEPTR_FLAGS
|
||||
|
||||
if test "$COMPILE_ENVIRONMENT"; then
|
||||
if test -n "$MOZ_OPTIMIZE"; then
|
||||
AC_MSG_CHECKING([for valid C compiler optimization flags])
|
||||
|
@ -2375,7 +2373,6 @@ if test -n "$MOZ_OPTIMIZE"; then
|
|||
fi
|
||||
fi # COMPILE_ENVIRONMENT
|
||||
|
||||
AC_SUBST_LIST(MOZ_FRAMEPTR_FLAGS)
|
||||
AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
|
||||
AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
|
||||
AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
|
||||
|
|
|
@ -27,7 +27,7 @@ DEFINES['RUSTFLAGS'] = ' '.join(rustflags)
|
|||
|
||||
cxx_flags = []
|
||||
for var in ('OS_CPPFLAGS', 'OS_CXXFLAGS', 'DEBUG', 'OPTIMIZE', 'FRAMEPTR'):
|
||||
cxx_flags += COMPILE_FLAGS.get(var, [])
|
||||
cxx_flags += COMPILE_FLAGS[var] or []
|
||||
|
||||
DEFINES['CXXFLAGS'] = ' '.join(cxx_flags)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче