Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the TASKING compiler family, and its MIL linking feature #12342

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/markdown/Reference-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ These are return values of the `get_id` (Compiler family) and
| armasm | Microsoft Macro Assembler for ARM and AARCH64 (Since 0.64.0) | |
| mwasmarm | Metrowerks Assembler for Embedded ARM | |
| mwasmeppc | Metrowerks Assembler for Embedded PowerPC | |
| cctc | TASKING VX-toolset for TriCore compiler | |
| ccarm | TASKING VX-toolset for ARM compiler | |
| cc51 | TASKING VX-toolset for 8051 compiler | |
| ccmcs | TASKING VX-toolset for MCS compiler | |
| ccpcp | TASKING VX-toolset for PCP compiler | |

## Linker ids

Expand Down Expand Up @@ -80,6 +85,11 @@ These are return values of the `get_linker_id` method in a compiler object.
| ccomp | CompCert used as the linker driver |
| mwldarm | The Metrowerks Linker with the ARM interface, used with mwccarm only |
| mwldeppc | The Metrowerks Linker with the PowerPC interface, used with mwcceppc only |
| ltc | TASKING VX-toolset for TriCore linker |
| lkarm | TASKING VX-toolset for ARM linker |
| lk51 | TASKING VX-toolset for 8051 linker |
| lmsc | TASKING VX-toolset for MCS linker |
| lpcp | TASKING VX-toolset for PCP linker |

For languages that don't have separate dynamic linkers such as C# and Java, the
`get_linker_id` will return the compiler name.
Expand Down Expand Up @@ -139,6 +149,7 @@ set in the cross file.
| wasm64 | 64 bit Webassembly |
| x86 | 32 bit x86 processor |
| x86_64 | 64 bit x86 processor |
| tricore | Tricore 32 bit processor |


