Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: field tracking is broken #20014

Closed
heschik opened this issue Apr 17, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@heschik
Copy link
Contributor

commented Apr 17, 2017

https://go-review.googlesource.com/38409 broke field tracking somehow. Field tracking has no test and the only documentation I can find is internal to Google, so here's repro instructions.

First, build a toolchain with GOEXPERIMENT=fieldtrack. This is important and easy to miss. Then compile the following:

package main

import “fmt”

type T struct {
	X int `go:”track”`
	Y int `go:”track”`
}

func (t *T) String() string {
	return fmt.Sprintf(“T(X=%d)”, t.X)
}

func (t *T) Sum() int {
	return t.X + t.Y
}

func Run() {
	t := new(T)
	fmt.Println(t)
}

func main() {
	Run()
}

The resulting object should have undefined symbols:

         U go.track.%22%22.T.X
         U go.track.%22%22.T.Y

which would then be used by the linker to build the used field list. After https://go-review.googlesource.com/38409, they aren't there.

If it's useful, the full command I used for bisecting was

(cd src; GOEXPERIMENT=fieldtrack ./make.bash); bin/go tool compile -o fieldtrack.o fieldtrack.go; bin/go tool nm fieldtrack.o | grep go.track || exit 1

CC @josharian @mdempsky

@heschik heschik changed the title Field tracking is broken cmd/compile: field tracking is broken Apr 17, 2017

@bradfitz bradfitz added this to the Go1.9 milestone Apr 17, 2017

@bradfitz

This comment has been minimized.

Copy link
Member

commented Apr 17, 2017

Issue #12174 had proposed adding a builder for this, but it deemed not important at the time, largely because this was a mostly Google-internal optimization/hack for one large logs processing job, and it shouldn't pollute the open source world. But it's kinda weird that it exists in open source anyway (as an experiment) but can't be tested. I'd still support adding tests + builder for it.

@josharian

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2017

Yeah. Without tests and a builder, it's just going to keep breaking.

Or if it was a one-time hack, is it still needed?

@bradfitz

This comment has been minimized.

Copy link
Member

commented Apr 17, 2017

@mdempsky

This comment has been minimized.

Copy link
Member

commented Apr 17, 2017

FWIW, @rsc uploaded code for testing fieldtrack: https://godoc.org/rsc.io/tmp/fieldtrack

@gopherbot gopherbot closed this in 33fd319 Apr 19, 2017

@golang golang locked and limited conversation to collaborators Apr 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.