Bug 1350362 Fix NSS Build System for MinGW r=ted
authorTom Ritter <tom@mozilla.com>
Fri, 12 May 2017 11:39:00 -0500
changeset 412552 169d5dfe505f3f519d1aa14309327ad768429a90
parent 412551 0d50eaa8bfa0bdfb5a7d039360ba54124551a7cf
child 412553 9fa721e390adef999705f2acc28dc8213e467e54
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1350362
milestone55.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 1350362 Fix NSS Build System for MinGW r=ted MozReview-Commit-ID: 4QROlna5Cvg
old-configure.in
security/generate_mapfile.py
security/moz.build
--- a/old-configure.in
+++ b/old-configure.in
@@ -937,17 +937,17 @@ case "$target" in
 
         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
         WIN32_GUI_EXE_LDFLAGS=-mwindows
 
         # GCC/binutils can't link to a function if we try to include dllexport function
         # in the same library as dllimport caller. To work around it, we build NSPR
         # and NSS with -mnop-fun-dllimport flag. The drawback of this solution is that
         # function thunks need to be generated for cross-DLL calls.
-        MOZ_FOLD_LIBS_FLAGS=-mnop-fun-dllimport
+        MOZ_FOLD_LIBS_FLAGS="-mnop-fun-dllimport"
     else
         TARGET_COMPILER_ABI=msvc
         if test "$AS_BIN"; then
             AS="$(basename "$AS_BIN")"
         fi
         AR='lib'
         AR_FLAGS='-NOLOGO -OUT:$@'
         AR_EXTRACT=
@@ -5345,17 +5345,17 @@ AC_SUBST(MOZ_CODE_COVERAGE)
 AC_SUBST(LIBJPEG_TURBO_USE_YASM)
 AC_SUBST_LIST(LIBJPEG_TURBO_ASFLAGS)
 AC_SUBST(MOZ_LIBAV_FFT)
 AC_SUBST_LIST(LIBAV_FFT_ASFLAGS)
 AC_SUBST(MOZ_DEVTOOLS)
 
 AC_SUBST(MOZ_PACKAGE_JSSHELL)
 AC_SUBST(MOZ_FOLD_LIBS)
-AC_SUBST(MOZ_FOLD_LIBS_FLAGS)
+AC_SUBST_LIST(MOZ_FOLD_LIBS_FLAGS)
 AC_SUBST(SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE)
 
 AC_SUBST(DMG_TOOL)
 
 dnl Host JavaScript runtime, if any, to use during cross compiles.
 AC_SUBST(JS_BINARY)
 
 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
--- a/security/generate_mapfile.py
+++ b/security/generate_mapfile.py
@@ -7,43 +7,49 @@
 # This script processes NSS .def files according to the rules defined in
 # a comment at the top of each one. The files are used to define the
 # exports from NSS shared libraries, with -DEFFILE on Windows, a linker
 # script on Linux, or with -exported_symbols_list on OS X.
 #
 # The NSS build system processes them using a series of sed replacements,
 # but the Mozilla build system is already running a Python script to generate
 # the file so it's simpler to just do the replacement in Python.
+#
+# One difference between the NSS build system and Mozilla's is that
+# Mozilla's supports building on Linux for Windows using MinGW. MinGW
+# expects all lines containing ;+ removed and all ;- tokens removed.
 
 import buildconfig
 
 
 def main(output, input):
     is_darwin = buildconfig.substs['OS_ARCH'] == 'Darwin'
+    is_mingw = "WINNT" == buildconfig.substs['OS_ARCH'] and buildconfig.substs['GCC_USE_GNU_LD']
 
     with open(input, 'rb') as f:
         for line in f:
             line = line.rstrip()
-            # Remove all lines containing ';-'
-            if ';-' in line:
+            # On everything except MinGW, remove all lines containing ';-'
+            if not is_mingw and ';-' in line:
                 continue
             # On OS X, remove all lines containing ';+'
             if is_darwin and ';+' in line:
                 continue
             # Remove the string ' DATA '.
             line = line.replace(' DATA ', '')
             # Remove the string ';+'
-            line = line.replace(';+', '')
+            if not is_mingw:
+                line = line.replace(';+', '')
             # Remove the string ';;'
             line = line.replace(';;', '')
             # If a ';' is present, remove everything after it,
             # and on OS X, remove it as well.
             i = line.find(';')
             if i != -1:
-                if is_darwin:
+                if is_darwin or is_mingw:
                     line = line[:i]
                 else:
                     line = line[:i+1]
             # On OS X, symbols get an underscore in front.
             if line and is_darwin:
                 output.write('_')
             output.write(line)
             output.write('\n')
--- a/security/moz.build
+++ b/security/moz.build
@@ -88,16 +88,18 @@ else:
     gyp_vars['nspr_include_dir'] = CONFIG['NSPR_INCLUDE_DIR']
     gyp_vars['nspr_lib_dir'] = CONFIG['NSPR_LIB_DIR']
     # The Python scripts that detect clang need it to be set as CC
     # in the environment, which isn't true here. I don't know that
     # setting that would be harmful, but we already have this information
     # anyway.
     if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
         gyp_vars['cc_is_clang'] = 1
+    if CONFIG['GCC_USE_GNU_LD']:
+        gyp_vars['cc_use_gnu_ld'] = 1
 
     GYP_DIRS += ['nss']
     GYP_DIRS['nss'].input = 'nss/nss.gyp'
     GYP_DIRS['nss'].variables = gyp_vars
 
     sandbox_vars = {
         # NSS explicitly exports its public symbols
         # with linker scripts.
@@ -108,16 +110,18 @@ else:
         # We could probably do so, but not without a lot of
         # careful consideration.
         'NO_PGO': True,
     }
     if CONFIG['OS_TARGET'] == 'WINNT':
         if CONFIG['CPU_ARCH'] == 'x86':
             # This should really be the default.
             sandbox_vars['ASFLAGS'] = ['-safeseh']
+        if CONFIG['MOZ_FOLD_LIBS_FLAGS']:
+            sandbox_vars['CFLAGS'] = CONFIG['MOZ_FOLD_LIBS_FLAGS']
     if CONFIG['OS_TARGET'] == 'Android':
         sandbox_vars['CFLAGS'] = [
             '-include', TOPSRCDIR + '/security/manager/android_stub.h',
             # Setting sandbox_vars['DEFINES'] is broken currently.
             '-DCHECK_FORK_GETPID',
         ]
         if CONFIG['ANDROID_VERSION']:
             sandbox_vars['CFLAGS'] += ['-DANDROID_VERSION=' + CONFIG['ANDROID_VERSION']]