From 24c4c079e7e4b94af9659299e730a6970eb8a648 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 19 Oct 2018 14:15:51 -0700 Subject: [PATCH] linkers: Add get_base_link_args method to static linkers MSVC needs an argument to static linkers for doing LTO, so we need a way for the static linker to tell us that. --- mesonbuild/backend/ninjabackend.py | 4 +++- mesonbuild/linkers.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index ce5565f5c..cc601d8b2 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2467,7 +2467,9 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) # Add linker args for linking this target derived from 'base' build # options passed on the command-line, in default_options, etc. # These have the lowest priority. - if not isinstance(target, build.StaticLibrary): + if isinstance(target, build.StaticLibrary): + commands += linker.get_base_link_args(self.get_base_options_for_target(target)) + else: commands += compilers.get_base_link_args(self.get_base_options_for_target(target), linker, isinstance(target, build.SharedModule)) diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py index 20b513a2e..9529cb739 100644 --- a/mesonbuild/linkers.py +++ b/mesonbuild/linkers.py @@ -33,6 +33,10 @@ class StaticLinker: """ return mesonlib.is_windows() + def get_base_link_args(self, options: 'OptionDictType') -> typing.List[str]: + """Like compilers.get_base_link_args, but for the static linker.""" + return [] + def get_exelist(self) -> typing.List[str]: return self.exelist.copy()