diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 11db1928d..d6387d58a 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1590,6 +1590,7 @@ int dummy; 'symbolextractor', ninja_quote(quote_func(self.environment.get_build_dir())), '$in', + '$IMPLIB', '$out'] symrule = 'SHSYM' symcmd = args + ['$CROSS'] @@ -2308,12 +2309,17 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) self.add_build(elem) return pch_objects + def get_target_shsym_filename(self, target): + # Always name the .symbols file after the primary build output because it always exists + targetdir = self.get_target_private_dir(target) + return os.path.join(targetdir, target.get_filename() + '.symbols') + def generate_shsym(self, target): - target_name = target.get_filename() target_file = self.get_target_filename(target) - targetdir = self.get_target_private_dir(target) - symname = os.path.join(targetdir, target_name + '.symbols') + symname = self.get_target_shsym_filename(target) elem = NinjaBuildElement(self.all_outputs, symname, 'SHSYM', target_file) + # The library we will actually link to, which is an import library on Windows (not the DLL) + elem.add_item('IMPLIB', self.get_target_filename_for_linking(target)) if self.environment.is_cross_build(): elem.add_item('CROSS', '--cross-host=' + self.environment.machines[target.for_machine].system) self.add_build(elem) @@ -2593,7 +2599,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) def get_dependency_filename(self, t): if isinstance(t, build.SharedLibrary): - return os.path.join(self.get_target_private_dir(t), t.get_filename() + '.symbols') + return self.get_target_shsym_filename(t) elif isinstance(t, mesonlib.File): if t.is_built: return t.relative_name() diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py index f94595f99..fd42dde45 100644 --- a/mesonbuild/scripts/symbolextractor.py +++ b/mesonbuild/scripts/symbolextractor.py @@ -129,7 +129,7 @@ def osx_syms(libfilename: str, outfilename: str): result += [' '.join(x.split()[0:2]) for x in output.split('\n')] write_if_changed('\n'.join(result) + '\n', outfilename) -def gen_symbols(libfilename: str, outfilename: str, cross_host: str): +def gen_symbols(libfilename: str, impfilename: str, outfilename: str, cross_host: str): if cross_host is not None: # In case of cross builds just always relink. In theory we could # determine the correct toolset, but we would need to use the correct @@ -151,14 +151,15 @@ def gen_symbols(libfilename: str, outfilename: str, cross_host: str): def run(args): global TOOL_WARNING_FILE options = parser.parse_args(args) - if len(options.args) != 3: - print('symbolextractor.py ') + if len(options.args) != 4: + print('symbolextractor.py ') sys.exit(1) privdir = os.path.join(options.args[0], 'meson-private') TOOL_WARNING_FILE = os.path.join(privdir, 'symbolextractor_tool_warning_printed') libfile = options.args[1] - outfile = options.args[2] - gen_symbols(libfile, outfile, options.cross_host) + impfile = options.args[2] # Only used on Windows + outfile = options.args[3] + gen_symbols(libfile, impfile, outfile, options.cross_host) return 0 if __name__ == '__main__':