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
Labels
Documentation FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.

Comments

@ALTree
Copy link
Member

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

@ALTree ALTree added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Aug 12, 2020
@cherrymui
Copy link
Member

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 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

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

@gopherbot
Copy link

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
@golang golang locked and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

3 participants