aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2022-06-08 11:39:04 +0800
committerJussi Pakkanen <jpakkane@gmail.com>2022-06-21 21:08:06 +0300
commit6e7c3efa793c25259891d3b5471343f95fb061fa (patch)
tree7ce98e8308166d002d0c04b335484d749772a71d /mesonbuild/compilers
parent28a9c1fdad259bfb30cbc734755a714b880d7113 (diff)
downloadmeson-6e7c3efa793c25259891d3b5471343f95fb061fa.zip
meson-6e7c3efa793c25259891d3b5471343f95fb061fa.tar.gz
meson-6e7c3efa793c25259891d3b5471343f95fb061fa.tar.bz2
visualstudio.py: Apply /utf-8 only on clang or VS2015+
In PR 10263, we didn't account for that we may have initialize the Visual Studio-like compiler two times, once for a C compiler and once for the C++ compiler, so we end up with Meson breaking on Visual Studio 2013 or earlier, such as when building GLib. Fix this by setting up the always_args member of the VisualStudioLikeCompiler instance during __init__() as needed, so that we avoid falling into modifying shared objects.
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index 0ad4d85..2839f62 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -101,9 +101,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
# /showIncludes is needed for build dependency tracking in Ninja
# See: https://ninja-build.org/manual.html#_deps
- # Assume UTF-8 sources by default, but self.unix_args_to_native() removes it
- # if `/source-charset` is set too.
- always_args = ['/nologo', '/showIncludes', '/utf-8']
+ always_args = ['/nologo', '/showIncludes'] # type: T.List[str]
warn_args = {
'0': [],
'1': ['/W2'],
@@ -117,6 +115,10 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
self.base_options = {mesonlib.OptionKey(o) for o in ['b_pch', 'b_ndebug', 'b_vscrt']} # FIXME add lto, pgo and the like
self.target = target
self.is_64 = ('x64' in target) or ('x86_64' in target)
+ # Assume UTF-8 sources by default on Visual Studio 2015 or later, or clang,
+ # but self.unix_args_to_native() removes it if `/source-charset` is set too.
+ if isinstance(self, ClangClCompiler) or mesonlib.version_compare(self.version, '>=19.00'):
+ self.always_args = self.always_args + ['/utf-8']
# do some canonicalization of target machine
if 'x86_64' in target:
self.machine = 'x64'
@@ -130,10 +132,6 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
self.machine = target
if mesonlib.version_compare(self.version, '>=19.28.29910'): # VS 16.9.0 includes cl 19.28.29910
self.base_options.add(mesonlib.OptionKey('b_sanitize'))
- # Exclude /utf-8 in self.always_args in VS2013 and earlier
- if not isinstance(self, ClangClCompiler):
- if mesonlib.version_compare(self.version, '<19.00'):
- self.always_args.remove('/utf-8')
assert self.linker is not None
self.linker.machine = self.machine