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
Labels

Comments

@dsnet
Copy link
Member

@dsnet 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.

@dsnet dsnet added the Performance label Apr 26, 2019
@randall77

This comment has been minimized.

Copy link
Contributor

@randall77 randall77 commented Apr 27, 2019

I'm pretty sure this is #2559.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.