summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-11-20 09:58:49 +0100
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-11-23 17:02:12 +0200
commit6c9bad51d6a05001c22215ee0ac2c25acc022e0f (patch)
treedb06d27fa6679dddcc4e0d5b6f6767eff273e8bb
parent9104bb616766bd9a05f0b2f280359463d32e227d (diff)
downloadmeson-6c9bad51d6a05001c22215ee0ac2c25acc022e0f.tar.gz
linkers: add gen_vs_module_defs_args
.def files are a linker concept, and they should not be shoehorned into the Compiler. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--mesonbuild/linkers/linkers.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
index 1d61f4a4b..8f9738283 100644
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -258,6 +258,9 @@ class DynamicLinker(metaclass=abc.ABCMeta):
def get_coverage_args(self) -> T.List[str]:
raise EnvironmentException(f"Linker {self.id} doesn't implement coverage data generation.")
+ def gen_vs_module_defs_args(self, defsfile: str) -> T.List[str]:
+ return []
+
@abc.abstractmethod
def get_search_args(self, dirname: str) -> T.List[str]:
pass
@@ -696,6 +699,15 @@ class GnuLikeDynamicLinkerMixin(DynamicLinkerBase):
def get_coverage_args(self) -> T.List[str]:
return ['--coverage']
+ def gen_vs_module_defs_args(self, defsfile: str) -> T.List[str]:
+ # On Windows targets, .def files may be specified on the linker command
+ # line like an object file.
+ m = self.environment.machines[self.for_machine]
+ if m.is_windows() or m.is_cygwin():
+ return [defsfile]
+ # For other targets, discard the .def file.
+ return []
+
def export_dynamic_args(self) -> T.List[str]:
m = self.environment.machines[self.for_machine]
if m.is_windows() or m.is_cygwin():
@@ -1448,6 +1460,11 @@ class VisualStudioLikeLinkerMixin(DynamicLinkerBase):
def get_allow_undefined_args(self) -> T.List[str]:
return []
+ def gen_vs_module_defs_args(self, defsfile: str) -> T.List[str]:
+ # With MSVC, DLLs only export symbols that are explicitly exported,
+ # so if a module defs file is specified, we use that to export symbols
+ return ['/DEF:' + defsfile]
+
def get_soname_args(self, prefix: str, shlib_name: str, suffix: str,
soversion: str, darwin_versions: T.Tuple[str, str]
) -> T.List[str]: