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

build: debug_* sections are missing from toolchain binaries in Go 1.21 #61714

Open
laboger opened this issue Aug 2, 2023 · 5 comments
Open
Labels
binary-size NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@laboger
Copy link
Contributor

laboger commented Aug 2, 2023

What version of Go are you using (go version)?

go 1.21rc4

$ go version

Does this issue reproduce with the latest release?

No

What operating system and processor architecture are you using (go env)?

ppc64le, but same result on x86

go env Output
$ go env

What did you do?

I tried to use the GNU objdump -DlS on the go binary from a toolchain I built from the Go 1.21 branch, but the source statement information did not appear. On further inspection I found that the debug_* sections were missing from the go binary and all binaries found under pkg/tool/linux_ppc64le. When building a toolchain from the master branch all these binaries have the debug sections, and likewise on earlier releases such as the Go 1.20 branch.

[boger@ltcd97-lp2 bin]$ file ~/golang/base/go/bin/go
/home/boger/golang/base/go/bin/go: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), statically linked, Go BuildID=yEBM_x29Vtmmv5mU7ibv/fQLYk1huGo5MrnaLT7cs/UABCXJ-zG0lDIV6nnPTB/lP5zvxbwOH1d-gjeKVWj, with debug_info, not stripped
[boger@ltcd97-lp2 bin]$ file ~/golang/base/go/pkg/tool/linux_ppc64le/compile
/home/boger/golang/base/go/pkg/tool/linux_ppc64le/compile: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), statically linked, Go BuildID=NEnWUHq4dHMg58fMsP2C/HzKcDIEHHQ2d8XRwW2wM/hVRUaEN2h5tH_gBuJgi3/Fd9-7WFy0d_3nglhJ1Wn, with debug_info, not stripped

[boger@ltcd97-lp2 bin]$ file ~/golang/go1.21/go/bin/go
/home/boger/golang/go1.21/go/bin/go: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), statically linked, Go BuildID=Ipj_J0quvipW6G1VJUv5/Z8dFndgoIFi-DjK_MBs5/Yo-_THqt0OgmXGm3gyEv/DwCPGEf0IzGsTtYqTLQd, not stripped
[boger@ltcd97-lp2 bin]$ file ~/golang/go1.21/go/pkg/tool/linux_ppc64le/compile 
/home/boger/golang/go1.21/go/pkg/tool/linux_ppc64le/compile: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), statically linked, Go BuildID=L5yz1CZ290PRDTFeR0Cq/-R4MnzVYRXvc8oT1olkg/SlvsKpKgea9wlhrCM9fX/IFuvxzMaydYb-mjbrIpz, not stripped

What did you expect to see?

The debug_* sections in the Go 1.21 toolchain binaries such as go and those found in pkg/tool/linux_ppc64le so that debug tools will work when debugging the toolchain.

What did you see instead?

No debuginfo in the Go 1.21 toolchain binaries and debugging tools less effective.

If this was a planned change, I didn't see anything in the git log that explicitly mentions the removal of the debug_* sections and didn't find anything in the release notes that mentions the diffference.

@dmitshur
Copy link
Contributor

dmitshur commented Aug 2, 2023

There've been some changes to reduce the size of the release toolchains as part of work for #57001, but I'm not sure if this issue is working is intended. CL 475378 may be relevant here.

@laboger
Copy link
Contributor Author

laboger commented Aug 2, 2023

OK it looks like that CL is what did this. Is there a place where the value for the GO_LDFLAGS option to generate the dwarf sections is documented?

@dmitshur
Copy link
Contributor

dmitshur commented Aug 2, 2023

CC @rsc, @ianlancetaylor.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 2, 2023
@dmitshur dmitshur added this to the Go1.21 milestone Aug 2, 2023
@cherrymui
Copy link
Member

The linker -w flag is documented at https://pkg.go.dev/cmd/link .

I think the expectation is that most user won't debug a toolchain binary. And for toolchain developers who do want to debug a toolchain binary, one can build it with go install cmd/compile (or link etc.).

@laboger
Copy link
Contributor Author

laboger commented Aug 7, 2023

The linker -w flag is documented at https://pkg.go.dev/cmd/link .

My point is that the only way to know that the release binaries in the toolchain are not built with debug information is to search the log and find the change. Then you'd know to use -w=0 to generate them. I was expecting to see this in at least the release notes but if you don't think this is a difference that warrants being mentioned then feel free to close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary-size NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants