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

doc: in 1.15 release notes, warn that -buildmode=pie will prevent static builds #40719

Closed
ALTree opened this issue Aug 12, 2020 · 4 comments
Closed

Comments

@ALTree
Copy link
Member

@ALTree ALTree commented Aug 12, 2020

From the Go1.15 release notes:

The linker now defaults to internal linking mode for -buildmode=pie on linux/amd64 and linux/arm64 [...]

This means this classical incantation for static builds, that worked on Go1.14:

go build \
-buildmode pie \
-ldflags '-extldflags "-fno-PIC -static"' \
[...]

will instead silently produce dynamically linked binaries in Go 1.15.

We already had a report of a user that was stumped by the change: #40711.

Should we warn about this in the linker section of the 1.15 release notes?

cc @ianlancetaylor @cherrymui @dmitshur

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Aug 12, 2020

I don't think it prevent static build. You can still use external linking with -ldflags=-linkmode=external (which was the default in Go 1.14). In Go 1.15, we changed the default but not remove external linking.

Maybe the linker can warn if it is internal linking but -extldflags is specified? (Not sure, maybe there are tools that pass no-op -extldflags unconditionally.)

I'm not sure we need to update the release notes. We only changed the default, and '-extldflags "-fno-PIC -static"' is already not the default, technically. Maybe we could add "External linking mode can still be requested with -ldflags=-linkmode=external".

@ALTree
Copy link
Member Author

@ALTree ALTree commented Aug 12, 2020

"will prevent static builds... unless you add an additional flag, that wasn't needed before" is what I meant. I know that you can still build static binaries. I'm just not sure that's easy to understand reading that sentence about the linker in the release notes.

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248199 mentions this issue: doc/go1.15: clarify external linking can still be used for building PIE

@gopherbot gopherbot closed this in 50f63a7 Aug 12, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248330 mentions this issue: [release-branch.go1.15] doc/go1.15: clarify external linking can still be used for building PIE

gopherbot pushed a commit that referenced this issue Aug 13, 2020
…l be used for building PIE

In Go 1.15 we switched the default linking mode for PIE on
Linux/AMD64 and Linux/ARM64 to internal linking. Clarify that
the previous behavior (external linking) can still be used with
a flag.

Updates #40719.

Change-Id: Ib7042622bc91e1b1aa31f520990d03b5eb6c56bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/248199
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 50f63a7)
Reviewed-on: https://go-review.googlesource.com/c/go/+/248330
IceCodeNew added a commit to IceCodeNew/go-collection that referenced this issue Oct 20, 2020
IceCodeNew added a commit to IceCodeNew/go-collection that referenced this issue Oct 20, 2020
IceCodeNew added a commit to IceCodeNew/go-collection that referenced this issue Oct 21, 2020
IceCodeNew added a commit to IceCodeNew/go-collection that referenced this issue Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.