Bug 1257448 - Move --enable-jemalloc and MOZ_JEMALLOC4 to moz.configure. r?nalexander
At the same time, allow to enable jemalloc 4 with --enable-jemalloc=4.
MOZ_JEMALLOC4 will be deprecated later.
This also changes the semantics for freebsd, where the system jemalloc
is used, relying on MOZ_MEMORY being unset (default on freebsd) and
MOZ_JEMALLOC4 to be set. In this new setup, MOZ_JEMALLOC4 implies
--enable-jemalloc=4, which still works because of the corresponding
changes to old-configure.
new file mode 100644
--- /dev/null
+++ b/build/moz.configure/memory.configure
@@ -0,0 +1,57 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+option(env='MOZ_JEMALLOC4', help='Enable jemalloc 4')
+imply_option('--enable-jemalloc', depends_if('MOZ_JEMALLOC4')(lambda x: '4'))
+
+
+option('--enable-jemalloc', nargs='?', choices=('4',), env='MOZ_MEMORY',
+ help='Replace memory allocator with jemalloc')
+
+@depends('--enable-jemalloc', target, build_project, c_compiler)
+def jemalloc(value, target, build_project, c_compiler):
+ if value.origin != 'default':
+ return bool(value) or None
+
+ if build_project == 'js':
+ return True
+
+ if target.kernel == 'Darwin' and target.cpu == 'x86_64':
+ # Don't enable by default on 32-bits OSX. See bug 702250.
+ return True
+
+ if target.kernel == 'WINNT' and c_compiler.type in ('msvc', 'clang-cl'):
+ return True
+
+ if target.kernel == 'Linux':
+ return True
+
+@depends('--enable-jemalloc')
+def jemalloc4(jemalloc):
+ if len(jemalloc) and jemalloc[0] == '4':
+ return True
+
+
+set_config('MOZ_MEMORY', jemalloc)
+set_define('MOZ_MEMORY', jemalloc)
+add_old_configure_assignment('MOZ_MEMORY', jemalloc)
+
+set_config('MOZ_JEMALLOC4', jemalloc4)
+set_define('MOZ_JEMALLOC4', jemalloc4)
+add_old_configure_assignment('MOZ_JEMALLOC4', jemalloc4)
+
+
+# Because --enable-jemalloc doesn't use a default because of the dependency
+# on the target, we can't use a js_option for it to propagate to js/src
+# through the old-configure.
+@depends(jemalloc, jemalloc4)
+def jemalloc_for_old_configure(jemalloc, jemalloc4):
+ if jemalloc:
+ return '--enable-jemalloc=4' if jemalloc4 else '--enable-jemalloc'
+ return '--disable-jemalloc'
+
+add_old_configure_arg(jemalloc_for_old_configure)
new file mode 100644
--- /dev/null
+++ b/build/moz.configure/no-toolchain.configure
@@ -0,0 +1,20 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+@depends('--help')
+def no_toolchain_compiler(_):
+ return namespace(
+ wrapper=(),
+ compiler='',
+ flags=(),
+ type='',
+ version='',
+ )
+
+c_compiler = no_toolchain_compiler
+cxx_compiler = no_toolchain_compiler
+host_c_compiler = no_toolchain_compiler
+host_cxx_compiler = no_toolchain_compiler
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -194,17 +194,16 @@ def old_configure_options(*options):
'--enable-gold',
'--enable-gps-debug',
'--enable-hardware-aec-ns',
'--enable-icf',
'--enable-install-strip',
'--enable-ion',
'--enable-ios-target',
'--enable-ipdl-tests',
- '--enable-jemalloc',
'--enable-jitspew',
'--enable-libjpeg-turbo',
'--enable-libproxy',
'--enable-llvm-hacks',
'--enable-logrefcnt',
'--enable-macos-target',
'--enable-maintenance-service',
'--enable-media-navigator',
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -1970,41 +1970,28 @@ dnl ====================================
if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
WARNINGS_AS_ERRORS=''
fi
dnl ========================================================
dnl = Enable jemalloc
dnl ========================================================
-LOCAL_MOZ_MEMORY=1
-MOZ_ARG_DISABLE_BOOL(jemalloc,
-[ --disable-jemalloc Don't replace memory allocator with jemalloc],
- LOCAL_MOZ_MEMORY=)
-
-dnl Consult the command-line arguments in stand alone-builds only. In
-dnl non-stand-alone builds, we always use the value of MOZ_MEMORY inherited from
-dnl the top-level configure script.
-if test "$JS_STANDALONE"; then
- MOZ_MEMORY=$LOCAL_MOZ_MEMORY
-fi
-
case "${OS_TARGET}" in
Android|WINNT|Darwin)
MOZ_GLUE_IN_PROGRAM=
;;
*)
dnl On !Android !Windows !OSX, we only want to link executables against mozglue
MOZ_GLUE_IN_PROGRAM=1
AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
;;
esac
if test "$MOZ_MEMORY"; then
- AC_DEFINE(MOZ_MEMORY)
if test "x$MOZ_DEBUG" = "x1"; then
AC_DEFINE(MOZ_MEMORY_DEBUG)
fi
dnl The generic feature tests that determine how to compute ncpus are long and
dnl complicated. Therefore, simply define special cpp variables for the
dnl platforms we have special knowledge of.
case "${target}" in
*-darwin*)
@@ -2027,21 +2014,16 @@ if test "$MOZ_MEMORY"; then
AC_DEFINE(MOZ_MEMORY_WINDOWS)
export MOZ_NO_DEBUG_RTL=1
;;
*)
AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
;;
esac
fi
-AC_SUBST(MOZ_MEMORY)
-AC_SUBST(MOZ_JEMALLOC4)
-if test -n "$MOZ_JEMALLOC4"; then
- AC_DEFINE(MOZ_JEMALLOC4)
-fi
AC_SUBST(MOZ_CRT)
AC_SUBST(MOZ_GLUE_IN_PROGRAM)
AC_SUBST_LIST(MOZ_GLUE_WRAP_LDFLAGS)
dnl ========================================================
dnl = Use a smaller chunk size for GC chunks
dnl ========================================================
dnl Use large (1MB) chunks by default. For B2G this option is used to give
--- a/moz.configure
+++ b/moz.configure
@@ -52,19 +52,23 @@ def compile_environment(value):
set_config('COMPILE_ENVIRONMENT', compile_environment)
add_old_configure_assignment('COMPILE_ENVIRONMENT', compile_environment)
@depends('--disable-compile-environment', '--help')
def toolchain_include(value, help):
if value:
return 'build/moz.configure/toolchain.configure'
+ else:
+ return 'build/moz.configure/no-toolchain.configure'
include(toolchain_include)
+include('build/moz.configure/memory.configure')
+
@depends('--help')
@imports(_from='mozbuild.backend', _import='backends')
def build_backends_choices(help):
return tuple(backends)
option('--enable-build-backend', nargs='+', choices=build_backends_choices,
--- a/old-configure.in
+++ b/old-configure.in
@@ -1144,17 +1144,16 @@ dnl = Enable DMD
dnl ========================================================
if test "$MOZ_DMD"; then
if test "${CPU_ARCH}" = "arm"; then
CFLAGS="$CFLAGS -funwind-tables"
CXXFLAGS="$CXXFLAGS -funwind-tables"
fi
- MOZ_MEMORY=1 # DMD enables jemalloc
MOZ_REPLACE_MALLOC=1 # DMD enables replace-malloc
fi
dnl ========================================================
dnl System overrides of the defaults for host
dnl ========================================================
case "$host" in
*mingw*)
@@ -1234,20 +1233,16 @@ dnl ====================================
dnl System overrides of the defaults for target
dnl ========================================================
case "$target" in
*-darwin*)
MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
MOZ_OPTIMIZE_FLAGS="-O3"
- # Statically disable jemalloc on 10.5 and 32-bit 10.6. See bug 702250.
- if test "$HAVE_64BIT_BUILD"; then
- MOZ_MEMORY=1
- fi
DLL_SUFFIX=".dylib"
DSO_LDOPTS=''
STRIP_FLAGS="$STRIP_FLAGS -x -S"
# Ensure that if we're targeting iOS an SDK was provided.
AC_CACHE_CHECK(for iOS target,
ac_cv_ios_target,
[AC_TRY_COMPILE([#include <TargetConditionals.h>
#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
@@ -1331,18 +1326,16 @@ case "$target" in
if test "$GNU_CC" -o "$GNU_CXX"; then
MOZ_PGO_OPTIMIZE_FLAGS="-O3"
MOZ_OPTIMIZE_FLAGS="-Os"
if test -z "$CLANG_CC"; then
MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
fi
fi
- MOZ_MEMORY=1
-
case "${target_cpu}" in
alpha*)
CFLAGS="$CFLAGS -mieee"
CXXFLAGS="$CXXFLAGS -mieee"
;;
esac
if test -z "$MC"; then
@@ -1553,17 +1546,16 @@ case "$target" in
LDFLAGS="$LDFLAGS -MaxILKSize:0x7FF00000"
fi
dnl Minimum reqiurement of Gecko is VS2010 or later which supports
dnl both SSSE3 and SSE4.1.
HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
dnl allow AVX2 code from VS2012
HAVE_X86_AVX2=1
- MOZ_MEMORY=1
fi
AC_DEFINE(STDC_HEADERS)
AC_DEFINE(WIN32_LEAN_AND_MEAN)
dnl See http://support.microsoft.com/kb/143208 to use STL
AC_DEFINE(NOMINMAX)
BIN_SUFFIX='.exe'
MOZ_USER_DIR="Mozilla"
@@ -2798,17 +2790,16 @@ case "$target_os" in
;;
esac
case "${target}" in
*-android*|*-linuxandroid*)
NSS_DISABLE_DBM=1
MOZ_THEME_FASTSTRIPE=1
MOZ_TREE_FREETYPE=1
- MOZ_MEMORY=1
MOZ_RAW=1
;;
esac
# The app update channel is 'default' when not supplied. The value is used in
# the application's confvars.sh so it must be set before confvars.sh is called.
MOZ_ARG_ENABLE_STRING([update-channel],
@@ -5603,24 +5594,16 @@ MOZ_ARG_ENABLE_BOOL(dump-painting,
if test -n "$MOZ_DUMP_PAINTING"; then
AC_DEFINE(MOZ_DUMP_PAINTING)
AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
fi
if test -n "$MOZ_DEBUG"; then
AC_DEFINE(MOZ_DUMP_PAINTING)
fi
-dnl ========================================================
-dnl = Enable jemalloc
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(jemalloc,
-[ --enable-jemalloc Replace memory allocator with jemalloc],
- MOZ_MEMORY=1,
- MOZ_MEMORY=)
-
case "${OS_TARGET}" in
Android|WINNT|Darwin)
MOZ_GLUE_IN_PROGRAM=
;;
*)
dnl On !Android !Windows !OSX, we only want to link executables against mozglue
MOZ_GLUE_IN_PROGRAM=1
AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
@@ -5701,39 +5684,32 @@ elif test -n "$MOZ_REPLACE_MALLOC"; then
fi
AC_SUBST(MOZ_REPLACE_MALLOC)
AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
dnl ========================================================
dnl = Jemalloc build setup
dnl ========================================================
if test -z "$MOZ_MEMORY"; then
- if test -n "$MOZ_JEMALLOC4" -a -z "$MOZ_REPLACE_MALLOC"; then
- MOZ_SYSTEM_JEMALLOC=1
- AC_CHECK_FUNCS(mallctl nallocx,,
- [MOZ_SYSTEM_JEMALLOC=
- break])
- if test -n "$MOZ_SYSTEM_JEMALLOC"; then
- MOZ_MEMORY=1
- AC_DEFINE(MOZ_MEMORY)
- AC_DEFINE(MOZ_JEMALLOC4)
- AC_DEFINE(MOZ_SYSTEM_JEMALLOC)
- fi
- fi
case "${target}" in
*-mingw*)
if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
fi
;;
esac
else
- AC_DEFINE(MOZ_MEMORY)
- if test -n "$MOZ_JEMALLOC4"; then
- AC_DEFINE(MOZ_JEMALLOC4)
+ if test -n "$MOZ_JEMALLOC4" -a -z "$MOZ_REPLACE_MALLOC"; then
+ MOZ_SYSTEM_JEMALLOC=1
+ AC_CHECK_FUNCS(mallctl nallocx,,
+ [MOZ_SYSTEM_JEMALLOC=
+ break])
+ if test -n "$MOZ_SYSTEM_JEMALLOC"; then
+ AC_DEFINE(MOZ_SYSTEM_JEMALLOC)
+ fi
fi
if test "x$MOZ_DEBUG" = "x1"; then
AC_DEFINE(MOZ_MEMORY_DEBUG)
fi
dnl The generic feature tests that determine how to compute ncpus are long and
dnl complicated. Therefore, simply define special cpp variables for the
dnl platforms we have special knowledge of.
case "${target}" in
@@ -5767,18 +5743,16 @@ else
rm crtdll.obj
fi
;;
*)
AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
;;
esac
fi # MOZ_MEMORY
-AC_SUBST(MOZ_MEMORY)
-AC_SUBST(MOZ_JEMALLOC4)
AC_SUBST(MOZ_SYSTEM_JEMALLOC)
AC_SUBST(MOZ_CRT)
export MOZ_CRT
AC_SUBST(MOZ_GLUE_IN_PROGRAM)
AC_SUBST_LIST(WIN32_CRT_LIBS)
# Allow the application to provide a subconfigure script.
# This should be after 'export MOZ_NO_DEBUG_RTL=1' since
@@ -7638,19 +7612,16 @@ if test "$BUILD_CTYPES"; then
# Build js-ctypes on the platforms we can.
ac_configure_args="$ac_configure_args --enable-ctypes"
fi
if test -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then
ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
fi
ac_configure_args="$ac_configure_args --prefix=$dist"
-if test "$MOZ_MEMORY"; then
- ac_configure_args="$ac_configure_args --enable-jemalloc"
-fi
if test -n "$ZLIB_IN_MOZGLUE"; then
MOZ_ZLIB_LIBS=
fi
export MOZ_SYSTEM_ZLIB
export MOZ_ZLIB_CFLAGS
export MOZ_ZLIB_LIBS
export MOZ_APP_NAME
export MOZ_APP_REMOTINGNAME
@@ -7658,17 +7629,16 @@ export RUSTC
export MOZILLA_CENTRAL_PATH=$_topsrcdir
export STLPORT_CPPFLAGS
export STLPORT_LIBS
export JS_STANDALONE=
unset MOZ_BUILD_APP
export DIST
export MOZ_LINKER
export ZLIB_IN_MOZGLUE
-export MOZ_MEMORY
export AR
export RANLIB
export CPP
export CC
export CXX
export LD
export ARFLAGS
export CPPFLAGS
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -60,16 +60,17 @@ option('--enable-dmd', env='MOZ_DMD',
def dmd(value):
if value:
return True
set_config('MOZ_DMD', dmd)
set_define('MOZ_DMD', dmd)
add_old_configure_assignment('MOZ_DMD', dmd)
imply_option('--enable-profiling', dmd)
+imply_option('--enable-jemalloc', dmd)
# Javascript engine
# ==============================================================
include('../js/moz.configure')
# L10N
# ==============================================================