Fix long link commands on macOS (v2) (#21382)
Handle long link commands on macOS with a script, since ar does not support response files
This commit is contained in:
parent
13711b101d
commit
6b93db7070
1 changed files with 14 additions and 2 deletions
|
|
@ -834,6 +834,15 @@ proc linkViaResponseFile(conf: ConfigRef; cmd: string) =
|
||||||
finally:
|
finally:
|
||||||
removeFile(linkerArgs)
|
removeFile(linkerArgs)
|
||||||
|
|
||||||
|
proc linkViaShellScript(conf: ConfigRef; cmd: string) =
|
||||||
|
let linkerScript = conf.projectName & "_" & "linkerScript.sh"
|
||||||
|
writeFile(linkerScript, cmd)
|
||||||
|
let shell = getEnv("SHELL")
|
||||||
|
try:
|
||||||
|
execLinkCmd(conf, shell & " " & linkerScript)
|
||||||
|
finally:
|
||||||
|
removeFile(linkerScript)
|
||||||
|
|
||||||
proc getObjFilePath(conf: ConfigRef, f: Cfile): string =
|
proc getObjFilePath(conf: ConfigRef, f: Cfile): string =
|
||||||
if noAbsolutePaths(conf): f.obj.extractFilename
|
if noAbsolutePaths(conf): f.obj.extractFilename
|
||||||
else: f.obj.string
|
else: f.obj.string
|
||||||
|
|
@ -856,9 +865,12 @@ proc preventLinkCmdMaxCmdLen(conf: ConfigRef, linkCmd: string) =
|
||||||
# Windows's command line limit is about 8K (8191 characters) so C compilers on
|
# 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``
|
# Windows support a feature where the command line can be passed via ``@linkcmd``
|
||||||
# to them.
|
# to them.
|
||||||
const MaxCmdLen = when defined(windows): 8_000 else: 32_000
|
const MaxCmdLen = when defined(windows): 8_000 elif defined(macosx): 260_000 else: 32_000
|
||||||
if linkCmd.len > MaxCmdLen:
|
if linkCmd.len > MaxCmdLen:
|
||||||
linkViaResponseFile(conf, linkCmd)
|
when defined(macosx):
|
||||||
|
linkViaShellScript(conf, linkCmd)
|
||||||
|
else:
|
||||||
|
linkViaResponseFile(conf, linkCmd)
|
||||||
else:
|
else:
|
||||||
execLinkCmd(conf, linkCmd)
|
execLinkCmd(conf, linkCmd)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue