]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: use response files when command line would be too long
authorKeith Randall <khr@golang.org>
Tue, 21 Apr 2020 23:29:18 +0000 (16:29 -0700)
committerKeith Randall <khr@golang.org>
Thu, 23 Apr 2020 18:20:07 +0000 (18:20 +0000)
Fixes #37768

Change-Id: I799a8da632890ad7595697d461c90e3c4c065d95
Reviewed-on: https://go-review.googlesource.com/c/go/+/229317
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/work/exec.go

index dbe31a60164db1a4d451e94918d38401afdd6f1a..1261cf4e6c95dbf15a4bccd7d3a1fc617c6ddcf8 100644 (file)
@@ -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
        }