From 9bbceeee068190b2a7a622b368d7a4d54385fb22 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 10 Jan 2023 15:28:37 +0800 Subject: Visual Studio: Drop /utf-8 if it is not supported We assume /utf-8 for all C builds unless /source-charset or /execution-charset is specified, but then this will cause trouble for Visual Studio 2013 or earler since the /utf-8 flag is only supported since Visual Studio 2015. Specifically, if we try to check whether compiler flags are supported, those checks will fail since /utf-8 is never supported on these older Visual Studio versions. Drop /utf-8 from get_always_args() if we are using Visual Studio 2013 or earlier. --- mesonbuild/compilers/mixins/visualstudio.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mesonbuild/compilers') diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index 5a326dc..48d0bbb 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -105,6 +105,8 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): # 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. + # It is also dropped if Visual Studio 2013 or earlier is used, since it would + # not be supported in that case. always_args = ['/nologo', '/showIncludes', '/utf-8'] warn_args = { '0': [], @@ -429,6 +431,14 @@ class MSVCCompiler(VisualStudioLikeCompiler): args = ['/FS'] + args return args + # Override CCompiler.get_always_args + # We want to drop '/utf-8' for Visual Studio 2013 and earlier + def get_always_args(self) -> T.List[str]: + if mesonlib.version_compare(self.version, '<19.00'): + if '/utf-8' in self.always_args: + self.always_args.remove('/utf-8') + return self.always_args + def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[str]]: if self.version.split('.')[0] == '16' and instruction_set == 'avx': # VS documentation says that this exists and should work, but -- cgit v1.1