Bug 1325632 - part 5 - ensure that we compile with -fno-sized-deallocation when possible; r=chmanchester
authorNathan Froyd <froydnj@mozilla.com>
Wed, 15 Nov 2017 14:53:16 -0400
changeset 392046 402cad93aa6ece010f3c834b9d20e431c4ee8f8b
parent 392045 aeaf5db9a9e276ddb59b512926d95b858c4e1ccf
child 392047 b6a8db01f25a57d6b70a769ab96c3a407b490945
push id32909
push usercbrindusan@mozilla.com
push dateWed, 15 Nov 2017 22:25:14 +0000
treeherdermozilla-central@f41930a869a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1325632
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1325632 - part 5 - ensure that we compile with -fno-sized-deallocation when possible; r=chmanchester We currently turn off the C++14 sized-deallocation facility on MSVC, and we'd like to ensure we do the same thing for clang and gcc. To do so, we add new functionality to moz.configure for checking and adding compilation flags, similar to the facility for checking and adding warning flags. The newly added facility is then used to add -fno-sized-deallocation to the compilation flags, when the option is supported. Once we do this, we can't define the sized deallocation functions in mozalloc.h; the compiler will complain that we are using -fno-sized-deallocation, yet defining these special functions that we'll never use. These functions were added for MinGW, where we needed to compile with C++14 ahead of other platforms to be compatible with MSVC headers. But they're no longer necessary, though they would be if we removed -fno-sized-deallocation; the compiler will complain if we do that and we'll add them back at that point.
build/moz.configure/compile-checks.configure
build/moz.configure/flags.configure
js/src/old-configure.in
memory/mozalloc/mozalloc.h
moz.configure
old-configure.in
--- a/build/moz.configure/compile-checks.configure
+++ b/build/moz.configure/compile-checks.configure
@@ -179,8 +179,50 @@ def check_and_add_gcc_warning(warning, c
 #   is added for both compilers.
 # - `when` (optional) is a @depends function or option name conditioning
 #   when the warning flag is wanted.
 
 
 @template
 def add_gcc_warning(warning, compiler=None, when=None):
     check_and_add_gcc_warning(warning, compiler, when, check=False)
+
+
+# Like the warning checks above, but for general compilation flags.
+@dependable
+def compilation_cflags():
+    return []
+
+
+@dependable
+def compilation_cxxflags():
+    return []
+
+
+# Tests whether GCC or clang support the given compilation flag; if the flag
+# is supported, add it to the list of compilation flags for the build.
+# - `flag` is the flag to test
+# - `compiler` (optional) is the compiler to test against (c_compiler or
+#   cxx_compiler, from toolchain.configure). When omitted, both compilers
+#   are tested.
+# - `when` (optional) is a @depends function or option name conditioning
+#   when the warning flag is wanted.
+# - `check`, when not set, skips checking whether the flag is supported and
+#   adds it to the list of flags unconditionally. This is only meant for
+#   add_gcc_flag().
+@template
+def check_and_add_gcc_flag(flag, compiler=None, when=None, check=True):
+    flags = ['-Werror', flag]
+
+    check_and_add_flags(flag, compilation_cflags, compilation_cxxflags,
+                        flags, compiler=compiler, when=when, check=check)
+
+
+# Add the given flag to the list of flags for the build.
+# - `flag` is the flag (e.g. -fno-sized-deallocation)
+# - `compiler` (optional) is the compiler to add the flag for (c_compiler or
+#   cxx_compiler, from toolchain.configure). When omitted, the flag is added
+#   for both compilers.
+# - `when` (optional) is a @depends function or option name conditioning
+#   when the flag is wanted.
+@template
+def add_gcc_flag(warning, compiler=None, when=None):
+    check_and_add_gcc_flag(warning, compiler, when, check=False)
new file mode 100644
--- /dev/null
+++ b/build/moz.configure/flags.configure
@@ -0,0 +1,13 @@
+# -*- 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/.
+
+# We support C++14, but we don't want to enable the sized deallocation
+# facilities in C++14 yet.
+check_and_add_gcc_flag('-fno-sized-deallocation', compiler=cxx_compiler)
+
+# Please keep these last in this file.
+add_old_configure_assignment('_COMPILATION_CFLAGS', compilation_cflags)
+add_old_configure_assignment('_COMPILATION_CXXFLAGS', compilation_cxxflags)
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -1996,20 +1996,22 @@ dnl ====================================
 dnl top-level configure may override this with --without-intl-api
 _INTL_API=yes
 
 MOZ_CONFIG_ICU()
 
 dnl Echo the CFLAGS to remove extra whitespace.
 CFLAGS=`echo \
 	$_WARNINGS_CFLAGS \
+	$_COMPILATION_CFLAGS \
 	$CFLAGS`
 
 CXXFLAGS=`echo \
 	$_WARNINGS_CXXFLAGS \
+	$_COMPILATION_CXXFLAGS \
 	$CXXFLAGS`
 
 COMPILE_CFLAGS=`echo \
     $_DEFINES_CFLAGS \
     $COMPILE_CFLAGS`
 
 COMPILE_CXXFLAGS=`echo \
     $_DEFINES_CXXFLAGS \
--- a/memory/mozalloc/mozalloc.h
+++ b/memory/mozalloc/mozalloc.h
@@ -225,44 +225,28 @@ void* operator new[](size_t size, const 
 }
 
 MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
 void operator delete(void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
 {
     return free_impl(ptr);
 }
 
-#if __cplusplus >= 201402L
-MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
-void operator delete(void* ptr, size_t size) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
-{
-    return free_impl(ptr);
-}
-#endif
-
 MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
 void operator delete(void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
 {
     return free_impl(ptr);
 }
 
 MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
 void operator delete[](void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
 {
     return free_impl(ptr);
 }
 
-#if __cplusplus >= 201402L
-MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
-void operator delete[](void* ptr, size_t size) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
-{
-    return free_impl(ptr);
-}
-#endif
-
 MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
 void operator delete[](void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
 {
     return free_impl(ptr);
 }
 
 
 /*
--- a/moz.configure
+++ b/moz.configure
@@ -134,16 +134,18 @@ add_old_configure_assignment('PKG_CONFIG
 include('build/moz.configure/toolchain.configure',
         when='--enable-compile-environment')
 include('build/moz.configure/memory.configure',
         when='--enable-compile-environment')
 include('build/moz.configure/headers.configure',
         when='--enable-compile-environment')
 include('build/moz.configure/warnings.configure',
         when='--enable-compile-environment')
+include('build/moz.configure/flags.configure',
+        when='--enable-compile-environment')
 
 
 @depends(target, host)
 def is_openbsd(target, host):
     return target.kernel == 'OpenBSD' or host.kernel == 'OpenBSD'
 
 option(env='SO_VERSION', nargs=1, default='1.0', when=is_openbsd,
        help='Shared library version for OpenBSD systems')
--- a/old-configure.in
+++ b/old-configure.in
@@ -4769,20 +4769,22 @@ if test "$MOZ_WIDGET_TOOLKIT" = "cocoa";
     USE_ICU=1
 fi
 
 MOZ_CONFIG_ICU()
 
 dnl Echo the CFLAGS to remove extra whitespace.
 CFLAGS=`echo \
     $_WARNINGS_CFLAGS \
+    $_COMPILATION_CFLAGS \
     $CFLAGS`
 
 CXXFLAGS=`echo \
     $_WARNINGS_CXXFLAGS \
+    $_COMPILATION_CXXFLAGS \
     $CXXFLAGS`
 
 COMPILE_CFLAGS=`echo \
     $_DEFINES_CFLAGS \
     $COMPILE_CFLAGS`
 
 COMPILE_CXXFLAGS=`echo \
     $_DEFINES_CXXFLAGS \