1
0
mirror of https://github.com/golang/go synced 2024-11-19 14:54:43 -07:00

cmd/link: don't link the same dylib multiple times

Also, unexport Machoadddynlib

n=`go test -c crypto/x509 && otool -l x509.test | grep libSystem | wc -l`

Before this CL, n = 3.
After this CL, n = 1.

on my environment.

Change-Id: Ic7b8157435cc85086404860dc6c84eb0aecc5d19
Reviewed-on: https://go-review.googlesource.com/44771
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Avelino <t@avelino.xxx>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Hiroshi Ioka 2017-06-01 16:23:40 +09:00 committed by Ian Lance Taylor
parent bac1cc0d16
commit 1f8433c66a
2 changed files with 7 additions and 2 deletions

View File

@ -175,7 +175,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) {
havedynamic = 1
if Headtype == objabi.Hdarwin {
Machoadddynlib(lib)
machoadddynlib(lib)
} else {
dynlib = append(dynlib, lib)
}

View File

@ -380,7 +380,12 @@ func (ctxt *Link) domacho() {
}
}
func Machoadddynlib(lib string) {
func machoadddynlib(lib string) {
if seenlib[lib] || Linkmode == LinkExternal {
return
}
seenlib[lib] = true
// Will need to store the library name rounded up
// and 24 bytes of header metadata. If not enough
// space, grab another page of initial space at the