diff options
| author | Hiroshi Ioka <hirochachacha@gmail.com> | 2017-06-01 16:23:40 +0900 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2017-08-14 18:48:28 +0000 |
| commit | 1f8433c66ae945f6d1e4a6bc8c6c5efebeae0dbe (patch) | |
| tree | c78b95fba455710854cca7816fa642e421c9c8e3 /src | |
| parent | bac1cc0d1675a0e958b366837e6230f4f09c2a5b (diff) | |
| download | go-1f8433c66ae945f6d1e4a6bc8c6c5efebeae0dbe.tar.xz | |
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>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/link/internal/ld/go.go | 2 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/macho.go | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/link/internal/ld/go.go b/src/cmd/link/internal/ld/go.go index 2930a6b24f..56d2f3f42e 100644 --- a/src/cmd/link/internal/ld/go.go +++ b/src/cmd/link/internal/ld/go.go @@ -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) } diff --git a/src/cmd/link/internal/ld/macho.go b/src/cmd/link/internal/ld/macho.go index ef4d1552f6..161833f357 100644 --- a/src/cmd/link/internal/ld/macho.go +++ b/src/cmd/link/internal/ld/macho.go @@ -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 |
