Bug 1239672 - Fixed symbols file support on mingw. r=glandium
authorJacek Caban <jacek@codeweavers.com>
Thu, 21 Jan 2016 13:39:41 +0100
changeset 316092 7698955aac90ef83a2b7756649873a12faa372b5
parent 316091 e9113fd6cdb8c7d5c83e109ce0a48e78ae530206
child 316093 be2e21c90fddd5561fa22ebe8165f5ad0508318c
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1239672
milestone46.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 1239672 - Fixed symbols file support on mingw. r=glandium
config/rules.mk
python/mozbuild/mozbuild/action/generate_symbols_file.py
python/mozbuild/mozbuild/frontend/data.py
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -458,24 +458,29 @@ EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
 endif
 ifdef LD_VERSION_SCRIPT
 EXTRA_DSO_LDOPTS += -Wl,--version-script,$(LD_VERSION_SCRIPT)
 EXTRA_DEPS += $(LD_VERSION_SCRIPT)
 endif
 endif
 
 ifdef SYMBOLS_FILE
+ifeq ($(OS_TARGET),WINNT)
+ifndef GNU_CC
+EXTRA_DSO_LDOPTS += -DEF:$(call normalizepath,$(SYMBOLS_FILE))
+else
+EXTRA_DSO_LDOPTS += $(call normalizepath,$(SYMBOLS_FILE))
+endif
+else
 ifdef GCC_USE_GNU_LD
 EXTRA_DSO_LDOPTS += -Wl,--version-script,$(SYMBOLS_FILE)
 else
 ifeq ($(OS_TARGET),Darwin)
 EXTRA_DSO_LDOPTS += -Wl,-exported_symbols_list,$(SYMBOLS_FILE)
 endif
-ifeq ($(OS_TARGET),WINNT)
-EXTRA_DSO_LDOPTS += -DEF:$(call normalizepath,$(SYMBOLS_FILE))
 endif
 endif
 EXTRA_DEPS += $(SYMBOLS_FILE)
 endif
 #
 # GNU doesn't have path length limitation
 #
 
--- a/python/mozbuild/mozbuild/action/generate_symbols_file.py
+++ b/python/mozbuild/mozbuild/action/generate_symbols_file.py
@@ -37,34 +37,17 @@ def generate_symbols_file(output, *args)
     else:
         pp.context['DATA'] = ''
     pp.out = StringIO()
     pp.do_filter('substitution')
     pp.do_include(input)
 
     symbols = [s.strip() for s in pp.out.getvalue().splitlines() if s.strip()]
 
-    if buildconfig.substs['GCC_USE_GNU_LD']:
-        # A linker version script is generated for GNU LD that looks like the
-        # following:
-        # {
-        # global:
-        #   symbol1;
-        #   symbol2;
-        #   ...
-        # local:
-        #   *;
-        # };
-        output.write('{\nglobal:\n  %s;\nlocal:\n  *;\n};'
-                     % ';\n  '.join(symbols))
-    elif buildconfig.substs['OS_TARGET'] == 'Darwin':
-        # A list of symbols is generated for Apple ld that simply lists all
-        # symbols, with an underscore prefix.
-        output.write(''.join('_%s\n' % s for s in symbols))
-    elif buildconfig.substs['OS_TARGET'] == 'WINNT':
+    if buildconfig.substs['OS_TARGET'] == 'WINNT':
         # A def file is generated for MSVC link.exe that looks like the
         # following:
         # LIBRARY library.dll
         # EXPORTS
         #   symbol1
         #   symbol2
         #   ...
         #
@@ -79,13 +62,30 @@ def generate_symbols_file(output, *args)
         #   data_symbol2 @DATA@
         #   ...
         # The DATA variable is "simply" expanded by the preprocessor, to
         # nothing on non-Windows, such that we only get the symbol name on
         # those platforms, and to DATA on Windows, so that the "DATA" part
         # is, in fact, part of the symbol name as far as the symbols variable
         # is concerned.
         libname, ext = os.path.splitext(os.path.basename(output.name))
-        assert ext == '.symbols'
+        assert ext == '.def'
         output.write('LIBRARY %s\nEXPORTS\n  %s\n'
                      % (libname, '\n  '.join(symbols)))
+    elif buildconfig.substs['GCC_USE_GNU_LD']:
+        # A linker version script is generated for GNU LD that looks like the
+        # following:
+        # {
+        # global:
+        #   symbol1;
+        #   symbol2;
+        #   ...
+        # local:
+        #   *;
+        # };
+        output.write('{\nglobal:\n  %s;\nlocal:\n  *;\n};'
+                     % ';\n  '.join(symbols))
+    elif buildconfig.substs['OS_TARGET'] == 'Darwin':
+        # A list of symbols is generated for Apple ld that simply lists all
+        # symbols, with an underscore prefix.
+        output.write(''.join('_%s\n' % s for s in symbols))
 
     return set(pp.includes)
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -492,20 +492,22 @@ class SharedLibrary(Library):
             self.soname = '%s%s%s' % (
                 context.config.dll_prefix,
                 soname,
                 context.config.dll_suffix,
             )
         else:
             self.soname = self.lib_name
 
-        if symbols_file:
+        if not symbols_file:
+            self.symbols_file = None
+        elif context.config.substs['OS_TARGET'] == 'WINNT':
+            self.symbols_file = '%s.def' % self.lib_name
+        else:
             self.symbols_file = '%s.symbols' % self.lib_name
-        else:
-            self.symbols_file = None
 
 
 class ExternalLibrary(object):
     """Empty mixin for libraries built by an external build system."""
 
 
 class ExternalStaticLibrary(StaticLibrary, ExternalLibrary):
     """Context derived container for static libraries built by an external