We have supported passing lists of arguments to the compiler and linker
for some time, since https://go.dev/issue/18468 was fixed.
The reason behind it is that some systems like Windows have relatively
small limits for commands, and some Go packages contain many source files.
This wasn't done for other Go toolchain programs like cgo and asm,
as there wasn't an initial need for it. A TODO was left for them.
The need has now arisen in the form of a bug report for a build of a
large Go package involving cgo.
Do asm as well, which could be triggered by lots of asm files.
I rebuilt Go itself with some basic logging to tell if any other
commands were being run with moderately large command lengths.
I only found one other: gcc being invoked with 300-500 bytes.
I didn't spot any length close to 1KiB, and we can't safely assume that
a user's CC compiler supports these "response files", so leave that as
another TODO for the future. Just like cgo and asm, we can revisit this
if any user reports a bug on the issue tracker.
Fixes #47235.
Change-Id: Ifcc099d7c0dfac3ed2c4e9e7a2d6e3d69b0ccb63
Reviewed-on: https://go-review.googlesource.com/c/go/+/427015
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Daniel Martà <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
}
func Parse() {
- flag.Usage = Usage
- flag.Parse()
+ objabi.Flagparse(Usage)
if flag.NArg() == 0 {
flag.Usage()
}
func main() {
objabi.AddVersionFlag() // -V
- flag.Usage = usage
- flag.Parse()
+ objabi.Flagparse(usage)
if *dynobj != "" {
// cgo -dynimport is essentially a separate helper command
func useResponseFile(path string, argLen int) bool {
// 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.
+ // TODO: Note that other toolchains like CC are missing here for now.
prog := strings.TrimSuffix(filepath.Base(path), ".exe")
switch prog {
- case "compile", "link":
+ case "compile", "link", "cgo", "asm":
default:
return false
}