summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-11-10 20:31:11 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-11-10 20:31:11 +0000
commitea5c200338a8f53b7b6068859ba5f5da84582c98 (patch)
tree702cc02dccad395c560d2e5bcd6975a8b6be0711 /libgo
parentc5a237e923d40c592d47828bcd20df6cc123dcb2 (diff)
downloadgcc-ea5c200338a8f53b7b6068859ba5f5da84582c98.tar.gz
re PR go/68255 (cgo-generated constructor not being called)
PR go/68255 cmd/go: always use --whole-archive for gccgo packages This is a backport of https://golang.org/cl/16775. This is, in effect, what the gc toolchain does. It fixes cases where Go code refers to a C global variable; without this, if the global variable was the only thing visible in the C code, the generated cgo file might not get pulled in from the archive, leaving the Go variable uninitialized. This was reported against gccgo as https://gcc.gnu.org/PR68255 . Reviewed-on: https://go-review.googlesource.com/16778 From-SVN: r230120
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/cmd/go/build.go12
1 files changed, 2 insertions, 10 deletions
diff --git a/libgo/go/cmd/go/build.go b/libgo/go/cmd/go/build.go
index 3afac2ee062..865871c5314 100644
--- a/libgo/go/cmd/go/build.go
+++ b/libgo/go/cmd/go/build.go
@@ -2555,17 +2555,9 @@ func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions
}
}
- 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", "")...)