From fd3660e10cf0c86b7bc1800c6f57e3c5e5326d90 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 21 Jan 2016 13:39:41 +0100 Subject: [PATCH] Bug 1239672 - Fixed symbols file support on mingw. r=glandium --- config/rules.mk | 9 ++++- .../mozbuild/action/generate_symbols_file.py | 38 +++++++++---------- python/mozbuild/mozbuild/frontend/data.py | 8 ++-- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index 7d16f60dd63..8b9ead89caf 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -463,14 +463,19 @@ 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) diff --git a/python/mozbuild/mozbuild/action/generate_symbols_file.py b/python/mozbuild/mozbuild/action/generate_symbols_file.py index ba1d562a9bc..ff6136bb14c 100644 --- a/python/mozbuild/mozbuild/action/generate_symbols_file.py +++ b/python/mozbuild/mozbuild/action/generate_symbols_file.py @@ -42,24 +42,7 @@ def generate_symbols_file(output, *args): 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 @@ -84,8 +67,25 @@ def generate_symbols_file(output, *args): # 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) diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index a5bd9594e45..4305ffa31b1 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -497,10 +497,12 @@ class SharedLibrary(Library): else: self.soname = self.lib_name - if symbols_file: - self.symbols_file = '%s.symbols' % self.lib_name - else: + 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 class ExternalLibrary(object):