Any cpu family not listed in the above list is not guaranteed to
Expand Down
11 changes: 8 additions & 3 deletions mesonbuild/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .. import mesonlib
from .. import mlog
from ..compilers import LANGUAGES_USING_LDFLAGS, detect
from ..utils.universal import get_compiler_for_source

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'get_compiler_for_source' may not be defined if module
mesonbuild.utils.universal
is imported before module
mesonbuild.backend.backends
, as the
definition
of get_compiler_for_source occurs after the cyclic
import
of mesonbuild.backend.backends.
'get_compiler_for_source' may not be defined if module
mesonbuild.utils.universal
is imported before module
mesonbuild.backend.backends
, as the
definition
of get_compiler_for_source occurs after the cyclic
import
of mesonbuild.backend.backends.
'get_compiler_for_source' may not be defined if module
mesonbuild.utils.universal
is imported before module
mesonbuild.backend.backends
, as the
definition
of get_compiler_for_source occurs after the cyclic
import
of mesonbuild.backend.backends.
'get_compiler_for_source' may not be defined if module
mesonbuild.utils.universal
is imported before module
mesonbuild.backend.backends
, as the
definition
of get_compiler_for_source occurs after the cyclic
import
of mesonbuild.backend.backends.
'get_compiler_for_source' may not be defined if module
mesonbuild.utils.universal
is imported before module
mesonbuild.backend.backends
, as the
definition
of get_compiler_for_source occurs after the cyclic
import
of mesonbuild.backend.backends.
'get_compiler_for_source' may not be defined if module
mesonbuild.utils.universal
is imported before module
mesonbuild.backend.backends
, as the
definition
of get_compiler_for_source occurs after the cyclic
import
of mesonbuild.backend.backends.
'get_compiler_for_source' may not be defined if module
mesonbuild.utils.universal
is imported before module
mesonbuild.backend.backends
, as the
definition
of get_compiler_for_source occurs after the cyclic
import
of mesonbuild.backend.backends.
from ..mesonlib import (
File, MachineChoice, MesonException, OrderedSet,
ExecutableSerialisation, classify_unity_sources,
Expand Down Expand Up @@ -836,7 +837,7 @@
fname = fname.replace(ch, '_')
return hashed + fname

def object_filename_from_source(self, target: build.BuildTarget, source: 'FileOrString', targetdir: T.Optional[str] = None) -> str:
def object_filename_from_source(self, target: build.BuildTarget, compiler: Compiler, source: 'FileOrString', targetdir: T.Optional[str] = None) -> str:
assert isinstance(source, mesonlib.File)
if isinstance(target, build.CompileTarget):
return target.sources_map[source]
Expand Down Expand Up @@ -867,7 +868,10 @@
gen_source = os.path.relpath(os.path.join(build_dir, rel_src),
os.path.join(self.environment.get_source_dir(), target.get_subdir()))
machine = self.environment.machines[target.for_machine]
ret = self.canonicalize_filename(gen_source) + '.' + machine.get_object_suffix()
object_suffix = machine.get_object_suffix()
object_suffix_override = compiler.get_object_suffix_override(target, source)
object_suffix = object_suffix if object_suffix_override is None else object_suffix_override
ret = self.canonicalize_filename(gen_source) + '.' + object_suffix
if targetdir is not None:
return os.path.join(targetdir, ret)
return ret
Expand Down Expand Up @@ -924,7 +928,8 @@
sources.append(_src)

for osrc in sources:
objname = self.object_filename_from_source(extobj.target, osrc, targetdir)
compiler = get_compiler_for_source(extobj.target.compilers.values(), osrc)
objname = self.object_filename_from_source(extobj.target, compiler, osrc, targetdir)
objpath = os.path.join(proj_dir_to_build_root, objname)
result.append(objpath)

Expand Down
77 changes: 68 additions & 9 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def _quoter(x: NinjaCommandArg, qf: T.Callable[[str], str] = quote_func) -> str:
def write(self, outfile: T.TextIO) -> None:
rspfile_args = self.args
rspfile_quote_func: T.Callable[[str], str]
if self.rspfile_quote_style is RSPFileSyntax.MSVC:
if self.rspfile_quote_style in {RSPFileSyntax.MSVC, RSPFileSyntax.TASKING}:
rspfile_quote_func = cmd_quote
rspfile_args = [NinjaCommandArg('$in_newline', arg.quoting) if arg.s == '$in' else arg for arg in rspfile_args]
else:
Expand All @@ -260,7 +260,10 @@ def rule_iter() -> T.Iterable[str]:
for rsp in rule_iter():
outfile.write(f'rule {self.name}{rsp}\n')
if rsp == '_RSP':
outfile.write(' command = {} @$out.rsp\n'.format(' '.join([self._quoter(x) for x in self.command])))
if self.rspfile_quote_style is RSPFileSyntax.TASKING:
outfile.write(' command = {} --option-file=$out.rsp\n'.format(' '.join([self._quoter(x) for x in self.command])))
else:
outfile.write(' command = {} @$out.rsp\n'.format(' '.join([self._quoter(x) for x in self.command])))
outfile.write(' rspfile = $out.rsp\n')
outfile.write(' rspfile_content = {}\n'.format(' '.join([self._quoter(x, rspfile_quote_func) for x in rspfile_args])))
else:
Expand Down Expand Up @@ -412,7 +415,7 @@ def write(self, outfile: T.TextIO) -> None:
outfile.write(line)

if use_rspfile:
if self.rule.rspfile_quote_style is RSPFileSyntax.MSVC:
if self.rule.rspfile_quote_style in {RSPFileSyntax.MSVC, RSPFileSyntax.TASKING}:
qf = cmd_quote
else:
qf = gcc_rsp_quote
Expand Down Expand Up @@ -729,6 +732,12 @@ def generate_compdb(self) -> None:
for ext in ['', '_RSP']]
rules += [f"{rule}{ext}" for rule in [self.compiler_to_pch_rule_name(compiler)]
for ext in ['', '_RSP']]
# Add custom MIL link rules to get the files compiled by the TASKING compiler family to MIL files included in the database
key = OptionKey('b_tasking_mil_link')
if key in compiler.base_options:
rule = self.get_compiler_rule_name('tasking_mil_compile', compiler.for_machine)
rules.append(rule)
rules.append(f'{rule}_RSP')
compdb_options = ['-x'] if mesonlib.version_compare(self.ninja_version, '>=1.9') else []
ninja_compdb = self.ninja_command + ['-t', 'compdb'] + compdb_options + rules
builddir = self.environment.get_build_dir()
Expand Down Expand Up @@ -1074,7 +1083,10 @@ def generate_target(self, target) -> None:
# Skip the link stage for this special type of target
return
linker, stdlib_args = self.determine_linker_and_stdlib_args(target)
if isinstance(target, build.StaticLibrary) and target.prelink:

