Bug 1350362 Fix NSS Build System for MinGW
MozReview-Commit-ID: 4QROlna5Cvg
--- a/old-configure.in
+++ b/old-configure.in
@@ -933,17 +933,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=
@@ -5361,17 +5361,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']]