compilers: add c23 and gnu23 c_stds

Closes: https://github.com/mesonbuild/meson/issues/12702
pull/12723/head
Simon Ser 1 year ago committed by Jussi Pakkanen
parent 1c852f0a98
commit 0bfe98e7e6
  1. 2
      docs/markdown/Builtin-options.md
  2. 2
      docs/markdown/Configuring-a-build-directory.md
  3. 8
      mesonbuild/compilers/c.py

@ -257,7 +257,7 @@ or compiler being used:
| ------ | ------------- | --------------- | ----------- | | ------ | ------------- | --------------- | ----------- |
| c_args | | free-form comma-separated list | C compile arguments to use | | c_args | | free-form comma-separated list | C compile arguments to use |
| c_link_args | | free-form comma-separated list | C link arguments to use | | c_link_args | | free-form comma-separated list | C link arguments to use |
| c_std | none | none, c89, c99, c11, c17, c18, c2x, gnu89, gnu99, gnu11, gnu17, gnu18, gnu2x | C language standard to use | | c_std | none | none, c89, c99, c11, c17, c18, c2x, c23, gnu89, gnu99, gnu11, gnu17, gnu18, gnu2x, gnu23 | C language standard to use |
| c_winlibs | see below | free-form comma-separated list | Standard Windows libs to link against | | c_winlibs | see below | free-form comma-separated list | Standard Windows libs to link against |
| c_thread_count | 4 | integer value ≥ 0 | Number of threads to use with emcc when using threads | | c_thread_count | 4 | integer value ≥ 0 | Number of threads to use with emcc when using threads |
| cpp_args | | free-form comma-separated list | C++ compile arguments to use | | cpp_args | | free-form comma-separated list | C++ compile arguments to use |

@ -61,7 +61,7 @@ a sample output for a simple project.
------ ------------- --------------- ----------- ------ ------------- --------------- -----------
c_args [] Extra arguments passed to the C compiler c_args [] Extra arguments passed to the C compiler
c_link_args [] Extra arguments passed to the C linker c_link_args [] Extra arguments passed to the C linker
c_std c99 [none, c89, c99, c11, c17, c18, c2x, gnu89, gnu99, gnu11, gnu17, gnu18, gnu2x] C language standard to use c_std c99 [none, c89, c99, c11, c17, c18, c2x, c23, gnu89, gnu99, gnu11, gnu17, gnu18, gnu2x, gnu23] C language standard to use
cpp_args [] Extra arguments passed to the C++ compiler cpp_args [] Extra arguments passed to the C++ compiler
cpp_debugstl false [true, false] STL debug mode cpp_debugstl false [true, false] STL debug mode
cpp_link_args [] Extra arguments passed to the C++ linker cpp_link_args [] Extra arguments passed to the C++ linker

@ -46,7 +46,7 @@ if T.TYPE_CHECKING:
else: else:
CompilerMixinBase = object CompilerMixinBase = object
_ALL_STDS = ['c89', 'c9x', 'c90', 'c99', 'c1x', 'c11', 'c17', 'c18', 'c2x'] _ALL_STDS = ['c89', 'c9x', 'c90', 'c99', 'c1x', 'c11', 'c17', 'c18', 'c2x', 'c23']
_ALL_STDS += [f'gnu{std[1:]}' for std in _ALL_STDS] _ALL_STDS += [f'gnu{std[1:]}' for std in _ALL_STDS]
_ALL_STDS += ['iso9899:1990', 'iso9899:199409', 'iso9899:1999', 'iso9899:2011', 'iso9899:2017', 'iso9899:2018'] _ALL_STDS += ['iso9899:1990', 'iso9899:199409', 'iso9899:1999', 'iso9899:2011', 'iso9899:2017', 'iso9899:2018']
@ -113,6 +113,7 @@ class _ClangCStds(CompilerMixinBase):
_C17_VERSION = '>=6.0.0' _C17_VERSION = '>=6.0.0'
_C18_VERSION = '>=8.0.0' _C18_VERSION = '>=8.0.0'
_C2X_VERSION = '>=9.0.0' _C2X_VERSION = '>=9.0.0'
_C23_VERSION = '>=18.0.0'
def get_options(self) -> 'MutableKeyedOptionDictType': def get_options(self) -> 'MutableKeyedOptionDictType':
opts = super().get_options() opts = super().get_options()
@ -125,6 +126,8 @@ class _ClangCStds(CompilerMixinBase):
stds += ['c18'] stds += ['c18']
if version_compare(self.version, self._C2X_VERSION): if version_compare(self.version, self._C2X_VERSION):
stds += ['c2x'] stds += ['c2x']
if version_compare(self.version, self._C23_VERSION):
stds += ['c23']
std_opt = opts[OptionKey('std', machine=self.for_machine, lang=self.language)] std_opt = opts[OptionKey('std', machine=self.for_machine, lang=self.language)]
assert isinstance(std_opt, coredata.UserStdOption), 'for mypy' assert isinstance(std_opt, coredata.UserStdOption), 'for mypy'
std_opt.set_versions(stds, gnu=True) std_opt.set_versions(stds, gnu=True)
@ -253,6 +256,7 @@ class GnuCCompiler(GnuCompiler, CCompiler):
_C18_VERSION = '>=8.0.0' _C18_VERSION = '>=8.0.0'
_C2X_VERSION = '>=9.0.0' _C2X_VERSION = '>=9.0.0'
_C23_VERSION = '>=14.0.0'
_INVALID_PCH_VERSION = ">=3.4.0" _INVALID_PCH_VERSION = ">=3.4.0"
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
@ -280,6 +284,8 @@ class GnuCCompiler(GnuCompiler, CCompiler):
stds += ['c17', 'c18'] stds += ['c17', 'c18']
if version_compare(self.version, self._C2X_VERSION): if version_compare(self.version, self._C2X_VERSION):
stds += ['c2x'] stds += ['c2x']
if version_compare(self.version, self._C23_VERSION):
stds += ['c23']
key = OptionKey('std', machine=self.for_machine, lang=self.language) key = OptionKey('std', machine=self.for_machine, lang=self.language)
std_opt = opts[key] std_opt = opts[key]
assert isinstance(std_opt, coredata.UserStdOption), 'for mypy' assert isinstance(std_opt, coredata.UserStdOption), 'for mypy'

Loading…
Cancel
Save