if not isinstance(target, build.StaticLibrary):
final_obj_list = obj_list
elif target.prelink:
final_obj_list = self.generate_prelink(target, obj_list)
else:
final_obj_list = obj_list
Expand Down Expand Up @@ -2479,6 +2491,33 @@ def generate_llvm_ir_compile_rule(self, compiler) -> None:
self.add_rule(NinjaRule(rule, command, args, description, **options))
self.created_llvm_ir_rule[compiler.for_machine] = True

def generate_tasking_mil_compile_rules(self, compiler: Compiler) -> None:
rule = self.get_compiler_rule_name('tasking_mil_compile', compiler.for_machine)
depargs = NinjaCommandArg.list(compiler.get_dependency_gen_args('$out', '$DEPFILE'), Quoting.none)
command = compiler.get_exelist()
args = ['$ARGS'] + depargs + NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none) + ['-cm', '$in']
description = 'Compiling to C object $in'
if compiler.get_argument_syntax() == 'msvc':
deps = 'msvc'
depfile = None
else:
deps = 'gcc'
depfile = '$DEPFILE'

options = self._rsp_options(compiler)

self.add_rule(NinjaRule(rule, command, args, description, **options, deps=deps, depfile=depfile))

def generate_tasking_mil_link_rules(self, compiler: Compiler) -> None:
rule = self.get_compiler_rule_name('tasking_mil_link', compiler.for_machine)
command = compiler.get_exelist()
args = ['$ARGS', '--mil-link'] + NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none) + ['-c', '$in']
description = 'MIL linking object $out'

options = self._rsp_options(compiler)

self.add_rule(NinjaRule(rule, command, args, description, **options))

