Repository: mesonbuild/meson

Issue:
vs_module_defs ignored when cross-compiling to Windows with clang
`gen_vs_module_defs_args` [checks if the compiler type is `GCC_CYGWIN` or `GCC_MINGW` to decide whether or not to pass the def file along](https://github.com/mesonbuild/meson/blob/807981889f0cbecf165d0dc8bfb1e980adac58d8/mesonbuild/compilers/compilers.py#L1485), which results in it dropping it on the floor when the compiler type is `CLANG_MINGW`. It seems like there are a few other places where there are similar checks, which probably also breaks c_winlibs.


Discussion:

Resolving patch:
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -1176,7 +1176,7 @@ def get_options(self):
                                                        ['none', 'c89', 'c99', 'c11',
                                                         'gnu89', 'gnu99', 'gnu11'],
                                                        'none')})
-        if self.compiler_type == CompilerType.GCC_MINGW:
+        if self.compiler_type.is_windows_compiler:
             opts.update({
                 'c_winlibs': coredata.UserArrayOption('c_winlibs', 'Standard Win libraries to link against',
                                                       gnu_winlibs), })
@@ -1190,7 +1190,7 @@ def get_option_compile_args(self, options):
         return args
 
     def get_option_link_args(self, options):
-        if self.compiler_type == CompilerType.GCC_MINGW:
+        if self.compiler_type.is_windows_compiler:
             return options['c_winlibs'].value[:]
         return []
 
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1439,6 +1439,16 @@ def openmp_flags(self):
     def gnu_symbol_visibility_args(self, vistype):
         return gnu_symbol_visibility_args[vistype]
 
+    def gen_vs_module_defs_args(self, defsfile):
+        if not isinstance(defsfile, str):
+            raise RuntimeError('Module definitions file should be str')
+        # On Windows targets, .def files may be specified on the linker command
+        # line like an object file.
+        if self.compiler_type.is_windows_compiler:
+            return [defsfile]
+        # For other targets, discard the .def file.
+        return []
+
 
 class GnuCompiler(GnuLikeCompiler):
     """
@@ -1477,18 +1487,8 @@ def get_optimization_args(self, optimization_level):
     def get_pch_suffix(self):
         return 'gch'
 
-    def gen_vs_module_defs_args(self, defsfile):
-        if not isinstance(defsfile, str):
-            raise RuntimeError('Module definitions file should be str')
-        # On Windows targets, .def files may be specified on the linker command
-        # line like an object file.
-        if self.compiler_type in (CompilerType.GCC_CYGWIN, CompilerType.GCC_MINGW):
-            return [defsfile]
-        # For other targets, discard the .def file.
-        return []
-
     def get_gui_app_args(self, value):
-        if self.compiler_type in (CompilerType.GCC_CYGWIN, CompilerType.GCC_MINGW) and value:
+        if self.compiler_type.is_windows_compiler and value:
             return ['-mwindows']
         return []
 
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -202,7 +202,7 @@ def get_options(self):
                      'cpp_debugstl': coredata.UserBooleanOption('cpp_debugstl',
                                                                 'STL debug mode',
                                                                 False)})
-        if self.compiler_type == CompilerType.GCC_MINGW:
+        if self.compiler_type.is_windows_compiler:
             opts.update({
                 'cpp_winlibs': coredata.UserArrayOption('cpp_winlibs', 'Standard Win libraries to link against',
                                                         gnu_winlibs), })
@@ -218,7 +218,7 @@ def get_option_compile_args(self, options):
         return args
 
     def get_option_link_args(self, options):
-        if self.compiler_type == CompilerType.GCC_MINGW:
+        if self.compiler_type.is_windows_compiler:
             return options['cpp_winlibs'].value[:]
         return []
 


Test patch: