Fix MSVC linker error LNK1170 with long rspfiles

The MSVC linker errors out if a line in the rspfile is too long.
The resolution is to use the built-in ninja keyword $in_newline instead of $in, which splits each input into separate lines.
pull/12364/head
Ada 1 year ago committed by Nirbheek Chauhan
parent 208b31faf1
commit 4c9927e8b7
  1. 4
      mesonbuild/backend/ninjabackend.py

@ -237,8 +237,10 @@ class NinjaRule:
return ninja_quote(qf(str(x)))
def write(self, outfile: T.TextIO) -> None:
rspfile_args = self.args
if self.rspfile_quote_style is RSPFileSyntax.MSVC:
rspfile_quote_func = cmd_quote
rspfile_args = [NinjaCommandArg('$in_newline', arg.quoting) if arg.s == '$in' else arg for arg in rspfile_args]
else:
rspfile_quote_func = gcc_rsp_quote
@ -253,7 +255,7 @@ class NinjaRule:
if rsp == '_RSP':
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 self.args])))
outfile.write(' rspfile_content = {}\n'.format(' '.join([self._quoter(x, rspfile_quote_func) for x in rspfile_args])))
else:
outfile.write(' command = {}\n'.format(' '.join([self._quoter(x) for x in self.command + self.args])))
if self.deps:

Loading…
Cancel
Save