def generate_compile_rule_for(self, langname: str, compiler: Compiler) -> None:
if langname == 'java':
self.generate_java_compile_rule(compiler)
Expand Down Expand Up @@ -2569,6 +2608,8 @@ def generate_compile_rules(self) -> None:
for langname, compiler in clist.items():
if compiler.get_id() == 'clang':
self.generate_llvm_ir_compile_rule(compiler)
if compiler.get_id() in {'cctc', 'ccarm', 'cc51', 'ccmcs', 'ccpcp'}:
self.generate_tasking_mil_compile_rules(compiler)
self.generate_compile_rule_for(langname, compiler)
self.generate_pch_rule_for(langname, compiler)
for mode in compiler.get_modes():
Expand Down Expand Up @@ -3008,7 +3049,7 @@ def generate_single_compile(self, target: build.BuildTarget, src,
raise AssertionError(f'BUG: broken generated source file handling for {src!r}')
else:
raise InvalidArguments(f'Invalid source type: {src!r}')
obj_basename = self.object_filename_from_source(target, src)
obj_basename = self.object_filename_from_source(target, compiler, src)
rel_obj = os.path.join(self.get_target_private_dir(target), obj_basename)
dep_file = compiler.depfile_for_object(rel_obj)

Expand All @@ -3029,8 +3070,17 @@ def generate_single_compile(self, target: build.BuildTarget, src,
i = os.path.join(self.get_target_private_dir(target), compiler.get_pch_name(pchlist[0]))
arr.append(i)
pch_dep = arr

compiler_name = self.compiler_to_rule_name(compiler)
# If TASKING compiler family is used and MIL linking is enabled for the target,
# then compilation rule name is a special one to output MIL files
# instead of object files for .c files
key = OptionKey('b_lto')
if compiler.get_id() in {'cctc', 'ccarm', 'cc51', 'ccmcs', 'ccpcp'}:
if ((isinstance(target, build.StaticLibrary) and target.prelink) or target.get_option(key)) and src.rsplit('.', 1)[1] in compilers.lang_suffixes['c']:
compiler_name = self.get_compiler_rule_name('tasking_mil_compile', compiler.for_machine)
else:
compiler_name = self.compiler_to_rule_name(compiler)
else:
compiler_name = self.compiler_to_rule_name(compiler)
extra_deps = []
if compiler.get_language() == 'fortran':
# Can't read source file to scan for deps if it's generated later
Expand Down Expand Up @@ -3407,13 +3457,19 @@ def generate_prelink(self, target, obj_list):

prelinker = target.get_prelinker()
cmd = prelinker.exelist[:]
cmd += prelinker.get_prelink_args(prelink_name, obj_list)
obj_list, args = prelinker.get_prelink_args(target, prelink_name, obj_list)
cmd += args
if prelinker.get_prelink_append_compile_args():
compile_args = self._generate_single_compile_base_args(target, prelinker)
compile_args += self._generate_single_compile_target_args(target, prelinker)
compile_args = compile_args.compiler.compiler_args(compile_args)
cmd += compile_args.to_native()

cmd = self.replace_paths(target, cmd)
elem.add_item('COMMAND', cmd)
elem.add_item('description', f'Prelinking {prelink_name}')
self.add_build(elem)
return [prelink_name]
return obj_list

def generate_link(self, target: build.BuildTarget, outname, obj_list, linker: T.Union['Compiler', 'StaticLinker'], extra_args=None, stdlib_args=None):
extra_args = extra_args if extra_args is not None else []
Expand Down Expand Up @@ -3446,6 +3502,9 @@ def generate_link(self, target: build.BuildTarget, outname, obj_list, linker: T.
linker,
isinstance(target, build.SharedModule),
self.environment.get_build_dir())
# Add --mil-link if the option is enabled
if isinstance(target, build.Executable) and 'c' in target.compilers and OptionKey('b_tasking_mil_link') in target.get_options():
commands += target.compilers['c'].get_tasking_mil_link_args(target.get_option(OptionKey('b_tasking_mil_link')))
# Add -nostdlib if needed; can't be overridden
commands += self.get_no_stdlib_link_args(target, linker)
# Add things like /NOLOGO; usually can't be overridden
Expand Down
4 changes: 2 additions & 2 deletions mesonbuild/backend/vs2010backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ def path_normalize_add(path, lis):
self.add_preprocessor_defines(lang, inc_cl, file_defines)
self.add_include_dirs(lang, inc_cl, file_inc_dirs)
ET.SubElement(inc_cl, 'ObjectFileName').text = "$(IntDir)" + \
self.object_filename_from_source(target, s)
self.object_filename_from_source(target, compiler, s)
for s in gen_src:
if path_normalize_add(s, previous_sources):
inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=s)
Expand All @@ -1739,7 +1739,7 @@ def path_normalize_add(path, lis):
self.add_include_dirs(lang, inc_cl, file_inc_dirs)
s = File.from_built_file(target.get_subdir(), s)
ET.SubElement(inc_cl, 'ObjectFileName').text = "$(IntDir)" + \
self.object_filename_from_source(target, s)
self.object_filename_from_source(target, compiler, s)
for lang, headers in pch_sources.items():
impl = headers[1]
if impl and path_normalize_add(impl, previous_sources):
Expand Down
7 changes: 6 additions & 1 deletion mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

from . import environment
from ._typing import ImmutableListProtocol
from .backend.backends import Backend

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
'Backend' may not be defined if module
mesonbuild.backend.backends
is imported before module
mesonbuild.build
, as the
definition
of Backend occurs after the cyclic
import
of mesonbuild.build.
from .compilers import Compiler
from .interpreter.interpreter import SourceOutputs, Interpreter
from .interpreter.interpreterobjects import Test
Expand Down Expand Up @@ -2008,6 +2008,8 @@
elif ('c' in self.compilers and self.compilers['c'].get_id() in {'mwccarm', 'mwcceppc'} or
'cpp' in self.compilers and self.compilers['cpp'].get_id() in {'mwccarm', 'mwcceppc'}):
self.suffix = 'nef'
elif ('c' in self.compilers and self.compilers['c'].get_id() in {'cctc', 'ccarm', 'cc51', 'ccmcs', 'ccpcp'}):
self.suffix = 'elf'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you found this, good. :)

