From: Keith Randall Date: Tue, 21 Apr 2020 23:29:18 +0000 (-0700) Subject: cmd/go: use response files when command line would be too long X-Git-Tag: go1.15beta1~422 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0d19b91b40a971cad50b894d543c201763d4085e;p=gostls13.git cmd/go: use response files when command line would be too long Fixes #37768 Change-Id: I799a8da632890ad7595697d461c90e3c4c065d95 Reviewed-on: https://go-review.googlesource.com/c/go/+/229317 Run-TryBot: Keith Randall TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index dbe31a6016..1261cf4e6c 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -2972,13 +2972,13 @@ func mkAbsFiles(dir string, files []string) []string { return abs } -// passLongArgsInResponseFiles modifies cmd on Windows such that, for +// passLongArgsInResponseFiles modifies cmd such that, for // certain programs, long arguments are passed in "response files", a // file on disk with the arguments, with one arg per line. An actual // argument starting with '@' means that the rest of the argument is // a filename of arguments to expand. // -// See Issue 18468. +// See issues 18468 (Windows) and 37768 (Darwin). func passLongArgsInResponseFiles(cmd *exec.Cmd) (cleanup func()) { cleanup = func() {} // no cleanup by default @@ -3016,11 +3016,6 @@ func passLongArgsInResponseFiles(cmd *exec.Cmd) (cleanup func()) { } func useResponseFile(path string, argLen int) bool { - // Unless we're on Windows, don't use response files. - if runtime.GOOS != "windows" { - return false - } - // Unless the program uses objabi.Flagparse, which understands // response files, don't use response files. // TODO: do we need more commands? asm? cgo? For now, no. @@ -3033,6 +3028,8 @@ func useResponseFile(path string, argLen int) bool { // Windows has a limit of 32 KB arguments. To be conservative and not // worry about whether that includes spaces or not, just use 30 KB. + // Darwin's limit is less clear. The OS claims 256KB, but we've seen + // failures with arglen as small as 50KB. if argLen > (30 << 10) { return true }