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: linker does not elide unused global maps #31704

Closed
dsnet opened this issue Apr 26, 2019 · 1 comment
Closed

cmd/compile: linker does not elide unused global maps #31704

dsnet opened this issue Apr 26, 2019 · 1 comment

Comments

@dsnet
Copy link
Member

dsnet commented Apr 26, 2019

Using go1.12

Consider the following snippet:

package main
var GlobalMap = map[string]struct{}{"MY_GLOBAL_MAP": {}}
var GlobalSlice = []string{"MY_GLOBAL_SLICE"}
func main() {}

If I build the program and grep for my magic string, it is in the final binary:

$ go build main.go && strings main | grep -oE "MY_GLOBAL_(MAP|SLICE)"
MY_GLOBAL_MAP

This suggests that this global map is linked into the final binary even if unused. On the other hand, unused global slices are not linked into the final binary.

@randall77
Copy link
Contributor

I'm pretty sure this is #2559.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants