[backport: 2.0] prevents the jsonscript command from exceeding the maximum length of a command line during linking (#21186)
This commit is contained in:
parent
9e35631191
commit
9efa56a8bb
1 changed files with 13 additions and 9 deletions
|
|
@ -851,6 +851,17 @@ proc displayProgressCC(conf: ConfigRef, path, compileCmd: string): string =
|
||||||
else:
|
else:
|
||||||
result = MsgKindToStr[hintCC] % demangleModuleName(path.splitFile.name)
|
result = MsgKindToStr[hintCC] % demangleModuleName(path.splitFile.name)
|
||||||
|
|
||||||
|
proc preventLinkCmdMaxCmdLen(conf: ConfigRef, linkCmd: string) =
|
||||||
|
# Prevent linkcmd from exceeding the maximum command line length.
|
||||||
|
# Windows's command line limit is about 8K (8191 characters) so C compilers on
|
||||||
|
# Windows support a feature where the command line can be passed via ``@linkcmd``
|
||||||
|
# to them.
|
||||||
|
const MaxCmdLen = when defined(windows): 8_000 else: 32_000
|
||||||
|
if linkCmd.len > MaxCmdLen:
|
||||||
|
linkViaResponseFile(conf, linkCmd)
|
||||||
|
else:
|
||||||
|
execLinkCmd(conf, linkCmd)
|
||||||
|
|
||||||
proc callCCompiler*(conf: ConfigRef) =
|
proc callCCompiler*(conf: ConfigRef) =
|
||||||
var
|
var
|
||||||
linkCmd: string
|
linkCmd: string
|
||||||
|
|
@ -927,14 +938,7 @@ proc callCCompiler*(conf: ConfigRef) =
|
||||||
linkCmd = getLinkCmd(conf, mainOutput, objfiles, removeStaticFile = true)
|
linkCmd = getLinkCmd(conf, mainOutput, objfiles, removeStaticFile = true)
|
||||||
extraCmds = getExtraCmds(conf, mainOutput)
|
extraCmds = getExtraCmds(conf, mainOutput)
|
||||||
if optCompileOnly notin conf.globalOptions:
|
if optCompileOnly notin conf.globalOptions:
|
||||||
const MaxCmdLen = when defined(windows): 8_000 else: 32_000
|
preventLinkCmdMaxCmdLen(conf, linkCmd)
|
||||||
if linkCmd.len > MaxCmdLen:
|
|
||||||
# Windows's command line limit is about 8K (don't laugh...) so C compilers on
|
|
||||||
# Windows support a feature where the command line can be passed via ``@linkcmd``
|
|
||||||
# to them.
|
|
||||||
linkViaResponseFile(conf, linkCmd)
|
|
||||||
else:
|
|
||||||
execLinkCmd(conf, linkCmd)
|
|
||||||
for cmd in extraCmds:
|
for cmd in extraCmds:
|
||||||
execExternalProgram(conf, cmd, hintExecuting)
|
execExternalProgram(conf, cmd, hintExecuting)
|
||||||
else:
|
else:
|
||||||
|
|
@ -1035,7 +1039,7 @@ proc runJsonBuildInstructions*(conf: ConfigRef; jsonFile: AbsoluteFile) =
|
||||||
cmds.add cmd
|
cmds.add cmd
|
||||||
prettyCmds.add displayProgressCC(conf, name, cmd)
|
prettyCmds.add displayProgressCC(conf, name, cmd)
|
||||||
execCmdsInParallel(conf, cmds, prettyCb)
|
execCmdsInParallel(conf, cmds, prettyCb)
|
||||||
execLinkCmd(conf, bcache.linkcmd)
|
preventLinkCmdMaxCmdLen(conf, bcache.linkcmd)
|
||||||
for cmd in bcache.extraCmds: execExternalProgram(conf, cmd, hintExecuting)
|
for cmd in bcache.extraCmds: execExternalProgram(conf, cmd, hintExecuting)
|
||||||
|
|
||||||
proc genMappingFiles(conf: ConfigRef; list: CfileList): Rope =
|
proc genMappingFiles(conf: ConfigRef; list: CfileList): Rope =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue