summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorgerioldman <k.gergo49@gmail.com>2023-09-23 00:33:39 +0200
committergerioldman <k.gergo49@gmail.com>2025-01-08 01:52:03 +0100
commit62c5db2cb3809e584bd4faef5c0a9d112e36a29c (patch)
tree4a74e3e62377bfa54b7252ea78a67d598d9a26ae /mesonbuild/compilers
parenta05135fe94383e82147442d701f18c49dfc4ef00 (diff)
downloadmeson-62c5db2cb3809e584bd4faef5c0a9d112e36a29c.tar.gz
Add TASKING compiler support
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/c.py25
-rw-r--r--mesonbuild/compilers/compilers.py8
-rw-r--r--mesonbuild/compilers/detect.py43
-rw-r--r--mesonbuild/compilers/mixins/tasking.py126
4 files changed, 202 insertions, 0 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 5868211a6..b72c5b5d2 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -27,6 +27,7 @@ from .mixins.pgi import PGICompiler
from .mixins.emscripten import EmscriptenMixin
from .mixins.metrowerks import MetrowerksCompiler
from .mixins.metrowerks import mwccarm_instruction_set_args, mwcceppc_instruction_set_args
+from .mixins.tasking import TaskingCompiler
from .compilers import (
gnu_winlibs,
msvc_winlibs,
@@ -830,3 +831,27 @@ class MetrowerksCCompilerEmbeddedPowerPC(MetrowerksCompiler, CCompiler):
if std != 'none':
args.append('-lang ' + std)
return args
+
+class _TaskingCCompiler(TaskingCompiler, CCompiler):
+ 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,
+ info, linker=linker, full_version=full_version)
+ TaskingCompiler.__init__(self)
+
+class TaskingTricoreCCompiler(_TaskingCCompiler):
+ id = 'cctc'
+
+class TaskingArmCCompiler(_TaskingCCompiler):
+ id = 'ccarm'
+
+class Tasking8051CCompiler(_TaskingCCompiler):
+ id = 'cc51'
+
+class TaskingMCSCCompiler(_TaskingCCompiler):
+ id = 'ccmcs'
+
+class TaskingPCPCCompiler(_TaskingCCompiler):
+ id = 'ccpcp'
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 8788df0be..f8d4ac439 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -251,6 +251,7 @@ BASE_OPTIONS: T.Mapping[OptionKey, BaseOption] = {
OptionKey('b_bitcode'): BaseOption(options.UserBooleanOption, 'Generate and embed bitcode (only macOS/iOS/tvOS)', False),
OptionKey('b_vscrt'): BaseOption(options.UserComboOption, 'VS run-time library type to use.', 'from_buildtype',
choices=MSCRT_VALS + ['from_buildtype', 'static_from_buildtype']),
+ OptionKey('b_tasking_mil_link'): BaseOption(options.UserBooleanOption, 'Use TASKING compiler families MIL linking feature', False),
}
base_options = {key: base_opt.init_option(key) for key, base_opt in BASE_OPTIONS.items()}
@@ -1353,6 +1354,13 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def form_compileropt_key(self, basename: str) -> OptionKey:
return OptionKey(f'{self.language}_{basename}', machine=self.for_machine)
+ def get_tasking_mil_link_args(self, option_enabled: bool) -> T.List[str]:
+ """
+ Argument for enabling TASKING's MIL link feature,
+ for most compilers, this will return nothing.
+ """
+ return []
+
def get_global_options(lang: str,
comp: T.Type[Compiler],
for_machine: MachineChoice,
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index d88441dff..a528acbf3 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -240,6 +240,17 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker
return linkers.MetrowerksStaticLinkerARM(linker)
else:
return linkers.MetrowerksStaticLinkerEmbeddedPowerPC(linker)
+ if 'TASKING VX-toolset' in err:
+ if 'TriCore' in err:
+ return linkers.TaskingTricoreStaticLinker(linker)
+ if 'ARM' in err:
+ return linkers.TaskingARMStaticLinker(linker)
+ if '8051' in err:
+ return linkers.Tasking8051StaticLinker(linker)
+ if 'PCP' in err:
+ return linkers.TaskingPCPStaticLinker(linker)
+ else:
+ return linkers.TaskingMCSStaticLinker(linker)
if p.returncode == 0:
return linkers.ArLinker(compiler.for_machine, linker)
if p.returncode == 1 and err.startswith('usage'): # OSX
@@ -605,6 +616,38 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin
return cls(
ccache, compiler, compiler_version, for_machine, is_cross, info,
full_version=full_version, linker=linker)
+ if 'TASKING VX-toolset' in err:
+ if 'TriCore' in err or 'AURIX Development Studio' in err:
+ cls = c.TaskingTricoreCCompiler
+ lnk = linkers.TaskingTricoreLinker
+ elif 'ARM' in err:
+ cls = c.TaskingArmCCompiler
+ lnk = linkers.TaskingARMLinker
+ elif '8051' in err:
+ cls = c.Tasking8051CCompiler
+ lnk = linkers.Tasking8051Linker
+ elif 'PCP' in err:
+ cls = c.TaskingPCPCCompiler
+ lnk = linkers.TaskingPCPLinker
+ elif 'MCS' in err:
+ cls = c.TaskingMCSCCompiler
+ lnk = linkers.TaskingMCSLinker
+ else:
+ raise EnvironmentException('Failed to detect linker for TASKING VX-toolset compiler. Please update your cross file(s).')
+
+ tasking_ver_match = re.search(r'v([0-9]+)\.([0-9]+)r([0-9]+) Build ([0-9]+)', err)
+ assert tasking_ver_match is not None, 'for mypy'
+ tasking_version = '.'.join(x for x in tasking_ver_match.groups() if x is not None)
+
+ env.coredata.add_lang_args(cls.language, cls, for_machine, env)
+ ld = env.lookup_binary_entry(for_machine, cls.language + '_ld')
+ if ld is None:
+ raise MesonException(f'{cls.language}_ld was not properly defined in your cross file')
+
+ linker = lnk(ld, for_machine, version=tasking_version)
+ return cls(
+ ccache, compiler, tasking_version, for_machine, is_cross, info,
+ full_version=full_version, linker=linker)
_handle_exceptions(popen_exceptions, compilers)
raise EnvironmentException(f'Unknown compiler {compilers}')
diff --git a/mesonbuild/compilers/mixins/tasking.py b/mesonbuild/compilers/mixins/tasking.py
new file mode 100644
index 000000000..7675dbc75
--- /dev/null
+++ b/mesonbuild/compilers/mixins/tasking.py
@@ -0,0 +1,126 @@
+# SPDX-License-Identifier: Apache-2.0
+# Copyright 2012-2023 The Meson development team
+from __future__ import annotations
+
+"""Representations specific to the TASKING embedded C/C++ compiler family."""
+
+import os
+import typing as T
+
+from ...mesonlib import EnvironmentException
+from ...options import OptionKey
+
+if T.TYPE_CHECKING:
+ from ...compilers.compilers import Compiler
+else:
+ # This is a bit clever, for mypy we pretend that these mixins descend from
+ # Compiler, so we get all of the methods and attributes defined for us, but
+ # for runtime we make them descend from object (which all classes normally
+ # do). This gives us DRYer type checking, with no runtime impact
+ Compiler = object
+
+tasking_buildtype_args: T.Mapping[str, T.List[str]] = {
+ 'plain': [],
+ 'debug': [],
+ 'debugoptimized': [],
+ 'release': [],
+ 'minsize': [],
+ 'custom': []
+}
+
+tasking_optimization_args: T.Mapping[str, T.List[str]] = {
+ 'plain': [],
+ '0': ['-O0'],
+ 'g': ['-O1'], # There is no debug specific level, O1 is recommended by the compiler
+ '1': ['-O1'],
+ '2': ['-O2'],
+ '3': ['-O3'],
+ 's': ['-Os']
+}
+
+tasking_debug_args: T.Mapping[bool, T.List[str]] = {
+ False: [],
+ True: ['-g3']
+}
+
+class TaskingCompiler(Compiler):
+ '''
+ Functionality that is common to all TASKING family compilers.
+ '''
+
+ LINKER_PREFIX = '-Wl'
+
+ def __init__(self) -> None:
+ if not self.is_cross:
+ raise EnvironmentException(f'{id} supports only cross-compilation.')
+
+ self.base_options = {
+ OptionKey(o) for o in [
+ 'b_tasking_mil_link',
+ 'b_staticpic',
+ 'b_ndebug'
+ ]
+ }
+
+ default_warn_args = [] # type: T.List[str]
+ self.warn_args = {'0': [],
+ '1': default_warn_args,
+ '2': default_warn_args + [],
+ '3': default_warn_args + [],
+ 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]]
+ # TODO: add additional compilable files so that meson can detect it
+ self.can_compile_suffixes.add('asm')
+
+ def get_pic_args(self) -> T.List[str]:
+ return ['--pic']
+
+ def get_buildtype_args(self, buildtype: str) -> T.List[str]:
+ return tasking_buildtype_args[buildtype]
+
+ def get_debug_args(self, is_debug: bool) -> T.List[str]:
+ return tasking_debug_args[is_debug]
+
+ def get_compile_only_args(self) -> T.List[str]:
+ return ['-c']
+
+ def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
+ return [f'--dep-file={outfile}']
+
+ def get_depfile_suffix(self) -> str:
+ return 'dep'
+
+ def get_no_stdinc_args(self) -> T.List[str]:
+ return ['--no-stdinc']
+
+ def get_werror_args(self) -> T.List[str]:
+ return ['--warnings-as-errors']
+
+ def get_no_stdlib_link_args(self) -> T.List[str]:
+ return ['--no-default-libraries']
+
+ def get_output_args(self, outputname: str) -> T.List[str]:
+ return ['-o', outputname]
+
+ def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
+ if path == '':
+ path = '.'
+ return ['-I' + path]
+
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
+ return tasking_optimization_args[optimization_level]
+
+ def get_no_optimization_args(self) -> T.List[str]:
+ return ['-O0']
+
+ def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], build_dir: str) -> T.List[str]:
+ for idx, i in enumerate(parameter_list):
+ if i[:2] == '-I' or i[:2] == '-L':
+ parameter_list[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:]))
+
+ return parameter_list
+
+ def get_tasking_mil_link_args(self, option_enabled: bool) -> T.List[str]:
+ return ['--mil-link'] if option_enabled else []
+
+ def get_preprocess_only_args(self) -> T.List[str]:
+ return ['-E']