Only try to get RSP syntax if RSP is supported (#8804)

pull/8319/head
Dylan Baker 4 years ago committed by GitHub
parent 25fa2d4f7b
commit c6ec13e6bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      mesonbuild/backend/ninjabackend.py
  2. 2
      mesonbuild/linkers.py

@ -1840,6 +1840,17 @@ int dummy;
# Introspection information # Introspection information
self.create_target_source_introspection(target, swiftc, compile_args + header_imports + module_includes, relsrc, rel_generated) self.create_target_source_introspection(target, swiftc, compile_args + header_imports + module_includes, relsrc, rel_generated)
def _rsp_options(self, tool: T.Union['Compiler', 'StaticLinker', 'DynamicLinker']) -> T.Dict[str, T.Union[bool, RSPFileSyntax]]:
"""Helper method to get rsp options.
rsp_file_syntax() is only guaranteed to be implemented if
can_linker_accept_rsp() returns True.
"""
options = dict(rspable=tool.can_linker_accept_rsp())
if options['rspable']:
options['rspfile_quote_style'] = tool.rsp_file_syntax()
return options
def generate_static_link_rules(self): def generate_static_link_rules(self):
num_pools = self.environment.coredata.options[OptionKey('backend_max_links')].value num_pools = self.environment.coredata.options[OptionKey('backend_max_links')].value
if 'java' in self.environment.coredata.compilers.host: if 'java' in self.environment.coredata.compilers.host:
@ -1868,10 +1879,9 @@ int dummy;
pool = 'pool = link_pool' pool = 'pool = link_pool'
else: else:
pool = None pool = None
self.add_rule(NinjaRule(rule, cmdlist, args, description,
rspable=static_linker.can_linker_accept_rsp(), options = self._rsp_options(static_linker)
rspfile_quote_style=static_linker.rsp_file_syntax(), self.add_rule(NinjaRule(rule, cmdlist, args, description, **options, extra=pool))
extra=pool))
def generate_dynamic_link_rules(self): def generate_dynamic_link_rules(self):
num_pools = self.environment.coredata.options[OptionKey('backend_max_links')].value num_pools = self.environment.coredata.options[OptionKey('backend_max_links')].value
@ -1891,10 +1901,9 @@ int dummy;
pool = 'pool = link_pool' pool = 'pool = link_pool'
else: else:
pool = None pool = None
self.add_rule(NinjaRule(rule, command, args, description,
rspable=compiler.can_linker_accept_rsp(), options = self._rsp_options(compiler)
rspfile_quote_style=compiler.rsp_file_syntax(), self.add_rule(NinjaRule(rule, command, args, description, **options, extra=pool))
extra=pool))
args = self.environment.get_build_command() + \ args = self.environment.get_build_command() + \
['--internal', ['--internal',
@ -1977,8 +1986,10 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
command = compiler.get_exelist() command = compiler.get_exelist()
args = ['$ARGS'] + NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none) + compiler.get_compile_only_args() + ['$in'] args = ['$ARGS'] + NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none) + compiler.get_compile_only_args() + ['$in']
description = 'Compiling LLVM IR object $in' description = 'Compiling LLVM IR object $in'
self.add_rule(NinjaRule(rule, command, args, description,
rspable=compiler.can_linker_accept_rsp())) options = self._rsp_options(compiler)
self.add_rule(NinjaRule(rule, command, args, description, **options))
self.created_llvm_ir_rule[compiler.for_machine] = True self.created_llvm_ir_rule[compiler.for_machine] = True
def generate_compile_rule_for(self, langname, compiler): def generate_compile_rule_for(self, langname, compiler):
@ -2014,9 +2025,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
else: else:
deps = 'gcc' deps = 'gcc'
depfile = '$DEPFILE' depfile = '$DEPFILE'
self.add_rule(NinjaRule(rule, command, args, description, options = self._rsp_options(compiler)
rspable=compiler.can_linker_accept_rsp(), self.add_rule(NinjaRule(rule, command, args, description, **options,
rspfile_quote_style=compiler.rsp_file_syntax(),
deps=deps, depfile=depfile)) deps=deps, depfile=depfile))
def generate_pch_rule_for(self, langname, compiler): def generate_pch_rule_for(self, langname, compiler):

@ -112,7 +112,7 @@ class StaticLinker:
be implemented be implemented
""" """
assert not self.can_linker_accept_rsp(), f'{self.id} linker accepts RSP, but doesn\' provide a supported format, this is a bug' assert not self.can_linker_accept_rsp(), f'{self.id} linker accepts RSP, but doesn\' provide a supported format, this is a bug'
raise mesonlib.EnvironmentException(f'{self.id} does no implemnt rsp format, this shouldn\'t be called') raise mesonlib.EnvironmentException(f'{self.id} does not implemnt rsp format, this shouldn\'t be called')
class VisualStudioLikeLinker: class VisualStudioLikeLinker:

Loading…
Cancel
Save