1
0
mirror of https://github.com/golang/go synced 2024-11-18 17:54:57 -07:00

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 <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
Keith Randall 2020-04-21 16:29:18 -07:00
parent bf5b83a835
commit 0d19b91b40

View 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
}