Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(255)

Issue 93200044: code review 93200044: cmd/gc: disable link-time copying of un-Go-initialized ... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
5 years, 5 months ago by rsc
Modified:
5 years, 5 months ago
Reviewers:
gobot, iant
CC:
golang-codereviews, iant
Visibility:
Public.

Description

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 issue 7665.

Patch Set 1 #

Patch Set 2 : diff -r 4ffd1c7fbadb https://code.google.com/p/go/ #

Patch Set 3 : diff -r 4ffd1c7fbadb https://code.google.com/p/go/ #

Patch Set 4 : diff -r ba0d1163c276 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+28 lines, -2 lines) Patch
M misc/cgo/test/cgo_test.go View 1 2 1 chunk +1 line, -0 lines 0 comments Download
A misc/cgo/test/issue7665.go View 1 2 1 chunk +25 lines, -0 lines 0 comments Download
M src/cmd/gc/sinit.c View 1 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 4
rsc
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
5 years, 5 months ago (2014-05-09 19:33:13 UTC) #1
iant
LGTM
5 years, 5 months ago (2014-05-09 19:54:55 UTC) #2
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=be19ef9bd7b3 *** cmd/gc: disable link-time copying of un-Go-initialized globals If you write: ...
5 years, 5 months ago (2014-05-09 20:03:45 UTC) #3
gobot
5 years, 5 months ago (2014-05-09 20:43:50 UTC) #4
Message was sent while issue was closed.
This CL appears to have broken the openbsd-amd64-rootbsd builder.
See http://build.golang.org/log/d1a49acdacfd61b40f18ee142daee36c15b21c4a
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b