Backed out 4 changesets (bug 1306329) for 3000+ hazards a=backout
authorWes Kocher <wkocher@mozilla.com>
Tue, 17 Jan 2017 17:55:24 -0800
changeset 374858 93ffc3c44ee31192f6080f37d82994ca348e4148
parent 374857 077be424eb16ae5523dfe718cbb1897011b8ae4a
child 374859 c3f99c3904f15e6eddef13d3427c820a3fee54e1
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1306329
milestone53.0a1
backs out1c2f51ce3faff9c2ecd9d6c09ac49de975946185
6bb17b9a62d8ebeeaed80e87c14449b1d7dc6bb6
377ca1419f1aca2b43fbdfe83023c25c2f671ca0
ad4e531c7070874770201b5af956f3f8045c973b
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
Backed out 4 changesets (bug 1306329) for 3000+ hazards a=backout Backed out changeset 1c2f51ce3faf (bug 1306329) Backed out changeset 6bb17b9a62d8 (bug 1306329) Backed out changeset 377ca1419f1a (bug 1306329) Backed out changeset ad4e531c7070 (bug 1306329) MozReview-Commit-ID: KJAxdyJeJ6J
build/gecko_templates.mozbuild
media/webrtc/signaling/fuzztest/sdp_file_parser.cpp
python/mozbuild/mozbuild/frontend/data.py
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/test/frontend/test_emitter.py
toolkit/xre/nsAppRunner.cpp
tools/fuzzing/libfuzzer/harness/LibFuzzerRegistry.cpp
xpcom/base/nscore.h
xpcom/build/xrecore.h
xpcom/glue/moz.build
xpcom/glue/staticruntime/moz.build
xpcom/reflect/xptcall/xptcall.h
--- a/build/gecko_templates.mozbuild
+++ b/build/gecko_templates.mozbuild
@@ -37,16 +37,17 @@ def GeckoBinary(linkage='dependent', msv
                     'mozalloc_staticruntime',
                 ]
     else:
         error('msvcrt must be "dynamic" or "static"')
 
     if linkage == 'dependent':
         USE_LIBS += [
             'nspr',
+            '%s_s' % xpcomglue,
             'xul',
         ]
     elif linkage == 'standalone':
         DEFINES['XPCOM_GLUE'] = True
 
         USE_LIBS += [
             xpcomglue,
         ]
--- a/media/webrtc/signaling/fuzztest/sdp_file_parser.cpp
+++ b/media/webrtc/signaling/fuzztest/sdp_file_parser.cpp
@@ -21,23 +21,25 @@ void CSFLog(CSFLogLevel priority, const 
   va_start(ap, format);
 
   printf("%s\n:", tag);
   vprintf(format, ap);
 
   va_end(ap);
 }
 
