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.
pull/7866/head
Dylan Baker 4 years ago
parent 2844afedde
commit 0217faf13f
  1. 14
      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

Loading…
Cancel
Save