else:
self.suffix = machine.get_exe_suffix()
self.filename = self.name
Expand Down Expand Up @@ -2163,7 +2165,10 @@
elif self.rust_crate_type == 'staticlib':
self.suffix = 'a'
else:
self.suffix = 'a'
if 'c' in self.compilers and self.compilers['c'].get_id() in {'cctc', 'ccarm', 'cc51', 'ccmcs', 'ccpcp'}:
self.suffix = 'ma' if self.options.get_value('b_lto') and not self.prelink else 'a'
else:
self.suffix = 'a'
self.filename = self.prefix + self.name + '.' + self.suffix
self.outputs[0] = self.filename

Expand Down
25 changes: 25 additions & 0 deletions mesonbuild/compilers/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .. import mlog
from ..mesonlib import MesonException, version_compare
from .c_function_attributes import C_FUNC_ATTRIBUTES
from .mixins.apple import AppleCompilerMixin

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'AppleCompilerMixin' may not be defined if module
mesonbuild.compilers.mixins.apple
is imported before module
mesonbuild.compilers.c
, as the
definition
of AppleCompilerMixin occurs after the cyclic
import
of mesonbuild.compilers.c.
'AppleCompilerMixin' may not be defined if module
mesonbuild.compilers.mixins.apple
is imported before module
mesonbuild.compilers.c
, as the
definition
of AppleCompilerMixin occurs after the cyclic
import
of mesonbuild.compilers.c.
'AppleCompilerMixin' may not be defined if module
mesonbuild.compilers.mixins.apple
is imported before module
mesonbuild.compilers.c
, as the
definition
of AppleCompilerMixin occurs after the cyclic
import
of mesonbuild.compilers.c.
'AppleCompilerMixin' may not be defined if module
mesonbuild.compilers.mixins.apple
is imported before module
mesonbuild.compilers.c
, as the
definition
of AppleCompilerMixin occurs after the cyclic
import
of mesonbuild.compilers.c.
from .mixins.clike import CLikeCompiler
from .mixins.ccrx import CcrxCompiler
from .mixins.xc16 import Xc16Compiler
Expand All @@ -18,15 +18,16 @@
from .mixins.ti import TICompiler
from .mixins.arm import ArmCompiler, ArmclangCompiler
from .mixins.visualstudio import MSVCCompiler, ClangClCompiler
from .mixins.gnu import GnuCompiler

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'GnuCompiler' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of GnuCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'GnuCompiler' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of GnuCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'GnuCompiler' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of GnuCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'GnuCompiler' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of GnuCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'GnuCompiler' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of GnuCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'GnuCompiler' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of GnuCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'GnuCompiler' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of GnuCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
from .mixins.gnu import gnu_common_warning_args, gnu_c_warning_args

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'gnu_common_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_common_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_common_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_common_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_common_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_common_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_common_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_common_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_common_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_common_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_common_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_common_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_common_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_common_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'gnu_c_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_c_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_c_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_c_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_c_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_c_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_c_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_c_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_c_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_c_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_c_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_c_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
'gnu_c_warning_args' may not be defined if module
mesonbuild.compilers.mixins.gnu
is imported before module
mesonbuild.compilers.c
, as the
definition
of gnu_c_warning_args occurs after the cyclic
import
of mesonbuild.compilers.c.
from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler
from .mixins.clang import ClangCompiler
from .mixins.elbrus import ElbrusCompiler

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'ElbrusCompiler' may not be defined if module
mesonbuild.compilers.mixins.elbrus
is imported before module
mesonbuild.compilers.c
, as the
definition
of ElbrusCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'ElbrusCompiler' may not be defined if module
mesonbuild.compilers.mixins.elbrus
is imported before module
mesonbuild.compilers.c
, as the
definition
of ElbrusCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'ElbrusCompiler' may not be defined if module
mesonbuild.compilers.mixins.elbrus
is imported before module
mesonbuild.compilers.c
, as the
definition
of ElbrusCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'ElbrusCompiler' may not be defined if module
mesonbuild.compilers.mixins.elbrus
is imported before module
mesonbuild.compilers.c
, as the
definition
of ElbrusCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'ElbrusCompiler' may not be defined if module
mesonbuild.compilers.mixins.elbrus
is imported before module
mesonbuild.compilers.c
, as the
definition
of ElbrusCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'ElbrusCompiler' may not be defined if module
mesonbuild.compilers.mixins.elbrus
is imported before module
mesonbuild.compilers.c
, as the
definition
of ElbrusCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'ElbrusCompiler' may not be defined if module
mesonbuild.compilers.mixins.elbrus
is imported before module
mesonbuild.compilers.c
, as the
definition
of ElbrusCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
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

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'TaskingCompiler' may not be defined if module
mesonbuild.compilers.mixins.tasking
is imported before module
mesonbuild.compilers.c
, as the
definition
of TaskingCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'TaskingCompiler' may not be defined if module
mesonbuild.compilers.mixins.tasking
is imported before module
mesonbuild.compilers.c
, as the
definition
of TaskingCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'TaskingCompiler' may not be defined if module
mesonbuild.compilers.mixins.tasking
is imported before module
mesonbuild.compilers.c
, as the
definition
of TaskingCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
'TaskingCompiler' may not be defined if module
mesonbuild.compilers.mixins.tasking
is imported before module
mesonbuild.compilers.c
, as the
definition
of TaskingCompiler occurs after the cyclic
import
of mesonbuild.compilers.c.
from .compilers import (
gnu_winlibs,
msvc_winlibs,
Expand Down Expand Up @@ -830,3 +831,27 @@
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'
11 changes: 9 additions & 2 deletions mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ class CompileResult(HoldableObject):
output_name: T.Optional[str] = field(default=None, init=False)
cached: bool = field(default=False, init=False)


class Compiler(HoldableObject, metaclass=abc.ABCMeta):

# Libraries to ignore in find_library() since they are provided by the
# compiler or the C library. Currently only used for MSVC.
ignore_libs: T.List[str] = []
Expand Down Expand Up @@ -1323,9 +1323,13 @@ def get_feature_args(self, kwargs: DFeatures, build_to_src: str) -> T.List[str]:
# TODO: using a TypeDict here would improve this
raise EnvironmentException(f'{self.id} does not implement get_feature_args')

def get_prelink_args(self, prelink_name: str, obj_list: T.List[str]) -> T.List[str]:
def get_prelink_args(self, target: BuildTarget, prelink_name: str, obj_list: T.List[str]) -> T.Tuple[T.List[str], T.List[str]]:
raise EnvironmentException(f'{self.id} does not know how to do prelinking.')

def get_prelink_append_compile_args(self) -> bool:
"""Controls whether compile args have to be used for prelinking or not"""
return False

def rsp_file_syntax(self) -> 'RSPFileSyntax':
"""The format of the RSP file that this compiler supports.

Expand All @@ -1349,6 +1353,9 @@ def get_preprocessor(self) -> Compiler:
def form_compileropt_key(self, basename: str) -> OptionKey:
return OptionKey(f'{self.language}_{basename}', machine=self.for_machine)

def get_object_suffix_override(self, target: BuildTarget, source: mesonlib.File) -> T.Optional[str]:
return None

def get_global_options(lang: str,
comp: T.Type[Compiler],
for_machine: MachineChoice,
Expand Down
Loading
Loading