Skip to content

Commit 5f86d62

Browse files
neptuwuniumnirbheek
authored andcommitted
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.
1 parent 428c89a commit 5f86d62

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mesonbuild/backend/ninjabackend.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ def _quoter(x, qf = quote_func):
237237
return ninja_quote(qf(str(x)))
238238

239239
def write(self, outfile: T.TextIO) -> None:
240+
rspfile_args = self.args
240241
if self.rspfile_quote_style is RSPFileSyntax.MSVC:
241242
rspfile_quote_func = cmd_quote
243+
rspfile_args = [NinjaCommandArg('$in_newline', arg.quoting) if arg.s == '$in' else arg for arg in rspfile_args]
242244
else:
243245
rspfile_quote_func = gcc_rsp_quote
244246

@@ -253,7 +255,7 @@ def rule_iter():
253255
if rsp == '_RSP':
254256
outfile.write(' command = {} @$out.rsp\n'.format(' '.join([self._quoter(x) for x in self.command])))
255257
outfile.write(' rspfile = $out.rsp\n')
256-
outfile.write(' rspfile_content = {}\n'.format(' '.join([self._quoter(x, rspfile_quote_func) for x in self.args])))
258+
outfile.write(' rspfile_content = {}\n'.format(' '.join([self._quoter(x, rspfile_quote_func) for x in rspfile_args])))
257259
else:
258260
outfile.write(' command = {}\n'.format(' '.join([self._quoter(x) for x in self.command + self.args])))
259261
if self.deps:

0 commit comments

Comments
 (0)