From 0217faf13f13b9899f480513f248611893d23871 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 19 Oct 2020 09:34:41 -0700 Subject: [PATCH] compilers/c: Log that MSVC doesn't support gnu stds Since the current approach of demoting to the nearest C standard *might* work, but might not. For projects like Glib that detect which standard is used and fall back this is fine. For projects like libdrm that only work with gnu standards, this wont. We're nog tusing a warning because this shouldn't be fatal if --meson-fatal-warnings is used. Also demote a similar message in IntelCl from warning to log. --- mesonbuild/compilers/c.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 886090651..78185b204 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -420,6 +420,11 @@ class VisualStudioCCompiler(MSVCCompiler, VisualStudioLikeCCompilerMixin, CCompi def get_option_compile_args(self, options: 'OptionDictType') -> T.List[str]: args = [] std = options['std'] + if std.value.startswith('gnu'): + mlog.log( + 'cl.exe does not actually support gnu standards, and meson ' + 'will instead demote to the nearest ISO C standard. This ' + 'may cause compilation to fail.', once=True) # As of MVSC 16.7, /std:c11 is the only valid C standard option. if std.value in {'c11', 'gnu11'}: args.append('/std:c11') @@ -449,6 +454,13 @@ class ClangClCCompiler(ClangClCompiler, VisualStudioLikeCCompilerMixin, CCompile 'gnu89', 'gnu90', 'gnu9x', 'gnu99'] opts['std'].choices = c_stds # type: ignore return opts + def get_option_compile_args(self, options: 'OptionDictType') -> T.List[str]: + if options['std'].value.startswith('gnu'): + mlog.warning( + 'Clang-cl does not actually support gnu standards, and ' + 'meson will instead demote to the nearest ISO C standard. This ' + 'may cause compilation to fail.', once=True) + return [] class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerMixin, CCompiler): @@ -474,7 +486,7 @@ class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerM args = [] std = options['std'] if std.value == 'c89': - mlog.warning("ICL doesn't explicitly implement c89, setting the standard to 'none', which is close.", once=True) + mlog.log("ICL doesn't explicitly implement c89, setting the standard to 'none', which is close.", once=True) elif std.value != 'none': args.append('/Qstd:' + std.value) return args