Repository: mesonbuild/meson

Issue:
ERROR: xxxxx does not implement rsp format ?
I get this error on two of my builds for xc16 and c2000 targets, I'm not sure why?

"ERROR: ar2000 does no implemnt rsp format, this shouldn't be called"
"ERROR: xc16-ar does no implemnt rsp format, this shouldn't be called"

Both projects had been working on Meson 0.57.1. I have just upgraded to meson 0.58.0 and its the first error I get

I seem to have found this spot in the code, mentioning it's not implemented? Is that the case?
`
If `self.can_linker_accept_rsp()` returns True, then this needs to        
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'     
raise mesonlib.EnvironmentException(f'{self.id} does no implemnt rsp format, this shouldn\'t be called')

`



Discussion:

Resolving patch:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1831,6 +1831,17 @@ def generate_swift_target(self, target):
         # Introspection information
         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):
         num_pools = self.environment.coredata.options[OptionKey('backend_max_links')].value
         if 'java' in self.environment.coredata.compilers.host:
@@ -1859,10 +1870,9 @@ def generate_static_link_rules(self):
                 pool = 'pool = link_pool'
             else:
                 pool = None
-            self.add_rule(NinjaRule(rule, cmdlist, args, description,
-                                    rspable=static_linker.can_linker_accept_rsp(),
-                                    rspfile_quote_style=static_linker.rsp_file_syntax(),
-                                    extra=pool))
+
+            options = self._rsp_options(static_linker)
+            self.add_rule(NinjaRule(rule, cmdlist, args, description, **options, extra=pool))
 
     def generate_dynamic_link_rules(self):
         num_pools = self.environment.coredata.options[OptionKey('backend_max_links')].value
@@ -1882,10 +1892,9 @@ def generate_dynamic_link_rules(self):
                     pool = 'pool = link_pool'
                 else:
                     pool = None
-                self.add_rule(NinjaRule(rule, command, args, description,
-                                        rspable=compiler.can_linker_accept_rsp(),
-                                        rspfile_quote_style=compiler.rsp_file_syntax(),
-                                        extra=pool))
+
+                options = self._rsp_options(compiler)
+                self.add_rule(NinjaRule(rule, command, args, description, **options, extra=pool))
 
         args = self.environment.get_build_command() + \
             ['--internal',
@@ -1968,8 +1977,10 @@ def generate_llvm_ir_compile_rule(self, compiler):
         command = compiler.get_exelist()
         args = ['$ARGS'] + NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none) + compiler.get_compile_only_args() + ['$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
 
     def generate_compile_rule_for(self, langname, compiler):
@@ -2005,9 +2016,8 @@ def generate_compile_rule_for(self, langname, compiler):
         else:
             deps = 'gcc'
             depfile = '$DEPFILE'
-        self.add_rule(NinjaRule(rule, command, args, description,
-                                rspable=compiler.can_linker_accept_rsp(),
-                                rspfile_quote_style=compiler.rsp_file_syntax(),
+        options = self._rsp_options(compiler)
+        self.add_rule(NinjaRule(rule, command, args, description, **options,
                                 deps=deps, depfile=depfile))
 
     def generate_pch_rule_for(self, langname, compiler):
diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py
--- a/mesonbuild/linkers.py
+++ b/mesonbuild/linkers.py
@@ -112,7 +112,7 @@ def rsp_file_syntax(self) -> RSPFileSyntax:
         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'
-        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:


Test patch: