Commit ea5c2003 by Ian Lance Taylor

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
parent c5a237e9
012ab5cb2ef1c26e8023ce90d3a2bba174da7b30 0c07751d139ef90a43ef7f299f925622a8792a9f
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -2555,17 +2555,9 @@ func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions ...@@ -2555,17 +2555,9 @@ func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions
} }
} }
switch ldBuildmode { ldflags = append(ldflags, "-Wl,--whole-archive")
case "c-archive", "c-shared":
ldflags = append(ldflags, "-Wl,--whole-archive")
}
ldflags = append(ldflags, afiles...) ldflags = append(ldflags, afiles...)
ldflags = append(ldflags, "-Wl,--no-whole-archive")
switch ldBuildmode {
case "c-archive", "c-shared":
ldflags = append(ldflags, "-Wl,--no-whole-archive")
}
ldflags = append(ldflags, cgoldflags...) ldflags = append(ldflags, cgoldflags...)
ldflags = append(ldflags, envList("CGO_LDFLAGS", "")...) ldflags = append(ldflags, envList("CGO_LDFLAGS", "")...)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment