diff mbox

libgo patch committed: always use --whole-archive in go tool

Message ID CAOyqgcWWB+dEKEiq5CYjRXYhT0T+pKza+8X-z4od_VPo_dcGkw@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Nov. 10, 2015, 8:31 p.m. UTC
This patch changes the Go tool to always use --whole-archive when
linking gccgo packages.  This fixes cases where a Go package uses cgo
to call C code in which the only referenced symbol is a C global
variable.  This is a backport of https://golang.org/cl/16775 in the
master Go sources.  This fixes GC PR 68255.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 230064)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-012ab5cb2ef1c26e8023ce90d3a2bba174da7b30
+0c07751d139ef90a43ef7f299f925622a8792a9f
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/cmd/go/build.go
===================================================================
--- libgo/go/cmd/go/build.go	(revision 230064)
+++ libgo/go/cmd/go/build.go	(working copy)
@@ -2555,17 +2555,9 @@  func (tools gccgoToolchain) ld(b *builde
 		}
 	}
 
-	switch ldBuildmode {
-	case "c-archive", "c-shared":
-		ldflags = append(ldflags, "-Wl,--whole-archive")
-	}
-
+	ldflags = append(ldflags, "-Wl,--whole-archive")
 	ldflags = append(ldflags, afiles...)
-
-	switch ldBuildmode {
-	case "c-archive", "c-shared":
-		ldflags = append(ldflags, "-Wl,--no-whole-archive")
-	}
+	ldflags = append(ldflags, "-Wl,--no-whole-archive")
 
 	ldflags = append(ldflags, cgoldflags...)
 	ldflags = append(ldflags, envList("CGO_LDFLAGS", "")...)