mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: directly exec archive command if external tmpdir
When linking a Go archive, if the archiver invocation is the very last thing that needs to happen in the link (no "atexit" cleanups required remove the locally created tmpdir) then call syscall.Exec to invoke the archiver command instead of the usual exec.Command. This has the effect of reducing peak memory use for the linker overall, since we don't be holding onto all of the linker's live memory while the archiver is running. Change-Id: Ibbe22d8d67a70cc2a4f91c68aab56d19fb77c393 Reviewed-on: https://go-review.googlesource.com/c/go/+/203821 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
1da575a7bc
commit
bf7e55b618
6 changed files with 154 additions and 10 deletions
|
|
@ -46,6 +46,7 @@ import (
|
|||
var (
|
||||
pkglistfornote []byte
|
||||
windowsgui bool // writes a "GUI binary" instead of a "console binary"
|
||||
ownTmpDir bool // set to true if tmp dir created by linker (e.g. no -tmpdir)
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -272,13 +273,12 @@ func Main(arch *sys.Arch, theArch Arch) {
|
|||
|
||||
ctxt.undef()
|
||||
ctxt.hostlink()
|
||||
ctxt.archive()
|
||||
if ctxt.Debugvlog != 0 {
|
||||
ctxt.Logf("%d symbols\n", len(ctxt.Syms.Allsym))
|
||||
ctxt.Logf("%d liveness data\n", liveness)
|
||||
}
|
||||
|
||||
ctxt.Bso.Flush()
|
||||
ctxt.archive()
|
||||
|
||||
errorexit()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue