From 3f8d6af9c2110bc1b3c94dd7b638d5b7eb1208c0 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 6 Jan 2020 13:59:11 -0800 Subject: [PATCH] compilers: Use /Zi instead of /ZI with clang-cl Clang-cl doesn't support /ZI, so we need to use either /Zi or /Z7, which both do the same thing for clang-cl (though not for msvc) Fixes #6414 --- mesonbuild/compilers/mixins/visualstudio.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index 525a87e40..a9943798d 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -61,6 +61,15 @@ msvc_buildtype_args = { 'custom': [], } # type: T.Dict[str, T.List[str]] +# Clang-cl doesn't have /ZI, and /Zi and /Z7 do the same thing +# quoting the docs (https://clang.llvm.org/docs/MSVCCompatibility.html): +# +# Clang emits relatively complete CodeView debug information if /Z7 or /Zi is +# passed. Microsoft’s link.exe will transform the CodeView debug information +# into a PDB +clangcl_buildtype_args = msvc_buildtype_args.copy() +clangcl_buildtype_args['debug'] = ['/Zi', '/Ob0', '/Od', '/RTC1'] + msvc_optimization_args = { '0': [], 'g': ['/O0'], @@ -130,9 +139,6 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta): def get_always_args(self) -> T.List[str]: return self.always_args - def get_buildtype_args(self, buildtype: str) -> T.List[str]: - return msvc_buildtype_args[buildtype] - def get_pch_suffix(self) -> str: return 'pch' @@ -398,7 +404,7 @@ class MSVCCompiler(VisualStudioLikeCompiler): return super().get_instruction_set_args(instruction_set) def get_buildtype_args(self, buildtype: str) -> T.List[str]: - args = super().get_buildtype_args(buildtype) + args = msvc_buildtype_args[buildtype] if mesonlib.version_compare(self.version, '<18.0'): args = [arg for arg in args if arg != '/Gw'] return args @@ -426,3 +432,6 @@ class ClangClCompiler(VisualStudioLikeCompiler): def get_pch_base_name(self, header: str) -> str: return header + + def get_buildtype_args(self, buildtype: str) -> T.List[str]: + return clangcl_buildtype_args[buildtype]