Skip to content

Commit

Permalink
compilers: Pass vs_module_defs with /DEF: to LLD-LINK
Browse files Browse the repository at this point in the history
Recently, it is possible to install Clang with Visual Studio Installer. By
default this Clang has a MSVC target, and invokes the Microsoft Linker; if
`-fuse-ld=lld` is specified, it will invoke LLD-LINK. Both linkers take
MSVC-style arguments, and take DEF files with `/DEF:<path>`.

Previously DEF files were passed in the GNU way, directly on the linker
command line like an object file, which caused errors like

   lld-link: error: ..\my.def: unknown file type

While Clang-CL takes Unix-style options, it actually passes MSVC-style
options to LINK or LLD-LINK with `-Wl,`. There is already a check for both
linkers in `linker_to_compiler_args()`, so it's necessary to do the same
in `gen_vs_module_defs_args()`.

This commit closes #13988.

Signed-off-by: LIU Hao <lh_mouse@126.com>
  • Loading branch information
lhmouse authored and dcbaker committed Dec 11, 2024
1 parent 8156e12 commit e542901
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mesonbuild/compilers/mixins/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def openmp_flags(self, env: Environment) -> T.List[str]:
return []

def gen_vs_module_defs_args(self, defsfile: str) -> T.List[str]:
if isinstance(self.linker, (MSVCDynamicLinker)):
if isinstance(self.linker, (ClangClDynamicLinker, MSVCDynamicLinker)):
# 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 ['-Wl,/DEF:' + defsfile]
Expand Down

0 comments on commit e542901

Please sign in to comment.