+extern "C" {
 void NS_DebugBreak(uint32_t aSeverity,
                    const char* aStr, const char* aExpr,
                    const char* aFile, int32_t aLine)
 {
   fprintf(stderr, "NS_DebugBreak: %u %s %s %s %u", aSeverity, aStr, aExpr,
           aFile, aLine);
 }
+} // end extern "C".
 
 namespace mozilla {
 
 enum class LogLevel {
 
 };
 
 namespace detail {
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -312,24 +312,26 @@ class LinkageWrongKindError(Exception):
 
 class LinkageMultipleRustLibrariesError(Exception):
     """Error thrown when trying to link multiple Rust libraries to an object"""
 
 
 class Linkable(ContextDerived):
     """Generic context derived container object for programs and libraries"""
     __slots__ = (
+        'name',
         'cxx_link',
         'lib_defines',
         'linked_libraries',
         'linked_system_libs',
     )
 
-    def __init__(self, context):
+    def __init__(self, context, name):
         ContextDerived.__init__(self, context)
+        self.name = name
         self.cxx_link = False
         self.linked_libraries = []
         self.linked_system_libs = []
         self.lib_defines = Defines(context, {})
 
     def link_library(self, obj):
         assert isinstance(obj, BaseLibrary)
         if isinstance(obj, SharedLibrary) and obj.variant == obj.COMPONENT:
@@ -378,17 +380,17 @@ class BaseProgram(Linkable):
     DICT_ATTRS = {
         'install_target',
         'KIND',
         'program',
         'relobjdir',
     }
 
     def __init__(self, context, program, is_unit_test=False):
-        Linkable.__init__(self, context)
+        Linkable.__init__(self, context, program)
 
         bin_suffix = context.config.substs.get(self.SUFFIX_VAR, '')
         if not program.endswith(bin_suffix):
             program += bin_suffix
         self.program = program
         self.is_unit_test = is_unit_test
 
     def __repr__(self):
@@ -468,17 +470,17 @@ class BaseLibrary(Linkable):
     __slots__ = (
         'basename',
         'lib_name',
         'import_name',
         'refs',
     )
 
     def __init__(self, context, basename):
-        Linkable.__init__(self, context)
+        Linkable.__init__(self, context, basename)
 
         self.basename = self.lib_name = basename
         if self.lib_name:
             self.lib_name = '%s%s%s' % (
                 context.config.lib_prefix,
                 self.lib_name,
                 context.config.lib_suffix
             )
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -98,16 +98,26 @@ from .context import (
     Path,
     SubContext,
     TemplateContext,
 )
 
 from mozbuild.base import ExecutionSummary
 
 
+ALLOWED_XPCOM_GLUE = {
+    ('xpcshell', 'js/xpconnect/shell'),
+    ('testcrasher', 'toolkit/crashreporter/test'),
+    ('TestMailCookie', 'mailnews/base/test'),
+    ('calbasecomps', 'calendar/base/backend/libical/build'),
+    ('purplexpcom', 'extensions/purple/purplexpcom/src'),
+    ('ipdlunittest', 'ipc/ipdl/test/cxx/app'),
+}
+
+
 class TreeMetadataEmitter(LoggingMixin):
     """Converts the executed mozbuild files into data structures.
 
     This is a bridge between reader.py and data.py. It takes what was read by
     reader.BuildReader and converts it into the classes defined in the data
     module.
     """
 
@@ -269,21 +279,25 @@ class TreeMetadataEmitter(LoggingMixin):
         'host': 'HOST_LIBRARY_NAME',
         'target': 'LIBRARY_NAME',
     }
 
     def _link_libraries(self, context, obj, variable):
         """Add linkage declarations to a given object."""
         assert isinstance(obj, Linkable)
 
+        use_xpcom = False
+
         for path in context.get(variable, []):
             force_static = path.startswith('static:') and obj.KIND == 'target'
             if force_static:
                 path = path[7:]
             name = mozpath.basename(path)
+            if name in ('xpcomglue', 'xpcomglue_s'):
+                use_xpcom = True
             dir = mozpath.dirname(path)
             candidates = [l for l in self._libs[name] if l.KIND == obj.KIND]
             if dir:
                 if dir.startswith('/'):
                     dir = mozpath.normpath(
                         mozpath.join(obj.topobjdir, dir[1:]))
                 else:
                     dir = mozpath.normpath(
@@ -360,16 +374,48 @@ class TreeMetadataEmitter(LoggingMixin):
                     SharedLibrary):
                 self._static_linking_shared.add(obj)
             obj.link_library(candidates[0])
 
         # Link system libraries from OS_LIBS/HOST_OS_LIBS.
         for lib in context.get(variable.replace('USE', 'OS'), []):
             obj.link_system_library(lib)
 
+        key = (obj.name, obj.relativedir)
+        substs = context.config.substs
+        extra_allowed = []
+        moz_build_app = substs.get('MOZ_BUILD_APP')
+        if moz_build_app is not None: # None during some test_emitter.py tests.
+            if moz_build_app.startswith('../'):
+                # For comm-central builds, where topsrcdir is not the root
+                # source dir.
+                moz_build_app = moz_build_app[3:]
+            extra_allowed = [
+                (substs.get('MOZ_APP_NAME'), '%s/app' % moz_build_app),
+                ('%s-bin' % substs.get('MOZ_APP_NAME'), '%s/app' % moz_build_app),
+            ]
+        if substs.get('MOZ_WIDGET_TOOLKIT') != 'android':
+            extra_allowed.append((substs.get('MOZ_CHILD_PROCESS_NAME'), 'ipc/app'))
+        else:
+            extra_allowed.append(('mozglue_android', 'mozglue/android'))
+
+        if key in ALLOWED_XPCOM_GLUE or key in extra_allowed:
+            if not use_xpcom:
+                raise SandboxValidationError(
+                    "%s is in the exception list for XPCOM glue dependency but "
+                    "doesn't depend on the XPCOM glue. Please adjust the list "
+                    "in %s." % (obj.name, __file__), context
+                )
+        elif use_xpcom:
+            raise SandboxValidationError(
+                "%s depends on the XPCOM glue. "
+                "No new dependency on the XPCOM glue is allowed."
+                % obj.name, context
+            )
+
     @memoize
     def _get_external_library(self, dir, name, force_static):
         # Create ExternalStaticLibrary or ExternalSharedLibrary object with a
         # context more or less truthful about where the external library is.
         context = Context(config=self.config)
         context.add_source(mozpath.join(self.config.topsrcdir, dir, 'dummy'))
         if force_static:
             return ExternalStaticLibrary(context, name)
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -2,16 +2,18 @@
 # 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/.
 
 from __future__ import unicode_literals
 
 import os
 import unittest
 
+from collections import defaultdict
+from buildconfig import topsrcdir
 from mozunit import main
 
 from mozbuild.frontend.context import (
     ObjDirPath,
     Path,
 )
 from mozbuild.frontend.data import (
     AndroidResDirs,
@@ -1228,11 +1230,34 @@ class TestEmitterBasic(unittest.TestCase
         """Test that a SYMBOLS_FILE in the objdir that's missing
         from GENERATED_FILES is an error.
         """
         reader = self.reader('test-symbols-file-objdir-missing-generated')
         with self.assertRaisesRegexp(SandboxValidationError,
              'Objdir file specified in SYMBOLS_FILE not in GENERATED_FILES:'):
             self.read_topsrcdir(reader)
 
+    def test_allowed_xpcom_glue(self):
+        """Test that the ALLOWED_XPCOM_GLUE list is still relevant."""
+        from mozbuild.frontend.emitter import ALLOWED_XPCOM_GLUE
+
+        allowed = defaultdict(list)
+        useless = []
+        for name, path in ALLOWED_XPCOM_GLUE:
+            allowed[path].append(name)
+
+        for path, names in allowed.iteritems():
+            if path.startswith(('mailnews/', 'calendar/', 'extensions/purple/purplexpcom')):
+                continue
+            try:
+                content = open(os.path.join(topsrcdir, path, 'moz.build')).read()
+            except:
+                content = ''
+            for name in names:
+                if "'%s'" % name in content or '"%s"' % name in content:
+                    continue
+                useless.append((name, path))
+
+        self.assertEqual(useless, [])
+
 
 if __name__ == '__main__':
     main()
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -267,17 +267,17 @@ extern "C" MFBT_API bool IsSignalHandlin
 
 #ifdef LIBFUZZER
 #include "LibFuzzerRunner.h"
 
 namespace mozilla {
 LibFuzzerRunner* libFuzzerRunner = 0;
 } // namespace mozilla
 
-void XRE_LibFuzzerSetMain(int argc, char** argv, LibFuzzerMain main) {
+extern "C" MOZ_EXPORT void XRE_LibFuzzerSetMain(int argc, char** argv, LibFuzzerMain main) {
   mozilla::libFuzzerRunner->setParams(argc, argv, main);
 }
 #endif
 
 namespace mozilla {
 int (*RunGTest)(int*, char**) = 0;
 } // namespace mozilla
 
--- a/tools/fuzzing/libfuzzer/harness/LibFuzzerRegistry.cpp
+++ b/tools/fuzzing/libfuzzer/harness/LibFuzzerRegistry.cpp
@@ -1,20 +1,22 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * * 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/. */
 
 #include "LibFuzzerRegistry.h"
 
-void XRE_LibFuzzerGetFuncs(const char* moduleName, LibFuzzerInitFunc* initFunc, LibFuzzerTestingFunc* testingFunc) {
-    std::string moduleNameStr(moduleName);
-    mozilla::LibFuzzerFunctions funcs = mozilla::LibFuzzerRegistry::getInstance().getModuleFunctions(moduleNameStr);
-    *initFunc = funcs.first;
-    *testingFunc = funcs.second;
+extern "C" {
+    void MOZ_EXPORT XRE_LibFuzzerGetFuncs(const char* moduleName, LibFuzzerInitFunc* initFunc, LibFuzzerTestingFunc* testingFunc) {
+        std::string moduleNameStr(moduleName);
+        mozilla::LibFuzzerFunctions funcs = mozilla::LibFuzzerRegistry::getInstance().getModuleFunctions(moduleNameStr);
+        *initFunc = funcs.first;
+        *testingFunc = funcs.second;
+    }
 }
 
 namespace mozilla {
 
 LibFuzzerRegistry& LibFuzzerRegistry::getInstance() {
     static LibFuzzerRegistry instance;
     return instance;
 }
--- a/xpcom/base/nscore.h
+++ b/xpcom/base/nscore.h
@@ -170,21 +170,33 @@
 #else
 # define MOZ_DEPRECATED
 #endif
 
 /**
  * Import/Export macros for XPCOM APIs
  */
 
-#define EXPORT_XPCOM_API(type) type
-#define IMPORT_XPCOM_API(type) type
-#define GLUE_XPCOM_API(type) type
+#ifdef __cplusplus
+#define NS_EXTERN_C extern "C"
+#else
+#define NS_EXTERN_C
+#endif
 
-#define XPCOM_API(type) type
+#define EXPORT_XPCOM_API(type) NS_EXTERN_C NS_EXPORT type NS_FROZENCALL
+#define IMPORT_XPCOM_API(type) NS_EXTERN_C NS_IMPORT type NS_FROZENCALL
+#define GLUE_XPCOM_API(type) NS_EXTERN_C NS_HIDDEN_(type) NS_FROZENCALL
+
+#ifdef IMPL_LIBXUL
+#define XPCOM_API(type) EXPORT_XPCOM_API(type)
+#elif defined(XPCOM_GLUE)
+#define XPCOM_API(type) GLUE_XPCOM_API(type)
+#else
+#define XPCOM_API(type) IMPORT_XPCOM_API(type)
+#endif
 
 #ifdef MOZILLA_INTERNAL_API
    /*
      The frozen string API has different definitions of nsAC?String
      classes than the internal API. On systems that explicitly declare
      dllexport symbols this is not a problem, but on ELF systems
      internal symbols can accidentally "shine through"; we rename the
      internal classes to avoid symbol conflicts.
--- a/xpcom/build/xrecore.h
+++ b/xpcom/build/xrecore.h
@@ -7,11 +7,19 @@
 #ifndef xrecore_h__
 #define xrecore_h__
 
 #include "nscore.h"
 
 /**
  * Import/export macros for libXUL APIs.
  */
-#define XRE_API(type, name, params) type name params;
+#ifdef XPCOM_GLUE
+#define XRE_API(type, name, params) \
+  typedef type (NS_FROZENCALL * name##Type) params; \
+  extern name##Type name NS_HIDDEN;
+#elif defined(IMPL_LIBXUL)
+#define XRE_API(type, name, params) EXPORT_XPCOM_API(type) name params;
+#else
+#define XRE_API(type, name, params) IMPORT_XPCOM_API(type) name params;
+#endif
 
 #endif // xrecore_h__
--- a/xpcom/glue/moz.build
+++ b/xpcom/glue/moz.build
@@ -4,16 +4,21 @@
 # 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/.
 
 with Files('nsString*'):
     BUG_COMPONENT = ('Core', 'String')
 
 DIRS += ['standalone']
 
+# On win we build two glue libs - glue linked to crt dlls here and in staticruntime we build
+# a statically linked glue lib.
+if CONFIG['OS_ARCH'] == 'WINNT':
+    DIRS += ['staticruntime']
+
 EXPORTS += [
     'MainThreadUtils.h',
     'nsArrayEnumerator.h',
     'nsArrayUtils.h',
     'nsBaseHashtable.h',
     'nsCategoryCache.h',
     'nsClassHashtable.h',
     'nsCOMArray.h',
@@ -71,10 +76,47 @@ EXPORTS.mozilla += [
     'GenericFactory.h',
     'IntentionalCrash.h',
     'Monitor.h',
     'Mutex.h',
     'Observer.h',
     'ReentrantMonitor.h',
 ]
 
+include('objs.mozbuild')
+
+UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs
+UNIFIED_SOURCES += xpcom_glue_src_cppsrcs
+
+UNIFIED_SOURCES += [
+    'GenericModule.cpp',
+    'nsStringAPI.cpp',
+]
+
+Library('xpcomglue_s')
+
+SDK_LIBRARY = True
+
+FORCE_STATIC_LIB = True
+
+if CONFIG['_MSC_VER']:
+    DEFINES['_USE_ANSI_CPP'] = True
+    # Don't include directives about which CRT to use
+    CFLAGS += ['-Zl']
+    CXXFLAGS += ['-Zl']
+
+LOCAL_INCLUDES += [
+    '../build',
+    '../threads',
+]
+
 if CONFIG['ENABLE_TESTS']:
     DIRS += ['tests/gtest']
+
+# Include fallible for third party code using the xpcom glue
+USE_LIBS += [
+    'fallible',
+]
+
+# Force to build a static library only
+NO_EXPAND_LIBS = True
+
+DIST_INSTALL = True
new file mode 100644
--- /dev/null
+++ b/xpcom/glue/staticruntime/moz.build
@@ -0,0 +1,48 @@
+# -*- Mode: python; 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/.
+
+include('../objs.mozbuild')
+
+UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs
+UNIFIED_SOURCES += xpcom_glue_src_cppsrcs
+
+UNIFIED_SOURCES += [
+    '../GenericModule.cpp',
+    '../nsStringAPI.cpp',
+]
+
+Library('xpcomglue_staticruntime_s')
+
+SDK_LIBRARY = True
+
+FORCE_STATIC_LIB = True
+
+if CONFIG['_MSC_VER']:
+    DEFINES['_USE_ANSI_CPP'] = True
+    # Don't include directives about which CRT to use
+    CFLAGS += ['-Zl']
+    CXXFLAGS += ['-Zl']
+
+LOCAL_INCLUDES += [
+    '../../build',
+    '../../threads',
+]
+
+# Statically link to the CRT on Windows
+USE_STATIC_LIBS = True
+
+# Don't use STL wrappers here (i.e. wrapped <new>); they require mozalloc
+DISABLE_STL_WRAPPING = True
+
+# Include fallible for third party code using the xpcom glue
+USE_LIBS += [
+    'fallible',
+]
+
+# Force to build a static library only
+NO_EXPAND_LIBS = True
+
+DIST_INSTALL = True
--- a/xpcom/reflect/xptcall/xptcall.h
+++ b/xpcom/reflect/xptcall/xptcall.h
@@ -181,14 +181,13 @@ XPCOM_API(void)
 NS_DestroyXPTCallStub(nsISomeInterface* aStub);
 
 /**
  * Measures the size of an XPTCall stub previously created with NS_GetXPTCallStub.
  */
 XPCOM_API(size_t)
 NS_SizeOfIncludingThisXPTCallStub(const nsISomeInterface* aStub, mozilla::MallocSizeOf aMallocSizeOf);
 
-// this is extern "C" because on some platforms it is implemented in assembly
-extern "C" nsresult
+XPCOM_API(nsresult)
 NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
                  uint32_t paramCount, nsXPTCVariant* params);
 
 #endif /* xptcall_h___ */