2020-10-28 00:17:28 +08:00
|
|
|
# Copyright 2012-2020 The Meson development team
|
2017-06-23 07:42:41 +08:00
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
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
|
|
|
|
|
|
|
from .. import coredata
|
2021-01-23 04:48:22 +08:00
|
|
|
from .. import mlog
|
|
|
|
from ..mesonlib import MachineChoice, MesonException, version_compare, OptionKey
|
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
|
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
|
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:
|
2020-12-03 08:02:03 +08:00
|
|
|
from ..coredata import 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
|
|
|
|
from ..linkers import DynamicLinker
|
2020-10-02 04:02:08 +08:00
|
|
|
from ..programs import ExternalProgram
|
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
|
|
|
|
|
2019-08-22 04:12:30 +08:00
|
|
|
|
2019-05-01 01:53:39 +08:00
|
|
|
class CCompiler(CLikeCompiler, Compiler):
|
2018-04-27 03:11:52 +08:00
|
|
|
|
2017-09-30 02:52:06 +08:00
|
|
|
@staticmethod
|
2020-09-22 06:35:53 +08:00
|
|
|
def attribute_check_func(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'
|
|
|
|
|
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', exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
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
|
2020-09-22 06:35:53 +08:00
|
|
|
Compiler.__init__(self, exelist, version, for_machine, info,
|
|
|
|
is_cross=is_cross, full_version=full_version, linker=linker)
|
2020-09-22 01:38:17 +08:00
|
|
|
CLikeCompiler.__init__(self, exe_wrapper)
|
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
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2020-10-14 01:09:38 +08:00
|
|
|
opts = super().get_options()
|
|
|
|
opts.update({
|
2020-12-03 08:02:03 +08:00
|
|
|
OptionKey('std', machine=self.for_machine, lang=self.language): coredata.UserComboOption(
|
2021-01-13 05:15:42 +08:00
|
|
|
'C language standard to use',
|
2020-10-14 01:09:38 +08:00
|
|
|
['none'],
|
|
|
|
'none',
|
|
|
|
)
|
|
|
|
})
|
|
|
|
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'
|
2019-08-22 04:21:49 +08:00
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2020-10-28 00:17:28 +08:00
|
|
|
opts = super().get_options()
|
2019-04-11 04:14:51 +08:00
|
|
|
c_stds = ['c89', 'c99', 'c11']
|
|
|
|
g_stds = ['gnu89', 'gnu99', 'gnu11']
|
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):
|
2019-04-11 04:14:51 +08:00
|
|
|
c_stds += ['c17']
|
|
|
|
g_stds += ['gnu17']
|
2019-08-22 04:21:49 +08:00
|
|
|
if version_compare(self.version, self._C18_VERSION):
|
2019-06-26 09:00:58 +08:00
|
|
|
c_stds += ['c18']
|
|
|
|
g_stds += ['gnu18']
|
2020-08-16 01:45:31 +08:00
|
|
|
if version_compare(self.version, self._C2X_VERSION):
|
|
|
|
c_stds += ['c2x']
|
|
|
|
g_stds += ['gnu2x']
|
2020-12-03 08:02:03 +08:00
|
|
|
opts[OptionKey('std', machine=self.for_machine, lang=self.language)].choices = ['none'] + c_stds + g_stds
|
2020-10-28 00:17:28 +08:00
|
|
|
return opts
|
|
|
|
|
|
|
|
|
|
|
|
class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler):
|
|
|
|
|
|
|
|
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
|
|
|
|
info: 'MachineInfo', exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
defines: T.Optional[T.Dict[str, str]] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, linker=linker, full_version=full_version)
|
|
|
|
ClangCompiler.__init__(self, defines)
|
|
|
|
default_warn_args = ['-Wall', '-Winvalid-pch']
|
|
|
|
self.warn_args = {'0': [],
|
|
|
|
'1': default_warn_args,
|
|
|
|
'2': default_warn_args + ['-Wextra'],
|
|
|
|
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
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():
|
|
|
|
opts.update({
|
2020-12-03 08:02:03 +08:00
|
|
|
OptionKey('winlibs', machine=self.for_machine, lang=self.language): coredata.UserArrayOption(
|
2019-06-13 06:08:45 +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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
std = options[OptionKey('std', machine=self.for_machine, lang=self.language)]
|
2017-06-23 07:42:41 +08:00
|
|
|
if std.value != 'none':
|
|
|
|
args.append('-std=' + std.value)
|
|
|
|
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.
|
2020-12-03 08:02:03 +08:00
|
|
|
libs = options[OptionKey('winlibs', machine=self.for_machine, lang=self.language)].value.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'
|
|
|
|
|
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', exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
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.')
|
2020-09-22 06:35:53 +08:00
|
|
|
ClangCCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
|
|
|
info, exe_wrapper=exe_wrapper, linker=linker,
|
|
|
|
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
|
|
|
|
'''
|
|
|
|
|
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', exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2019-08-22 04:12:30 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, 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'],
|
|
|
|
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2018-06-21 05:55:39 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
opts[key].choices = ['none', 'c90', 'c99', 'c11', 'gnu90', 'gnu99', 'gnu11']
|
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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
std = options[OptionKey('std', machine=self.for_machine, lang=self.language)]
|
2018-06-21 05:55:39 +08:00
|
|
|
if std.value != 'none':
|
|
|
|
args.append('-std=' + std.value)
|
|
|
|
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'
|
2021-11-16 12:33:36 +08:00
|
|
|
_INVALID_PCH_VERSION = ">=3.4.0"
|
2020-08-16 01:45:31 +08:00
|
|
|
|
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', exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
defines: T.Optional[T.Dict[str, str]] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, 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'],
|
|
|
|
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2018-05-13 22:36:58 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2019-04-11 04:14:51 +08:00
|
|
|
c_stds = ['c89', 'c99', 'c11']
|
|
|
|
g_stds = ['gnu89', 'gnu99', 'gnu11']
|
2020-08-16 01:45:31 +08:00
|
|
|
if version_compare(self.version, self._C18_VERSION):
|
2019-04-11 04:14:51 +08:00
|
|
|
c_stds += ['c17', 'c18']
|
|
|
|
g_stds += ['gnu17', 'gnu18']
|
2020-08-16 01:45:31 +08:00
|
|
|
if version_compare(self.version, self._C2X_VERSION):
|
|
|
|
c_stds += ['c2x']
|
|
|
|
g_stds += ['gnu2x']
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
opts[key].choices = ['none'] + c_stds + g_stds
|
2019-08-22 04:12:30 +08:00
|
|
|
if self.info.is_windows() or self.info.is_cygwin():
|
2017-06-23 07:42:41 +08:00
|
|
|
opts.update({
|
2020-12-03 08:02:03 +08:00
|
|
|
key.evolve('winlibs'): coredata.UserArrayOption(
|
2019-06-13 06:08:45 +08:00
|
|
|
'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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
std = options[OptionKey('std', lang=self.language, machine=self.for_machine)]
|
2017-06-23 07:42:41 +08:00
|
|
|
if std.value != 'none':
|
|
|
|
args.append('-std=' + std.value)
|
|
|
|
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
|
2020-12-03 08:02:03 +08:00
|
|
|
libs: T.List[str] = options[OptionKey('winlibs', lang=self.language, machine=self.for_machine)].value.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):
|
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', exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2019-08-22 04:12:30 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, 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'
|
|
|
|
|
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', exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2020-07-13 12:16:52 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, 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):
|
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', exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
defines: T.Optional[T.Dict[str, str]] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2021-09-29 04:26:31 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
|
|
|
info, exe_wrapper, 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
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
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']
|
|
|
|
opts[OptionKey('std', machine=self.for_machine, lang=self.language)].choices = ['none'] + 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):
|
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', exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2019-08-22 04:12:30 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, 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'
|
2018-11-13 08:32:56 +08:00
|
|
|
default_warn_args = ['-Wall', '-w3', '-diag-disable:remark']
|
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'],
|
2018-09-16 17:39:54 +08:00
|
|
|
'3': default_warn_args + ['-Wextra']}
|
2017-06-23 07:42:41 +08:00
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2018-05-13 22:36:58 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2017-06-23 07:42:41 +08:00
|
|
|
c_stds = ['c89', 'c99']
|
|
|
|
g_stds = ['gnu89', 'gnu99']
|
|
|
|
if version_compare(self.version, '>=16.0.0'):
|
|
|
|
c_stds += ['c11']
|
2020-12-03 08:02:03 +08:00
|
|
|
opts[OptionKey('std', machine=self.for_machine, lang=self.language)].choices = ['none'] + c_stds + g_stds
|
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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
std = options[OptionKey('std', machine=self.for_machine, lang=self.language)]
|
2017-06-23 07:42:41 +08:00
|
|
|
if std.value != 'none':
|
|
|
|
args.append('-std=' + std.value)
|
|
|
|
return args
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2019-05-01 01:53:39 +08:00
|
|
|
opts = super().get_options()
|
2019-06-13 06:08:45 +08:00
|
|
|
opts.update({
|
2020-12-03 08:02:03 +08:00
|
|
|
OptionKey('winlibs', machine=self.for_machine, lang=self.language): coredata.UserArrayOption(
|
2019-06-13 06:08:45 +08:00
|
|
|
'Windows libs to link against.',
|
|
|
|
msvc_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_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
2020-09-22 06:35:53 +08:00
|
|
|
# need a TypeDict to make this work
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('winlibs', machine=self.for_machine, lang=self.language)
|
|
|
|
libs = options[key].value.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'
|
|
|
|
|
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,
|
|
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2019-08-22 04:12:30 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, linker=linker,
|
|
|
|
full_version=full_version)
|
2020-01-07 05:49:01 +08:00
|
|
|
MSVCCompiler.__init__(self, target)
|
2018-10-14 11:00:38 +08:00
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2020-08-06 10:56:19 +08:00
|
|
|
opts = super().get_options()
|
2020-11-11 12:32:23 +08:00
|
|
|
c_stds = ['c89', 'c99']
|
2021-10-22 07:05:27 +08:00
|
|
|
# Need to have these to be compatible with projects
|
|
|
|
# that set c_std to e.g. gnu99.
|
|
|
|
# https://github.com/mesonbuild/meson/issues/7611
|
2020-11-11 12:32:23 +08:00
|
|
|
g_stds = ['gnu89', 'gnu90', 'gnu9x', 'gnu99']
|
|
|
|
if version_compare(self.version, self._C11_VERSION):
|
|
|
|
c_stds += ['c11']
|
|
|
|
g_stds += ['gnu1x', 'gnu11']
|
|
|
|
if version_compare(self.version, self._C17_VERSION):
|
|
|
|
c_stds += ['c17', 'c18']
|
|
|
|
g_stds += ['gnu17', 'gnu18']
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
opts[key].choices = ['none'] + c_stds + g_stds
|
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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
std = options[OptionKey('std', machine=self.for_machine, lang=self.language)]
|
2020-10-20 00:34:41 +08:00
|
|
|
if std.value.startswith('gnu'):
|
2020-11-11 12:32:23 +08:00
|
|
|
mlog.log_once(
|
2020-10-20 00:34:41 +08:00
|
|
|
'cl.exe does not actually support gnu standards, and meson '
|
|
|
|
'will instead demote to the nearest ISO C standard. This '
|
2020-11-11 12:32:23 +08:00
|
|
|
'may cause compilation to fail.')
|
|
|
|
# As of MVSC 16.8, /std:c11 and /std:c17 are the only valid C standard options.
|
|
|
|
if std.value in {'c11', 'gnu1x', 'gnu11'}:
|
2020-10-17 22:11:42 +08:00
|
|
|
args.append('/std:c11')
|
2020-11-11 12:32:23 +08:00
|
|
|
elif std.value in {'c17', 'c18', 'gnu17', 'gnu18'}:
|
|
|
|
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,
|
|
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2019-08-22 04:12:30 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, linker=linker,
|
|
|
|
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]:
|
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
std = options[key].value
|
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,
|
|
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2019-08-22 04:12:30 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, linker=linker,
|
|
|
|
full_version=full_version)
|
2019-05-01 06:53:50 +08:00
|
|
|
IntelVisualStudioLikeCompiler.__init__(self, target)
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2019-05-01 06:53:50 +08:00
|
|
|
opts = super().get_options()
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
opts[key].choices = ['none', '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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
std = options[key]
|
2019-05-01 06:53:50 +08:00
|
|
|
if std.value == 'c89':
|
2020-11-11 12:32:23 +08:00
|
|
|
mlog.log_once("ICL doesn't explicitly implement c89, setting the standard to 'none', which is close.")
|
2019-05-01 06:53:50 +08:00
|
|
|
elif std.value != 'none':
|
|
|
|
args.append('/Qstd:' + std.value)
|
|
|
|
return args
|
|
|
|
|
|
|
|
|
2018-03-15 21:03:11 +08:00
|
|
|
class ArmCCompiler(ArmCompiler, 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',
|
|
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2019-08-22 04:12:30 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, linker=linker,
|
|
|
|
full_version=full_version)
|
2019-08-22 04:12:30 +08:00
|
|
|
ArmCompiler.__init__(self)
|
2018-03-15 21:03:11 +08:00
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2018-05-13 22:36:58 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
opts[key].choices = ['none', '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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
std = options[key]
|
2018-03-15 21:03:11 +08:00
|
|
|
if std.value != 'none':
|
|
|
|
args.append('--' + std.value)
|
|
|
|
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):
|
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',
|
|
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2019-08-22 04:12:30 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, 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']
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2018-10-25 10:24:05 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
opts[key].choices = ['none', '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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
std = options[key]
|
2018-10-25 10:24:05 +08:00
|
|
|
if std.value == 'c89':
|
|
|
|
args.append('-lang=c')
|
|
|
|
elif std.value == 'c99':
|
|
|
|
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):
|
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',
|
|
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2020-03-21 04:13:42 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, linker=linker, full_version=full_version)
|
2020-03-21 04:13:42 +08:00
|
|
|
Xc16Compiler.__init__(self)
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2020-03-21 04:13:42 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
opts[key].choices = ['none', 'c89', 'c99', 'gnu89', 'gnu99']
|
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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
std = options[key]
|
2020-03-21 04:13:42 +08:00
|
|
|
if std.value != 'none':
|
|
|
|
args.append('-ansi')
|
|
|
|
args.append('-std=' + std.value)
|
|
|
|
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):
|
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',
|
|
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
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
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, 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)
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
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)
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
opts[key].choices = ['none', '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):
|
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',
|
|
|
|
exe_wrapper: T.Optional['ExternalProgram'] = None,
|
|
|
|
linker: T.Optional['DynamicLinker'] = None,
|
|
|
|
full_version: T.Optional[str] = None):
|
2020-03-21 04:13:42 +08:00
|
|
|
CCompiler.__init__(self, exelist, version, for_machine, is_cross,
|
2020-09-22 06:35:53 +08:00
|
|
|
info, exe_wrapper, 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 []
|
|
|
|
|
2020-12-03 08:02:03 +08:00
|
|
|
def get_options(self) -> 'KeyedOptionDictType':
|
2020-03-21 04:13:42 +08:00
|
|
|
opts = CCompiler.get_options(self)
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
opts[key].choices = ['none', '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 = []
|
2020-12-03 08:02:03 +08:00
|
|
|
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
|
|
std = options[key]
|
2020-03-21 04:13:42 +08:00
|
|
|
if std.value != 'none':
|
|
|
|
args.append('--' + std.value)
|
|
|
|
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'
|