Bug 1411081 - Move --enable-optimize/MOZ_OPTIMIZE to moz.configure; r=glandium

The Rust optimization logic is tied to --enable-optimize/MOZ_OPTIMIZE
and --enable-debug/MOZ_DEBUG. In order to more easily implement more
customization, let's move --enable-optimize/MOZ_OPTIMIZE to
moz.configure so its value can be consulted there.

The logic here is a bit wonky. The option behaves like a boolean
or a string. If a string, MOZ_OPTIMIZE is set to 2. Otherwise it
is 1 or unset depending on the boolean value.

The custom compiler flags string is passed to old-configure, where it
overwrites whatever old-configure derived as the default value.
We stop short of moving all references to MOZ_OPTIMIZE_FLAGS to
moz.configure because there are a handful of them and I don't want
to scope bloat.

MozReview-Commit-ID: 6iNDu2HwLGr

--HG--
extra : rebase_source : a64f1236012d13913f21253df1b9b5ff0ae8ea6e
This commit is contained in:
Gregory Szorc 2017-10-24 19:54:48 -07:00
parent b7a368158f
commit ae7cf57366
4 changed files with 39 additions and 27 deletions

View File

@ -209,7 +209,6 @@ def old_configure_options(*options):
'--enable-nspr-build',
'--enable-official-branding',
'--enable-oom-breakpoint',
'--enable-optimize',
'--enable-parental-controls',
'--enable-pie',
'--enable-posix-nspr-emulation',

View File

@ -11,6 +11,35 @@ option(env='MOZ_PGO', help='Build with profile guided optimizations')
set_config('MOZ_PGO', depends('MOZ_PGO')(lambda x: bool(x)))
add_old_configure_assignment('MOZ_PGO', depends('MOZ_PGO')(lambda x: bool(x)))
# Code optimization
# ==============================================================
js_option('--enable-optimize',
nargs='?',
default=True,
help='Enable optimizations via compiler flags')
@depends('--enable-optimize')
def moz_optimize(option):
flags = None
if len(option):
val = '2'
flags = option[0]
elif option:
val = '1'
else:
val = None
return namespace(
optimize=val,
flags=flags,
)
set_config('MOZ_OPTIMIZE', moz_optimize.optimize)
add_old_configure_assignment('MOZ_OPTIMIZE', moz_optimize.optimize)
add_old_configure_assignment('MOZ_CONFIGURE_OPTIMIZE_FLAGS', moz_optimize.flags)
# yasm detection
# ==============================================================
yasm = check_prog('YASM', ['yasm'], allow_missing=True)

View File

@ -1438,18 +1438,11 @@ dnl ========================================================
dnl = Enable code optimization. ON by default.
dnl ========================================================
MOZ_ARG_ENABLE_STRING(optimize,
[ --disable-optimize Disable compiler optimization
--enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
[ if test "$enableval" != "no"; then
MOZ_OPTIMIZE=1
if test -n "$enableval" -a "$enableval" != "yes"; then
MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
MOZ_OPTIMIZE=2
fi
else
MOZ_OPTIMIZE=
fi ], MOZ_OPTIMIZE=1)
# Use value from moz.configure if one is defined. Else use our computed
# value.
if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
fi
MOZ_SET_FRAMEPTR_FLAGS
@ -1470,7 +1463,6 @@ if test -n "$MOZ_OPTIMIZE"; then
fi
fi # COMPILE_ENVIRONMENT
AC_SUBST(MOZ_OPTIMIZE)
AC_SUBST(MOZ_FRAMEPTR_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)

View File

@ -3714,18 +3714,11 @@ dnl ========================================================
dnl = Enable code optimization. ON by default.
dnl ========================================================
MOZ_ARG_ENABLE_STRING(optimize,
[ --disable-optimize Disable compiler optimization
--enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
[ if test "$enableval" != "no"; then
MOZ_OPTIMIZE=1
if test -n "$enableval" -a "$enableval" != "yes"; then
MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
MOZ_OPTIMIZE=2
fi
else
MOZ_OPTIMIZE=
fi ], MOZ_OPTIMIZE=1)
# Use value from moz.configure if one is defined. Else use our computed
# value.
if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
fi
MOZ_SET_FRAMEPTR_FLAGS
@ -3746,7 +3739,6 @@ if test -n "$MOZ_OPTIMIZE"; then
fi
fi # COMPILE_ENVIRONMENT
AC_SUBST(MOZ_OPTIMIZE)
AC_SUBST(MOZ_FRAMEPTR_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)