2023-12-14 03:38:41 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2020-10-28 00:17:28 +08:00
|
|
|
# Copyright 2012-2020 The Meson development team
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2022-08-28 22:49:00 +08:00
|
|
|
from __future__ import annotations
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2018-07-10 00:45:02 +08:00
|
|
|
import os.path
|
2020-01-06 22:27:38 +08:00
|
|
|
import typing as T
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2024-05-23 04:59:02 +08:00
|
|
|
from .. import options
|
2021-01-23 04:48:22 +08:00
|
|
|
from .. import mlog
|
2024-06-08 23:01:49 +08:00
|
|
|
from ..mesonlib import MesonException, version_compare
|
2017-09-30 02:52:06 +08:00
|
|
|
from .c_function_attributes import C_FUNC_ATTRIBUTES
|
2019-07-03 01:31:39 +08:00
|
|
|
from .mixins.clike import CLikeCompiler
|
2019-07-03 01:52:25 +08:00
|
|
|
from .mixins.ccrx import CcrxCompiler
|
2020-03-21 04:13:42 +08:00
|
|
|
from .mixins.xc16 import Xc16Compiler
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
from .mixins.compcert import CompCertCompiler
|
2022-01-27 10:45:57 +08:00
|
|
|
from .mixins.ti import TICompiler
|
2019-07-03 05:52:32 +08:00
|
|
|
from .mixins.arm import ArmCompiler, ArmclangCompiler
|
2020-01-07 05:49:01 +08:00
|
|
|
from .mixins.visualstudio import MSVCCompiler, ClangClCompiler
|
2019-07-03 05:03:32 +08:00
|
|
|
from .mixins.gnu import GnuCompiler
|
2022-07-02 00:57:56 +08:00
|
|
|
from .mixins.gnu import gnu_common_warning_args, gnu_c_warning_args
|
2019-07-03 05:36:08 +08:00
|
|
|
from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler
|
2019-07-03 06:14:48 +08:00
|
|
|
from .mixins.clang import ClangCompiler
|
2019-07-03 06:26:02 +08:00
|
|
|
from .mixins.elbrus import ElbrusCompiler
|
2019-07-03 06:37:25 +08:00
|
|
|
from .mixins.pgi import PGICompiler
|
2019-10-15 05:59:59 +08:00
|
|
|
from .mixins.emscripten import EmscriptenMixin
|
2023-03-28 17:25:19 +08:00
|
|
|
from .mixins.metrowerks import MetrowerksCompiler
|
|
|
|
from .mixins.metrowerks import mwccarm_instruction_set_args, mwcceppc_instruction_set_args
|
2017-06-23 07:42:41 +08:00
|
|
|
from .compilers import (
|
|
|
|
gnu_winlibs,
|
|
|
|
msvc_winlibs,
|
|
|
|
Compiler,
|
|
|
|
)
|
|
|
|
|
2020-01-06 22:27:38 +08:00
|
|
|
if T.TYPE_CHECKING:
|
2021-10-13 09:45:24 +08:00
|
|
|
from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType
|
2020-10-02 04:02:08 +08:00
|
|
|
from ..dependencies import Dependency
|
2019-08-22 04:12:30 +08:00
|
|
|
from ..envconfig import MachineInfo
|
2020-09-22 06:35:53 +08:00
|
|
|
from ..environment import Environment
|
2023-02-07 12:29:27 +08:00
|
|
|
from ..linkers.linkers import DynamicLinker
|
2022-08-28 22:49:00 +08:00
|
|
|
from ..mesonlib import MachineChoice
|
2021-07-27 05:38:44 +08:00
|
|
|
from .compilers import CompileCheckMode
|
2020-09-22 06:35:53 +08:00
|
|
|
|
|
|
|
CompilerMixinBase = Compiler
|
|
|
|
else:
|
|
|
|
CompilerMixinBase = object
|
|
|
|
|
2024-01-09 21:11:39 +08:00
|
|
|
_ALL_STDS = ['c89', 'c9x', 'c90', 'c99', 'c1x', 'c11', 'c17', 'c18', 'c2x', 'c23']
|
2022-04-29 04:08:24 +08:00
|
|
|
_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']
|
|
|
|
|
2019-08-22 04:12:30 +08:00
|
|
|
|
2019-05-01 01:53:39 +08:00
|
|
|
class CCompiler(CLikeCompiler, Compiler):
|
2022-05-20 02:33:51 +08:00
|
|
|
def attribute_check_func(self, name: str) -> str:
|
2017-09-30 02:52:06 +08:00
|
|
|
try:
|
|
|
|
return C_FUNC_ATTRIBUTES[name]
|
|
|
|
except KeyError:
|
2021-03-05 06:16:11 +08:00
|
|
|
raise MesonException(f'Unknown function attribute "{name}"')
|
2017-09-30 02:52:06 +08:00
|
|
|
|
2019-11-26 03:45:17 +08:00
|
|
|
language = 'c'
|
|
|
|
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
2023-11-28 04:47:16 +08:00
|
|
|
info: 'MachineInfo',
|
2020-09-22 06:35:53 +08:00
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2017-06-23 07:42:41 +08:00
|
|
|
# If a child ObjC or CPP class has already set it, don't set it ourselves
|
2022-10-01 02:46:10 +08:00
|
|
|
Compiler.__init__(self, ccache, exelist, version, for_machine, info,
|
2020-09-22 06:35:53 +08:00
|
|
|
is_cross=is_cross, full_version=full_version, linker=linker)
|
2023-11-28 04:47:16 +08:00
|
|
|
CLikeCompiler.__init__(self)
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_no_stdinc_args(self) -> T.List[str]:
|
2017-06-23 07:42:41 +08:00
|
|
|
return ['-nostdinc']
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def sanity_check(self, work_dir: str, environment: 'Environment') -> None:
|
2019-11-19 04:21:37 +08:00
|
|
|
code = 'int main(void) { int class=0; return class; }\n'
|
2020-09-18 04:48:06 +08:00
|
|
|
return self._sanity_check_impl(work_dir, environment, 'sanitycheckc.c', code)
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def has_header_symbol(self, hname: str, symbol: str, prefix: str,
|
|
|
|
env: 'Environment', *,
|
2021-07-27 05:38:44 +08:00
|
|
|
extra_args: T.Union[None, T.List[str], T.Callable[['CompileCheckMode'], T.List[str]]] = None,
|
2020-09-22 06:35:53 +08:00
|
|
|
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
|
2017-06-23 07:42:41 +08:00
|
|
|
fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol}
|
|
|
|
t = '''{prefix}
|
|
|
|
#include <{header}>
|
2019-11-19 04:21:37 +08:00
|
|
|
int main(void) {{
|
2017-06-23 07:42:41 +08:00
|
|
|
/* If it's not defined as a macro, try to use as a symbol */
|
|
|
|
#ifndef {symbol}
|
|
|
|
{symbol};
|
|
|
|
#endif
|
2019-07-15 16:06:17 +08:00
|
|
|
return 0;
|
2017-06-23 07:42:41 +08:00
|
|
|
}}'''
|
compilers: Use keyword only arguments for compiler interfaces
Because we need to inherit them in some cases, and python's
keyword-or-positional arguments make this really painful, especially
with inheritance. They do this in two ways:
1) If you want to intercept the arguments you need to check for both a
keyword and a positional argument, because you could get either. Then
you need to make sure that you only pass one of those down to the
next layer.
2) After you do that, if the layer below you decides to do the same
thing, but uses the other form (you used keyword by the lower level
uses positional or vice versa), then you'll get a TypeError since two
layers down got the argument as both a positional and a keyword.
All of this is bad. Fortunately python 3.x provides a mechanism to solve
this, keyword only arguments. These arguments cannot be based
positionally, the interpreter will give us an error in that case.
I have made a best effort to do this correctly, and I've verified it
with GCC, Clang, ICC, and MSVC, but there are other compilers like Arm
and Elbrus that I don't have access to.
2018-10-10 06:15:39 +08:00
|
|
|
return self.compiles(t.format(**fargs), env, extra_args=extra_args,
|
|
|
|
dependencies=dependencies)
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2020-10-14 01:09:38 +08:00
|
|
|
opts = super().get_options()
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2020-10-14 01:09:38 +08:00
|
|
|
opts.update({
|
2024-05-23 04:59:02 +08:00
|
|
|
key: options.UserStdOption('C', _ALL_STDS),
|
2020-10-14 01:09:38 +08:00
|
|
|
})
|
|
|
|
return opts
|
|
|
|
|
2017-09-30 02:52:06 +08:00
|
|
|
|
2020-10-28 00:17:28 +08:00
|
|
|
class _ClangCStds(CompilerMixinBase):
|
|
|
|
|
|
|
|
"""Mixin class for clang based compilers for setting C standards.
|
|
|
|
|
|
|
|
This is used by both ClangCCompiler and ClangClCompiler, as they share
|
|
|
|
the same versions
|
|
|
|
"""
|
2019-08-22 04:21:49 +08:00
|
|
|
|
2019-10-11 16:15:08 +08:00
|
|
|
_C17_VERSION = '>=6.0.0'
|
|
|
|
_C18_VERSION = '>=8.0.0'
|
2020-08-16 01:45:31 +08:00
|
|
|
_C2X_VERSION = '>=9.0.0'
|
2024-01-09 21:11:39 +08:00
|
|
|
_C23_VERSION = '>=18.0.0'
|
2019-08-22 04:21:49 +08:00
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2020-10-28 00:17:28 +08:00
|
|
|
opts = super().get_options()
|
2022-04-29 04:08:24 +08:00
|
|
|
stds = ['c89', 'c99', 'c11']
|
2019-06-26 09:00:58 +08:00
|
|
|
# https://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html
|
|
|
|
# https://en.wikipedia.org/wiki/Xcode#Latest_versions
|
2019-08-22 04:21:49 +08:00
|
|
|
if version_compare(self.version, self._C17_VERSION):
|
2022-04-29 04:08:24 +08:00
|
|
|
stds += ['c17']
|
2019-08-22 04:21:49 +08:00
|
|
|
if version_compare(self.version, self._C18_VERSION):
|
2022-04-29 04:08:24 +08:00
|
|
|
stds += ['c18']
|
2020-08-16 01:45:31 +08:00
|
|
|
if version_compare(self.version, self._C2X_VERSION):
|
2022-04-29 04:08:24 +08:00
|
|
|
stds += ['c2x']
|
2024-01-09 21:11:39 +08:00
|
|
|
if version_compare(self.version, self._C23_VERSION):
|
|
|
|
stds += ['c23']
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(stds, gnu=True)
|
2020-10-28 00:17:28 +08:00
|
|
|
return opts
|
|
|
|
|
|
|
|
|
|
|
|
class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler):
|
|
|
|
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
2023-11-28 04:47:16 +08:00
|
|
|
info: 'MachineInfo',
|
2020-10-28 00:17:28 +08:00
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
defines: T.Optional[T.Dict[str, str]] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2023-11-28 04:47:16 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross, info, linker=linker, full_version=full_version)
|
2020-10-28 00:17:28 +08:00
|
|
|
ClangCompiler.__init__(self, defines)
|
|
|
|
default_warn_args = ['-Wall', '-Winvalid-pch']
|
|
|
|
self.warn_args = {'0': [],
|
|
|
|
'1': default_warn_args,
|
|
|
|
'2': default_warn_args + ['-Wextra'],
|
2022-07-02 00:57:56 +08:00
|
|
|
'3': default_warn_args + ['-Wextra', '-Wpedantic'],
|
|
|
|
'everything': ['-Weverything']}
|
2020-10-28 00:17:28 +08:00
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2020-10-28 00:17:28 +08:00
|
|
|
opts = super().get_options()
|
2020-03-03 19:02:04 +08:00
|
|
|
if self.info.is_windows() or self.info.is_cygwin():
|
2024-01-12 04:20:44 +08:00
|
|
|
self.update_options(
|
|
|
|
opts,
|
2024-05-23 04:59:02 +08:00
|
|
|
self.create_option(options.UserArrayOption,
|
2024-06-08 23:01:49 +08:00
|
|
|
self.form_langopt_key('winlibs'),
|
2024-01-12 04:20:44 +08:00
|
|
|
'Standard Win libraries to link against',
|
|
|
|
gnu_winlibs),
|
|
|
|
)
|
2018-05-13 22:36:58 +08:00
|
|
|
return opts
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2017-06-23 07:42:41 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std != 'none':
|
|
|
|
args.append('-std=' + std)
|
2017-06-23 07:42:41 +08:00
|
|
|
return args
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2020-03-03 19:02:04 +08:00
|
|
|
if self.info.is_windows() or self.info.is_cygwin():
|
2020-09-22 06:35:53 +08:00
|
|
|
# without a typedict mypy can't understand this.
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('winlibs')
|
2024-06-09 06:03:49 +08:00
|
|
|
libs = options.get_value(key).copy()
|
2020-09-22 06:35:53 +08:00
|
|
|
assert isinstance(libs, list)
|
|
|
|
for l in libs:
|
|
|
|
assert isinstance(l, str)
|
|
|
|
return libs
|
2017-06-23 07:42:41 +08:00
|
|
|
return []
|
|
|
|
|
2017-11-13 03:47:08 +08:00
|
|
|
|
2021-12-17 06:09:06 +08:00
|
|
|
class ArmLtdClangCCompiler(ClangCCompiler):
|
|
|
|
|
2022-01-11 01:54:46 +08:00
|
|
|
id = 'armltdclang'
|
2021-12-17 06:09:06 +08:00
|
|
|
|
|
|
|
|
2019-08-22 04:21:49 +08:00
|
|
|
class AppleClangCCompiler(ClangCCompiler):
|
|
|
|
|
|
|
|
"""Handle the differences between Apple Clang and Vanilla Clang.
|
2019-08-22 04:12:30 +08:00
|
|
|
|
2019-08-22 04:21:49 +08:00
|
|
|
Right now this just handles the differences between the versions that new
|
|
|
|
C standards were added.
|
|
|
|
"""
|
|
|
|
|
2019-10-11 16:15:08 +08:00
|
|
|
_C17_VERSION = '>=10.0.0'
|
|
|
|
_C18_VERSION = '>=11.0.0'
|
2020-08-16 01:45:31 +08:00
|
|
|
_C2X_VERSION = '>=11.0.0'
|
2019-08-22 04:21:49 +08:00
|
|
|
|
|
|
|
|
2020-12-09 03:08:37 +08:00
|
|
|
class EmscriptenCCompiler(EmscriptenMixin, ClangCCompiler):
|
2022-01-11 01:54:46 +08:00
|
|
|
|
|
|
|
id = 'emscripten'
|
|
|
|
|
2024-05-17 02:46:45 +08:00
|
|
|
# Emscripten uses different version numbers than Clang; `emcc -v` will show
|
|
|
|
# the Clang version number used as well (but `emcc --version` does not).
|
|
|
|
# See https://github.com/pyodide/pyodide/discussions/4762 for more on
|
|
|
|
# emcc <--> clang versions. Note that c17/c18/c2x are always available, since
|
|
|
|
# the lowest supported Emscripten version used a new-enough Clang version.
|
|
|
|
_C17_VERSION = '>=1.38.35'
|
|
|
|
_C18_VERSION = '>=1.38.35'
|
|
|
|
_C2X_VERSION = '>=1.38.35' # 1.38.35 used Clang 9.0.0
|
|
|
|
_C23_VERSION = '>=3.0.0' # 3.0.0 used Clang 18.0.0
|
|
|
|
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
2023-11-28 04:47:16 +08:00
|
|
|
info: 'MachineInfo',
|
2020-09-22 06:35:53 +08:00
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
defines: T.Optional[T.Dict[str, str]] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2019-06-20 02:56:00 +08:00
|
|
|
if not is_cross:
|
|
|
|
raise MesonException('Emscripten compiler can only be used for cross compilation.')
|
2022-12-26 00:01:26 +08:00
|
|
|
if not version_compare(version, '>=1.39.19'):
|
|
|
|
raise MesonException('Meson requires Emscripten >= 1.39.19')
|
2022-10-01 02:46:10 +08:00
|
|
|
ClangCCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker,
|
2020-09-22 06:35:53 +08:00
|
|
|
defines=defines, full_version=full_version)
|
2019-06-20 02:56:00 +08:00
|
|
|
|
2019-09-08 07:33:28 +08:00
|
|
|
|
2018-06-21 05:55:39 +08:00
|
|
|
class ArmclangCCompiler(ArmclangCompiler, CCompiler):
|
2021-12-17 06:08:10 +08:00
|
|
|
'''
|
|
|
|
Keil armclang
|
|
|
|
'''
|
|
|
|
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
2023-11-28 04:47:16 +08:00
|
|
|
info: 'MachineInfo',
|
2020-09-22 06:35:53 +08:00
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2019-08-22 04:12:30 +08:00
|
|
|
ArmclangCompiler.__init__(self)
|
2018-06-21 05:55:39 +08:00
|
|
|
default_warn_args = ['-Wall', '-Winvalid-pch']
|
2019-02-19 06:06:27 +08:00
|
|
|
self.warn_args = {'0': [],
|
|
|
|
'1': default_warn_args,
|
2018-06-21 05:55:39 +08:00
|
|
|
'2': default_warn_args + ['-Wextra'],
|
2022-07-02 00:57:56 +08:00
|
|
|
'3': default_warn_args + ['-Wextra', '-Wpedantic'],
|
|
|
|
'everything': ['-Weverything']}
|
2018-06-21 05:55:39 +08:00
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2018-06-21 05:55:39 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(['c90', 'c99', 'c11'], gnu=True)
|
2018-06-21 05:55:39 +08:00
|
|
|
return opts
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2018-06-21 05:55:39 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std != 'none':
|
|
|
|
args.append('-std=' + std)
|
2018-06-21 05:55:39 +08:00
|
|
|
return args
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2018-06-21 05:55:39 +08:00
|
|
|
return []
|
|
|
|
|
|
|
|
|
2017-06-23 07:42:41 +08:00
|
|
|
class GnuCCompiler(GnuCompiler, CCompiler):
|
2020-08-16 01:45:31 +08:00
|
|
|
|
|
|
|
_C18_VERSION = '>=8.0.0'
|
|
|
|
_C2X_VERSION = '>=9.0.0'
|
2024-01-09 21:11:39 +08:00
|
|
|
_C23_VERSION = '>=14.0.0'
|
2021-11-16 12:33:36 +08:00
|
|
|
_INVALID_PCH_VERSION = ">=3.4.0"
|
2020-08-16 01:45:31 +08:00
|
|
|
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
2023-11-28 04:47:16 +08:00
|
|
|
info: 'MachineInfo',
|
2020-09-22 06:35:53 +08:00
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
defines: T.Optional[T.Dict[str, str]] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2023-11-28 04:47:16 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross, info, linker=linker, full_version=full_version)
|
2019-08-22 04:12:30 +08:00
|
|
|
GnuCompiler.__init__(self, defines)
|
2021-11-16 12:33:36 +08:00
|
|
|
default_warn_args = ['-Wall']
|
|
|
|
if version_compare(self.version, self._INVALID_PCH_VERSION):
|
|
|
|
default_warn_args += ['-Winvalid-pch']
|
2019-02-19 06:06:27 +08:00
|
|
|
self.warn_args = {'0': [],
|
|
|
|
'1': default_warn_args,
|
2017-06-23 07:42:41 +08:00
|
|
|
'2': default_warn_args + ['-Wextra'],
|
2022-07-02 00:57:56 +08:00
|
|
|
'3': default_warn_args + ['-Wextra', '-Wpedantic'],
|
|
|
|
'everything': (default_warn_args + ['-Wextra', '-Wpedantic'] +
|
|
|
|
self.supported_warn_args(gnu_common_warning_args) +
|
|
|
|
self.supported_warn_args(gnu_c_warning_args))}
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2018-05-13 22:36:58 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2022-04-29 04:08:24 +08:00
|
|
|
stds = ['c89', 'c99', 'c11']
|
2020-08-16 01:45:31 +08:00
|
|
|
if version_compare(self.version, self._C18_VERSION):
|
2022-04-29 04:08:24 +08:00
|
|
|
stds += ['c17', 'c18']
|
2020-08-16 01:45:31 +08:00
|
|
|
if version_compare(self.version, self._C2X_VERSION):
|
2022-04-29 04:08:24 +08:00
|
|
|
stds += ['c2x']
|
2024-01-09 21:11:39 +08:00
|
|
|
if version_compare(self.version, self._C23_VERSION):
|
|
|
|
stds += ['c23']
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(stds, gnu=True)
|
2019-08-22 04:12:30 +08:00
|
|
|
if self.info.is_windows() or self.info.is_cygwin():
|
2024-01-12 04:20:44 +08:00
|
|
|
self.update_options(
|
|
|
|
opts,
|
2024-05-23 04:59:02 +08:00
|
|
|
self.create_option(options.UserArrayOption,
|
2024-01-12 04:20:44 +08:00
|
|
|
key.evolve('winlibs'),
|
|
|
|
'Standard Win libraries to link against',
|
|
|
|
gnu_winlibs),
|
|
|
|
)
|
2017-06-23 07:42:41 +08:00
|
|
|
return opts
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2017-06-23 07:42:41 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std != 'none':
|
|
|
|
args.append('-std=' + std)
|
2017-06-23 07:42:41 +08:00
|
|
|
return args
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2019-08-22 04:12:30 +08:00
|
|
|
if self.info.is_windows() or self.info.is_cygwin():
|
2020-09-22 06:35:53 +08:00
|
|
|
# without a typeddict mypy can't figure this out
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('winlibs')
|
2024-06-09 06:03:49 +08:00
|
|
|
libs: T.List[str] = options.get_value(key).copy()
|
2020-09-22 06:35:53 +08:00
|
|
|
assert isinstance(libs, list)
|
|
|
|
for l in libs:
|
|
|
|
assert isinstance(l, str)
|
|
|
|
return libs
|
2017-06-23 07:42:41 +08:00
|
|
|
return []
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]:
|
2018-01-29 08:10:43 +08:00
|
|
|
return ['-fpch-preprocess', '-include', os.path.basename(header)]
|
2017-08-07 06:02:45 +08:00
|
|
|
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2019-01-22 02:09:36 +08:00
|
|
|
class PGICCompiler(PGICompiler, CCompiler):
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
2023-11-28 04:47:16 +08:00
|
|
|
info: 'MachineInfo',
|
2020-09-22 06:35:53 +08:00
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2019-08-22 04:12:30 +08:00
|
|
|
PGICompiler.__init__(self)
|
2019-01-22 02:09:36 +08:00
|
|
|
|
|
|
|
|
2020-07-13 12:16:52 +08:00
|
|
|
class NvidiaHPC_CCompiler(PGICompiler, CCompiler):
|
2022-01-11 01:54:46 +08:00
|
|
|
|
|
|
|
id = 'nvidia_hpc'
|
|
|
|
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
2023-11-28 04:47:16 +08:00
|
|
|
info: 'MachineInfo',
|
2020-09-22 06:35:53 +08:00
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2020-07-13 12:16:52 +08:00
|
|
|
PGICompiler.__init__(self)
|
|
|
|
|
|
|
|
|
2021-09-29 04:26:31 +08:00
|
|
|
class ElbrusCCompiler(ElbrusCompiler, CCompiler):
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
2023-11-28 04:47:16 +08:00
|
|
|
info: 'MachineInfo',
|
2020-09-22 06:35:53 +08:00
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
defines: T.Optional[T.Dict[str, str]] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2020-01-13 22:11:20 +08:00
|
|
|
ElbrusCompiler.__init__(self)
|
2018-03-20 04:30:00 +08:00
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2018-05-13 22:36:58 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2021-09-29 07:38:19 +08:00
|
|
|
stds = ['c89', 'c9x', 'c99', 'gnu89', 'gnu9x', 'gnu99']
|
|
|
|
stds += ['iso9899:1990', 'iso9899:199409', 'iso9899:1999']
|
|
|
|
if version_compare(self.version, '>=1.20.00'):
|
|
|
|
stds += ['c11', 'gnu11']
|
|
|
|
if version_compare(self.version, '>=1.21.00') and version_compare(self.version, '<1.22.00'):
|
|
|
|
stds += ['c90', 'c1x', 'gnu90', 'gnu1x', 'iso9899:2011']
|
|
|
|
if version_compare(self.version, '>=1.23.00'):
|
|
|
|
stds += ['c90', 'c1x', 'gnu90', 'gnu1x', 'iso9899:2011']
|
|
|
|
if version_compare(self.version, '>=1.26.00'):
|
|
|
|
stds += ['c17', 'c18', 'iso9899:2017', 'iso9899:2018', 'gnu17', 'gnu18']
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(stds)
|
2018-03-20 04:30:00 +08:00
|
|
|
return opts
|
|
|
|
|
2018-03-21 21:42:15 +08:00
|
|
|
# Elbrus C compiler does not have lchmod, but there is only linker warning, not compiler error.
|
|
|
|
# So we should explicitly fail at this case.
|
2020-09-22 06:35:53 +08:00
|
|
|
def has_function(self, funcname: str, prefix: str, env: 'Environment', *,
|
|
|
|
extra_args: T.Optional[T.List[str]] = None,
|
|
|
|
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
|
2018-03-21 21:42:15 +08:00
|
|
|
if funcname == 'lchmod':
|
2019-02-20 04:04:23 +08:00
|
|
|
return False, False
|
2018-03-21 21:42:15 +08:00
|
|
|
else:
|
compilers: Use keyword only arguments for compiler interfaces
Because we need to inherit them in some cases, and python's
keyword-or-positional arguments make this really painful, especially
with inheritance. They do this in two ways:
1) If you want to intercept the arguments you need to check for both a
keyword and a positional argument, because you could get either. Then
you need to make sure that you only pass one of those down to the
next layer.
2) After you do that, if the layer below you decides to do the same
thing, but uses the other form (you used keyword by the lower level
uses positional or vice versa), then you'll get a TypeError since two
layers down got the argument as both a positional and a keyword.
All of this is bad. Fortunately python 3.x provides a mechanism to solve
this, keyword only arguments. These arguments cannot be based
positionally, the interpreter will give us an error in that case.
I have made a best effort to do this correctly, and I've verified it
with GCC, Clang, ICC, and MSVC, but there are other compilers like Arm
and Elbrus that I don't have access to.
2018-10-10 06:15:39 +08:00
|
|
|
return super().has_function(funcname, prefix, env,
|
|
|
|
extra_args=extra_args,
|
|
|
|
dependencies=dependencies)
|
2018-03-21 21:42:15 +08:00
|
|
|
|
2021-09-29 07:38:19 +08:00
|
|
|
|
2019-05-01 06:41:36 +08:00
|
|
|
class IntelCCompiler(IntelGnuLikeCompiler, CCompiler):
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
2023-11-28 04:47:16 +08:00
|
|
|
info: 'MachineInfo',
|
2020-09-22 06:35:53 +08:00
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2019-08-22 04:12:30 +08:00
|
|
|
IntelGnuLikeCompiler.__init__(self)
|
2017-06-23 07:42:41 +08:00
|
|
|
self.lang_header = 'c-header'
|
2022-07-02 00:57:56 +08:00
|
|
|
default_warn_args = ['-Wall', '-w3']
|
2019-02-19 06:06:27 +08:00
|
|
|
self.warn_args = {'0': [],
|
2022-07-02 00:57:56 +08:00
|
|
|
'1': default_warn_args + ['-diag-disable:remark'],
|
|
|
|
'2': default_warn_args + ['-Wextra', '-diag-disable:remark'],
|
|
|
|
'3': default_warn_args + ['-Wextra', '-diag-disable:remark'],
|
|
|
|
'everything': default_warn_args + ['-Wextra']}
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2018-05-13 22:36:58 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2022-04-29 04:08:24 +08:00
|
|
|
stds = ['c89', 'c99']
|
2017-06-23 07:42:41 +08:00
|
|
|
if version_compare(self.version, '>=16.0.0'):
|
2022-04-29 04:08:24 +08:00
|
|
|
stds += ['c11']
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(stds, gnu=True)
|
2017-06-23 07:42:41 +08:00
|
|
|
return opts
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2017-06-23 07:42:41 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std != 'none':
|
|
|
|
args.append('-std=' + std)
|
2017-06-23 07:42:41 +08:00
|
|
|
return args
|
|
|
|
|
|
|
|
|
2022-10-09 21:14:52 +08:00
|
|
|
class IntelLLVMCCompiler(ClangCCompiler):
|
|
|
|
|
|
|
|
id = 'intel-llvm'
|
|
|
|
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
class VisualStudioLikeCCompilerMixin(CompilerMixinBase):
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2019-05-01 01:53:39 +08:00
|
|
|
"""Shared methods that apply to MSVC-like C compilers."""
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2024-01-12 04:20:44 +08:00
|
|
|
def get_options(self) -> MutableKeyedOptionDictType:
|
|
|
|
return self.update_options(
|
|
|
|
super().get_options(),
|
|
|
|
self.create_option(
|
2024-05-23 04:59:02 +08:00
|
|
|
options.UserArrayOption,
|
2024-06-08 23:01:49 +08:00
|
|
|
self.form_langopt_key('winlibs'),
|
2019-06-13 06:08:45 +08:00
|
|
|
'Windows libs to link against.',
|
|
|
|
msvc_winlibs,
|
|
|
|
),
|
2024-01-12 04:20:44 +08:00
|
|
|
)
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2020-09-22 06:35:53 +08:00
|
|
|
# need a TypeDict to make this work
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('winlibs')
|
2024-06-09 06:03:49 +08:00
|
|
|
libs = options.get_value(key).copy()
|
2020-09-22 06:35:53 +08:00
|
|
|
assert isinstance(libs, list)
|
|
|
|
for l in libs:
|
|
|
|
assert isinstance(l, str)
|
|
|
|
return libs
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2019-08-22 04:12:30 +08:00
|
|
|
|
2020-01-07 05:49:01 +08:00
|
|
|
class VisualStudioCCompiler(MSVCCompiler, VisualStudioLikeCCompilerMixin, CCompiler):
|
2018-10-14 11:00:38 +08:00
|
|
|
|
2020-11-11 12:32:23 +08:00
|
|
|
_C11_VERSION = '>=19.28'
|
|
|
|
_C17_VERSION = '>=19.28'
|
|
|
|
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
2020-09-22 06:35:53 +08:00
|
|
|
is_cross: bool, info: 'MachineInfo', target: str,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker,
|
2020-09-22 06:35:53 +08:00
|
|
|
full_version=full_version)
|
2020-01-07 05:49:01 +08:00
|
|
|
MSVCCompiler.__init__(self, target)
|
2018-10-14 11:00:38 +08:00
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2020-08-06 10:56:19 +08:00
|
|
|
opts = super().get_options()
|
2022-04-29 04:08:24 +08:00
|
|
|
stds = ['c89', 'c99']
|
2020-11-11 12:32:23 +08:00
|
|
|
if version_compare(self.version, self._C11_VERSION):
|
2022-04-29 04:08:24 +08:00
|
|
|
stds += ['c11']
|
2020-11-11 12:32:23 +08:00
|
|
|
if version_compare(self.version, self._C17_VERSION):
|
2022-04-29 04:08:24 +08:00
|
|
|
stds += ['c17', 'c18']
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(stds, gnu=True, gnu_deprecated=True)
|
2020-08-06 10:56:19 +08:00
|
|
|
return opts
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2020-08-06 10:56:19 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
2020-11-11 12:32:23 +08:00
|
|
|
# As of MVSC 16.8, /std:c11 and /std:c17 are the only valid C standard options.
|
2024-06-09 06:03:49 +08:00
|
|
|
if std == 'c11':
|
2020-10-17 22:11:42 +08:00
|
|
|
args.append('/std:c11')
|
2024-06-09 06:03:49 +08:00
|
|
|
elif std in {'c17', 'c18'}:
|
2020-11-11 12:32:23 +08:00
|
|
|
args.append('/std:c17')
|
2020-08-06 10:56:19 +08:00
|
|
|
return args
|
|
|
|
|
2019-08-22 04:12:30 +08:00
|
|
|
|
2020-10-28 00:17:28 +08:00
|
|
|
class ClangClCCompiler(_ClangCStds, ClangClCompiler, VisualStudioLikeCCompilerMixin, CCompiler):
|
2020-09-22 06:35:53 +08:00
|
|
|
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice,
|
|
|
|
is_cross: bool, info: 'MachineInfo', target: str,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, [], exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker,
|
2020-09-22 06:35:53 +08:00
|
|
|
full_version=full_version)
|
2020-01-07 05:49:01 +08:00
|
|
|
ClangClCompiler.__init__(self, target)
|
2017-09-30 02:52:06 +08:00
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
2020-10-28 00:17:28 +08:00
|
|
|
if std != "none":
|
2021-03-05 06:16:11 +08:00
|
|
|
return [f'/clang:-std={std}']
|
2020-10-20 00:34:41 +08:00
|
|
|
return []
|
2020-10-20 00:28:46 +08:00
|
|
|
|
2018-10-14 11:00:38 +08:00
|
|
|
|
2019-05-01 06:53:50 +08:00
|
|
|
class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerMixin, CCompiler):
|
|
|
|
|
|
|
|
"""Intel "ICL" compiler abstraction."""
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice,
|
|
|
|
is_cross: bool, info: 'MachineInfo', target: str,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, [], exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker,
|
2020-09-22 06:35:53 +08:00
|
|
|
full_version=full_version)
|
2019-05-01 06:53:50 +08:00
|
|
|
IntelVisualStudioLikeCompiler.__init__(self, target)
|
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2019-05-01 06:53:50 +08:00
|
|
|
opts = super().get_options()
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-12 02:20:33 +08:00
|
|
|
# To shut up mypy.
|
|
|
|
if isinstance(opts, dict):
|
|
|
|
raise RuntimeError('This is a transitory issue that should not happen. Please report with full backtrace.')
|
2024-06-09 06:03:49 +08:00
|
|
|
std_opt = opts.get_value_object(key)
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(['c89', 'c99', 'c11'])
|
2019-05-01 06:53:50 +08:00
|
|
|
return opts
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2019-05-01 06:53:50 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std == 'c89':
|
2022-11-19 05:34:22 +08:00
|
|
|
mlog.log("ICL doesn't explicitly implement c89, setting the standard to 'none', which is close.", once=True)
|
2024-06-09 06:03:49 +08:00
|
|
|
elif std != 'none':
|
|
|
|
args.append('/Qstd:' + std)
|
2019-05-01 06:53:50 +08:00
|
|
|
return args
|
|
|
|
|
|
|
|
|
2022-10-09 21:14:52 +08:00
|
|
|
class IntelLLVMClCCompiler(IntelClCCompiler):
|
|
|
|
|
|
|
|
id = 'intel-llvm-cl'
|
|
|
|
|
|
|
|
|
2018-03-15 21:03:11 +08:00
|
|
|
class ArmCCompiler(ArmCompiler, CCompiler):
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
2020-09-22 06:35:53 +08:00
|
|
|
is_cross: bool, info: 'MachineInfo',
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker,
|
2020-09-22 06:35:53 +08:00
|
|
|
full_version=full_version)
|
2019-08-22 04:12:30 +08:00
|
|
|
ArmCompiler.__init__(self)
|
2018-03-15 21:03:11 +08:00
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2018-05-13 22:36:58 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(['c89', 'c99', 'c11'])
|
2018-03-15 21:03:11 +08:00
|
|
|
return opts
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2018-03-15 21:03:11 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std != 'none':
|
|
|
|
args.append('--' + std)
|
2018-03-15 21:03:11 +08:00
|
|
|
return args
|
2018-10-25 10:24:05 +08:00
|
|
|
|
2019-08-22 04:12:30 +08:00
|
|
|
|
2018-10-25 10:24:05 +08:00
|
|
|
class CcrxCCompiler(CcrxCompiler, CCompiler):
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
2020-09-22 06:35:53 +08:00
|
|
|
is_cross: bool, info: 'MachineInfo',
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2019-08-22 04:12:30 +08:00
|
|
|
CcrxCompiler.__init__(self)
|
2018-10-25 10:24:05 +08:00
|
|
|
|
|
|
|
# Override CCompiler.get_always_args
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_always_args(self) -> T.List[str]:
|
2018-10-25 10:24:05 +08:00
|
|
|
return ['-nologo']
|
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2018-10-25 10:24:05 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(['c89', 'c99'])
|
2018-10-25 10:24:05 +08:00
|
|
|
return opts
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_no_stdinc_args(self) -> T.List[str]:
|
2020-01-30 05:34:19 +08:00
|
|
|
return []
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2018-10-25 10:24:05 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std == 'c89':
|
2018-10-25 10:24:05 +08:00
|
|
|
args.append('-lang=c')
|
2024-06-09 06:03:49 +08:00
|
|
|
elif std == 'c99':
|
2018-10-25 10:24:05 +08:00
|
|
|
args.append('-lang=c99')
|
|
|
|
return args
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_compile_only_args(self) -> T.List[str]:
|
2018-10-25 10:24:05 +08:00
|
|
|
return []
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_no_optimization_args(self) -> T.List[str]:
|
2018-10-25 10:24:05 +08:00
|
|
|
return ['-optimize=0']
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_output_args(self, target: str) -> T.List[str]:
|
2021-06-07 00:17:59 +08:00
|
|
|
return [f'-output=obj={target}']
|
2018-10-25 10:24:05 +08:00
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_werror_args(self) -> T.List[str]:
|
2019-01-10 05:01:46 +08:00
|
|
|
return ['-change_message=error']
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
|
2018-10-25 10:24:05 +08:00
|
|
|
if path == '':
|
|
|
|
path = '.'
|
|
|
|
return ['-include=' + path]
|
2020-03-21 04:13:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
class Xc16CCompiler(Xc16Compiler, CCompiler):
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
2020-09-22 06:35:53 +08:00
|
|
|
is_cross: bool, info: 'MachineInfo',
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2020-03-21 04:13:42 +08:00
|
|
|
Xc16Compiler.__init__(self)
|
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2020-03-21 04:13:42 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(['c89', 'c99'], gnu=True)
|
2020-03-21 04:13:42 +08:00
|
|
|
return opts
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_no_stdinc_args(self) -> T.List[str]:
|
2020-03-21 04:13:42 +08:00
|
|
|
return []
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2020-03-21 04:13:42 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std != 'none':
|
2020-03-21 04:13:42 +08:00
|
|
|
args.append('-ansi')
|
2024-06-09 06:03:49 +08:00
|
|
|
args.append('-std=' + std)
|
2020-03-21 04:13:42 +08:00
|
|
|
return args
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_compile_only_args(self) -> T.List[str]:
|
2020-03-21 04:13:42 +08:00
|
|
|
return []
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_no_optimization_args(self) -> T.List[str]:
|
2020-03-21 04:13:42 +08:00
|
|
|
return ['-O0']
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_output_args(self, target: str) -> T.List[str]:
|
2021-06-07 00:17:59 +08:00
|
|
|
return [f'-o{target}']
|
2020-03-21 04:13:42 +08:00
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_werror_args(self) -> T.List[str]:
|
2020-03-21 04:13:42 +08:00
|
|
|
return ['-change_message=error']
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
|
2020-03-21 04:13:42 +08:00
|
|
|
if path == '':
|
|
|
|
path = '.'
|
|
|
|
return ['-I' + path]
|
|
|
|
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
class CompCertCCompiler(CompCertCompiler, CCompiler):
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
2020-09-22 06:35:53 +08:00
|
|
|
is_cross: bool, info: 'MachineInfo',
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
CompCertCompiler.__init__(self)
|
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(['c89', 'c99'])
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
return opts
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
return []
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_no_optimization_args(self) -> T.List[str]:
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
return ['-O0']
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_output_args(self, target: str) -> T.List[str]:
|
2021-03-05 06:16:11 +08:00
|
|
|
return [f'-o{target}']
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_werror_args(self) -> T.List[str]:
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
return ['-Werror']
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
|
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler
The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.
Squashed commit of the following:
commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:20:39 2020 +0200
remove '-fall' from default arguments, also filter -ftls-model=.*
commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 14:13:55 2020 +0200
use regex for filtering ccomp args
commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date: Mon Aug 31 13:54:36 2020 +0200
filter some gcc arguments
commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date: Fri Aug 28 15:03:14 2020 +0200
fix ccomp meson configuration
commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date: Thu Aug 27 13:02:19 2020 +0200
add CompCert to meson (does not fully work, yet)
* remove unused import and s/cls/self/
fixes the two obvious LGTM warnings
* CompCert: Do not ignore unsupported GCC flags
Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.
* remove unused variable
* Only add arguments once.
* Apply suggestions from code review
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Remove erroneous ' ' from '-o {}'.format()
As noticed by @dcbaker
* added release note snippet for compcert
* properly split parameters
As suggested by @dcbaker, these parameters should be properly split into multiple strings.
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
* Update add_compcert_compiler.md
Added a sentence about the state of the implementation (experimental); use proper markdown
* properly separate arguments
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-16 02:51:21 +08:00
|
|
|
if path == '':
|
|
|
|
path = '.'
|
|
|
|
return ['-I' + path]
|
2020-03-21 04:13:42 +08:00
|
|
|
|
2022-01-27 10:45:57 +08:00
|
|
|
class TICCompiler(TICompiler, CCompiler):
|
2022-10-01 02:46:10 +08:00
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
2020-09-22 06:35:53 +08:00
|
|
|
is_cross: bool, info: 'MachineInfo',
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2022-10-01 02:46:10 +08:00
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2022-01-27 10:45:57 +08:00
|
|
|
TICompiler.__init__(self)
|
2020-03-21 04:13:42 +08:00
|
|
|
|
|
|
|
# Override CCompiler.get_always_args
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_always_args(self) -> T.List[str]:
|
2020-03-21 04:13:42 +08:00
|
|
|
return []
|
|
|
|
|
2021-10-13 09:45:24 +08:00
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
2020-03-21 04:13:42 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
std_opt = opts[key]
|
2024-05-23 04:59:02 +08:00
|
|
|
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
|
2022-04-29 04:08:24 +08:00
|
|
|
std_opt.set_versions(['c89', 'c99', 'c11'])
|
2020-03-21 04:13:42 +08:00
|
|
|
return opts
|
|
|
|
|
2020-09-22 06:35:53 +08:00
|
|
|
def get_no_stdinc_args(self) -> T.List[str]:
|
2020-03-21 04:13:42 +08:00
|
|
|
return []
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2020-03-21 04:13:42 +08:00
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std != 'none':
|
|
|
|
args.append('--' + std)
|
2020-03-21 04:13:42 +08:00
|
|
|
return args
|
|
|
|
|
2022-01-27 10:45:57 +08:00
|
|
|
class C2000CCompiler(TICCompiler):
|
|
|
|
# Required for backwards compat with projects created before ti-cgt support existed
|
|
|
|
id = 'c2000'
|
2023-03-28 17:25:19 +08:00
|
|
|
|
2023-09-12 15:11:50 +08:00
|
|
|
class C6000CCompiler(TICCompiler):
|
|
|
|
id = 'c6000'
|
|
|
|
|
2023-03-28 17:25:19 +08:00
|
|
|
class MetrowerksCCompilerARM(MetrowerksCompiler, CCompiler):
|
|
|
|
id = 'mwccarm'
|
|
|
|
|
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
|
|
|
is_cross: bool, info: 'MachineInfo',
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2023-03-28 17:25:19 +08:00
|
|
|
MetrowerksCompiler.__init__(self)
|
|
|
|
|
|
|
|
def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[str]]:
|
|
|
|
return mwccarm_instruction_set_args.get(instruction_set, None)
|
|
|
|
|
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
|
|
|
opts = CCompiler.get_options(self)
|
|
|
|
c_stds = ['c99']
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
opts[key].choices = ['none'] + c_stds
|
2023-03-28 17:25:19 +08:00
|
|
|
return opts
|
|
|
|
|
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std != 'none':
|
2023-03-28 17:25:19 +08:00
|
|
|
args.append('-lang')
|
2024-06-09 06:03:49 +08:00
|
|
|
args.append(std)
|
2023-03-28 17:25:19 +08:00
|
|
|
return args
|
|
|
|
|
|
|
|
class MetrowerksCCompilerEmbeddedPowerPC(MetrowerksCompiler, CCompiler):
|
|
|
|
id = 'mwcceppc'
|
|
|
|
|
|
|
|
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
|
|
|
is_cross: bool, info: 'MachineInfo',
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
|
|
|
CCompiler.__init__(self, ccache, exelist, version, for_machine, is_cross,
|
2023-11-28 04:47:16 +08:00
|
|
|
info, linker=linker, full_version=full_version)
|
2023-03-28 17:25:19 +08:00
|
|
|
MetrowerksCompiler.__init__(self)
|
|
|
|
|
|
|
|
def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[str]]:
|
|
|
|
return mwcceppc_instruction_set_args.get(instruction_set, None)
|
|
|
|
|
|
|
|
def get_options(self) -> 'MutableKeyedOptionDictType':
|
|
|
|
opts = CCompiler.get_options(self)
|
|
|
|
c_stds = ['c99']
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
|
|
|
opts[key].choices = ['none'] + c_stds
|
2023-03-28 17:25:19 +08:00
|
|
|
return opts
|
|
|
|
|
|
|
|
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
|
|
|
args = []
|
2024-06-08 23:01:49 +08:00
|
|
|
key = self.form_langopt_key('std')
|
2024-06-09 06:03:49 +08:00
|
|
|
std = options.get_value(key)
|
|
|
|
if std != 'none':
|
|
|
|
args.append('-lang ' + std)
|
2023-03-28 17:25:19 +08:00
|
|
|
return args
|