]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: don't link the same dylib multiple times
authorHiroshi Ioka <hirochachacha@gmail.com>
Thu, 1 Jun 2017 07:23:40 +0000 (16:23 +0900)
committerIan Lance Taylor <iant@golang.org>
Mon, 14 Aug 2017 18:48:28 +0000 (18:48 +0000)
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>

src/cmd/link/internal/ld/go.go
src/cmd/link/internal/ld/macho.go

index 2930a6b24f1bab0e817b632116d4e7b026ccc339..56d2f3f42e824280177ded479f36ae3118ce8282 100644 (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)
                                }
index ef4d1552f6c44a82079edf686b22404a3462516a..161833f357c005968affc17953799c5b04bd7062 100644 (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