|
11 | 11 |
|
12 | 12 | from ... import mesonlib |
13 | 13 | from ...linkers.linkers import AppleDynamicLinker, ClangClDynamicLinker, LLVMDynamicLinker, GnuGoldDynamicLinker, \ |
14 | | - MoldDynamicLinker |
| 14 | + MoldDynamicLinker, MSVCDynamicLinker |
15 | 15 | from ...mesonlib import OptionKey |
16 | 16 | from ..compilers import CompileCheckMode |
17 | 17 | from .gnu import GnuLikeCompiler |
@@ -111,6 +111,13 @@ def openmp_flags(self) -> T.List[str]: |
111 | 111 | # Shouldn't work, but it'll be checked explicitly in the OpenMP dependency. |
112 | 112 | return [] |
113 | 113 |
|
| 114 | + def gen_vs_module_defs_args(self, defsfile: str) -> T.List[str]: |
| 115 | + if isinstance(self.linker, (MSVCDynamicLinker)): |
| 116 | + # With MSVC, DLLs only export symbols that are explicitly exported, |
| 117 | + # so if a module defs file is specified, we use that to export symbols |
| 118 | + return ['-Wl,/DEF:' + defsfile] |
| 119 | + return super().gen_vs_module_defs_args(defsfile) |
| 120 | + |
114 | 121 | @classmethod |
115 | 122 | def use_linker_args(cls, linker: str, version: str) -> T.List[str]: |
116 | 123 | # Clang additionally can use a linker specified as a path, which GCC |
@@ -155,6 +162,12 @@ def get_lto_compile_args(self, *, threads: int = 0, mode: str = 'default') -> T. |
155 | 162 | args.extend(super().get_lto_compile_args(threads=threads)) |
156 | 163 | return args |
157 | 164 |
|
| 165 | + def linker_to_compiler_args(self, args: T.List[str]) -> T.List[str]: |
| 166 | + if isinstance(self.linker, (ClangClDynamicLinker, MSVCDynamicLinker)): |
| 167 | + return [flag if flag.startswith('-Wl,') else f'-Wl,{flag}' for flag in args] |
| 168 | + else: |
| 169 | + return args |
| 170 | + |
158 | 171 | def get_lto_link_args(self, *, threads: int = 0, mode: str = 'default', |
159 | 172 | thinlto_cache_dir: T.Optional[str] = None) -> T.List[str]: |
160 | 173 | args = self.get_lto_compile_args(threads=threads, mode=mode) |
|
0 commit comments