Skip to content

Commit 0757230

Browse files
kim-emclaude
andcommitted
fix(lake): use response files on all platforms to avoid ARG_MAX
Lake already uses response files (`@file`) on Windows to avoid exceeding CLI length limits. This extends that behavior to macOS and Linux, where linking Mathlib's ~15,000 object files into a shared library exceeds macOS's ARG_MAX (262,144 bytes). Both `clang` and `gcc` support `@file` response files on all platforms, so this is safe to enable unconditionally. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ece65fc commit 0757230

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/lake/Lake/Build/Actions.lean

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,20 @@ public def compileO
8787
}
8888

8989
public def mkArgs (basePath : FilePath) (args : Array String) : LogIO (Array String) := do
90-
if Platform.isWindows then
91-
-- Use response file to avoid potentially exceeding CLI length limits.
92-
let rspFile := basePath.addExtension "rsp"
93-
let h ← IO.FS.Handle.mk rspFile .write
94-
args.forM fun arg =>
95-
-- Escape special characters
96-
let arg := arg.foldl (init := "") fun s c =>
97-
if c == '\\' || c == '"' then
98-
s.push '\\' |>.push c
99-
else
100-
s.push c
101-
h.putStr s!"\"{arg}\"\n"
102-
return #[s!"@{rspFile}"]
103-
else
104-
return args
90+
-- Use response file to avoid potentially exceeding CLI length limits.
91+
-- On Windows this is always needed; on macOS/Linux this is needed for large
92+
-- projects like Mathlib where the number of object files exceeds ARG_MAX.
93+
let rspFile := basePath.addExtension "rsp"
94+
let h ← IO.FS.Handle.mk rspFile .write
95+
args.forM fun arg =>
96+
-- Escape special characters
97+
let arg := arg.foldl (init := "") fun s c =>
98+
if c == '\\' || c == '"' then
99+
s.push '\\' |>.push c
100+
else
101+
s.push c
102+
h.putStr s!"\"{arg}\"\n"
103+
return #[s!"@{rspFile}"]
105104

106105
public def compileStaticLib
107106
(libFile : FilePath) (oFiles : Array FilePath)

0 commit comments

Comments
 (0)