Bug 1471685 - Work around MSVC linker adding padding during incremental builds. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 28 Jun 2018 15:53:25 +0900
changeset 424339 a57560dbc9acd4315bb929b65463fe6ba1ce53a0
parent 424338 cf28b5bf98ddfd2ceab2b29771d9f0b6d6b91e5b
child 424340 e3d9b7024efa256b0835b0acdd807d75121bdbdf
push id104778
push usershindli@mozilla.com
push dateThu, 28 Jun 2018 23:25:48 +0000
treeherdermozilla-inbound@226fffcc9736 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1471685
milestone63.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 1471685 - Work around MSVC linker adding padding during incremental builds. r=froydnj
python/mozbuild/mozbuild/action/check_binary.py
xpcom/components/nsComponentManager.cpp
--- a/python/mozbuild/mozbuild/action/check_binary.py
+++ b/python/mozbuild/mozbuild/action/check_binary.py
@@ -209,18 +209,27 @@ def check_nsmodules(target, binary):
         raise RuntimeError('Could not find NSModules')
 
     def print_symbols(symbols):
         for addr, size, sym in symbols:
             print('%x %d %s' % (addr, size, sym))
 
     symbols = sorted(symbols)
     next_addr = None
+    # MSVC linker, when doing incremental linking, adds padding when
+    # merging sections. Allow there to be more space between the NSModule
+    # symbols, as long as they are in the right order.
+    if buildconfig.substs.get('_MSC_VER') and \
+            buildconfig.substs.get('DEVELOPER_OPTIONS'):
+        sym_cmp = lambda guessed, actual: guessed <= actual
+    else:
+        sym_cmp = lambda guessed, actual: guessed == actual
+
     for addr, size, sym in symbols:
-        if next_addr is not None and next_addr != addr:
+        if next_addr is not None and not sym_cmp(next_addr, addr):
             print_symbols(symbols)
             raise RuntimeError('NSModules are not adjacent')
         next_addr = addr + size
 
     # The mac linker doesn't emit the start/stop symbols in the symbol table.
     # We'll just assume it did the job correctly.
     if get_type(binary) == MACHO:
         return
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -358,17 +358,20 @@ nsComponentManagerImpl::Init()
 
   InitializeStaticModules();
 
   nsCategoryManager::GetSingleton()->SuppressNotifications(true);
 
   RegisterModule(&kXPCOMModule, nullptr);
 
   for (auto module : AllStaticModules()) {
-    RegisterModule(module, nullptr);
+    if (module) { // On local Windows builds, the list may contain null
+                  // pointers from padding.
+      RegisterModule(module, nullptr);
+    }
   }
 
   for (uint32_t i = 0; i < sExtraStaticModules->Length(); ++i) {
     RegisterModule((*sExtraStaticModules)[i], nullptr);
   }
 
   bool loadChromeManifests = (XRE_GetProcessType() != GeckoProcessType_GPU);
   if (loadChromeManifests) {