-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: -buildmode=pie -linkshared generates large binaries #40416
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
Comments
Marking as a release blocker for 1.15. We should investigate this and decide whether it is a problem that needs to be addressed for 1.1.5 |
Sorry, I cannot reproduce it on my machine:
The generated binary is dynamically linked and linked against libstd.so. |
Have you checked the executable file size? despite ldd's output, When I build hello world shared linked with 1.14.6 the size is 19 KB It seems the file also contains statically linked modules, try the same on 1.14.6 and compare executable file sizes and content of a simple hello world. When I build statically the size is 2.3 MB To the contrary the shared executable must be smaller in size |
@kiap , just the clarify, can you state the exact problem you're seeing more clearly? It's not clear from your original bug report. Is it specifically that the shared linkage executable is significantly larger than it used to be, indicating the linker included a lot of things it shouldn't have? Are you seeing problems besides the size? (When you say it "generates incorrect code", that suggests a crash or panic when you try to run it.) |
Change https://golang.org/cl/244839 mentions this issue: |
Thanks for the note about the size. It is not that we linked in a static copy, but we accidentally put a large number of symbols into the dynamic symbol table. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
This was working before on 1.14.6 and was working on every every version
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
go install -v -ldflags '-s -w' -gcflags '-trimpath /usr/src/go' -buildmode=shared -linkshared -pkgdir /usr/src/lib std
go install -v -ldflags '-s -w' -gcflags '-trimpath /usr/src/go' -buildmode=pie -linkshared -pkgdir /usr/src/lib prog
What did you expect to see?
The binary should be linked correctly and builds linked to standard library
What did you see instead?
static executable
The text was updated successfully, but these errors were encountered: