1
0
mirror of https://github.com/golang/go synced 2024-11-19 21:04:43 -07:00
go/misc
Russ Cox e5c105033a cmd/gc: disable link-time copying of un-Go-initialized globals
If you write:

        var x = 3

then the compiler arranges for x to be initialized in the linker
with an actual 3 from the data segment, rather than putting
x in the bss and emitting init-time "x = 3" assignment code.

If you write:

        var y = x
        var x = 3

then the compiler is clever and treats this the same as if
the code said 'y = 3': they both end up in the data segment
with no init-time assignments.

If you write

        var y = x
        var x int

then the compiler was treating this the same as if the
code said 'x = 0', making both x and y zero and avoiding
any init-time assignment.

This copying optimization to avoid init-time assignment of y
is incorrect if 'var x int' doesn't mean 'x = 0' but instead means
'x is initialized in C or assembly code'. The program ends up
with 'y = 0' instead of 'y = the value specified for x in that other code'.

Disable the propagation if there is no initializer for x.

This comes up in some uses of cgo, because cgo generates
Go globals that are initialized in accompanying C files.

Fixes #7665.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/93200044
2014-05-09 16:03:44 -04:00
..
arm
bash misc/bash, misc/zsh: fix completion rules 2014-03-27 00:29:55 -04:00
bbedit misc/{bbedit|IntelliJIDEA|kate}: add missing delete predeclared identifier 2013-06-24 13:17:56 -07:00
cgo cmd/gc: disable link-time copying of un-Go-initialized globals 2014-05-09 16:03:44 -04:00
chrome/gophertool gophertool: fix links 2012-10-22 01:05:21 +08:00
dashboard/codereview misc/dashboard/app, misc/dashboard/builder: delete from main repo; part of move to go.tools 2013-08-01 13:27:27 +10:00
emacs misc/emacs: ignore backquote in comment or string 2014-04-09 12:28:27 -04:00
fraise
git misc/git: add gofmt git pre-commit hook 2012-11-15 19:58:49 +01:00
goplay misc/goplay: use go run x.go instead of go build x.go 2013-07-12 09:41:10 +10:00
IntelliJIDEA misc/{bbedit|IntelliJIDEA|kate}: add missing delete predeclared identifier 2013-06-24 13:17:56 -07:00
kate misc/{bbedit|IntelliJIDEA|kate}: add missing delete predeclared identifier 2013-06-24 13:17:56 -07:00
linkcheck misc/linkcheck: better redirect handling, use meaningful exit code 2013-10-25 17:31:02 +03:00
makerelease misc/makerelease: use windows installer resources from local goroot 2014-03-03 12:50:29 +11:00
nacl misc/nacl: add Native Client support scripts and documentation 2014-03-24 12:34:09 +11:00
notepadplus misc/notepadplus: Fix Function List in Notepad++ 6.5 2013-12-18 10:17:38 -08:00
swig cmd/go: add any .c/.cc files to the SWIG shared library 2013-10-09 10:35:46 -07:00
vim misc/vim/readme.txt: workaround weird OS X vim bug. 2014-04-28 14:24:14 -04:00
xcode misc/xcode: use xcode-select to determine path 2013-08-20 20:48:29 +10:00
zsh misc/bash, misc/zsh: fix completion rules 2014-03-27 00:29:55 -04:00
benchcmp benchcmp: leave a forwarding script 2014-03-31 16:39:41 -04:00
pprof runtime: more precise mprof sampling 2014-02-12 22:36:45 +04:00