-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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/go: link should stop when cgo is required but disabled #46330
Comments
cc @cherrymui @rsc @mdempsky @ianlancetaylor as per owners. |
Change https://golang.org/cl/321935 mentions this issue: |
The go tool disables cgo automatically when cross compiling, so it is not necessary to explicitly disable it. |
Change https://go.dev/cl/522239 mentions this issue: |
…enabled Fixes golang#46330. Fixes golang#62123. Updates golang#31544. Change-Id: I023aa2bdb5a24e126a0de5192a077e8cf1a0a67c Reviewed-on: https://go-review.googlesource.com/c/go/+/522239 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Change https://go.dev/cl/522182 mentions this issue: |
Change https://go.dev/cl/522495 mentions this issue: |
This test passes "-linkmode=external" to 'go run' to link the binary using the system C linker. CGO_ENABLED=0 explicitly tells cmd/go not to use the C toolchain, so the test should not be run in that configuration. Updates #46330. Change-Id: I16ac66aac91178045f9decaeb28134061e9711f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/522495 Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
…re external linking TestUnshareMountNameSpaceChroot attempts to build a statically-linked binary to run in a chroot, and sets CGO_ENABLED=0 in order to do so. Rather than trying to figure out some other way to coax the linker into building a static binary, let's just skip the test on Linux platforms that require external linking (namely android/arm). This should fix the build failure reported in https://build.golang.org/log/1ea245a9c2e916c81043db177be76778bab00058. While we're here, let's also fix the failure logging to make the text readable! Updates #46330. Change-Id: I4fa07640ce012ac141bf4698bc3215a7f146062c Reviewed-on: https://go-review.googlesource.com/c/go/+/522182 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Change https://go.dev/cl/522795 mentions this issue: |
We have tried various approaches in testenv.hasTool to detect whether 'go build' works without actually building a binary. However, they all turn out to be fairly fragile. If cgo is enabled then we need a C linker, but if the platform requires external linking then cgo must be enabled too. Instead of trying to second-guess whether 'go build' will actually work, let's just ask it to build a binary and see whether it succeeds. Hopefully this appreach will be simple enough in practice. This parallels the approach taken in CL 492979. Fixes golang/go#62268. Updates golang/go#46330. Change-Id: I9fd85fb73d291306e7bfb2f3ef6cf75a09cb6bed Reviewed-on: https://go-review.googlesource.com/c/tools/+/522795 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com>
Change https://go.dev/cl/569296 mentions this issue: |
…e notes for Go 1.21 and 1.22 Fixes golang/go#65887. Updates golang/go#31544. Updates golang/go#46330. Updates golang/go#64875. Change-Id: Ibb035e2287ad0efdbe875c5dd16ffd938ec7a956 Reviewed-on: https://go-review.googlesource.com/c/website/+/569296 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
We have tried various approaches in testenv.hasTool to detect whether 'go build' works without actually building a binary. However, they all turn out to be fairly fragile. If cgo is enabled then we need a C linker, but if the platform requires external linking then cgo must be enabled too. Instead of trying to second-guess whether 'go build' will actually work, let's just ask it to build a binary and see whether it succeeds. Hopefully this appreach will be simple enough in practice. This parallels the approach taken in CL 492979. Fixes golang/go#62268. Updates golang/go#46330. Change-Id: I9fd85fb73d291306e7bfb2f3ef6cf75a09cb6bed Reviewed-on: https://go-review.googlesource.com/c/tools/+/522795 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
It also reproduces with go1.17 devel.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Using https://play.golang.org/p/LqHgq34kmVq:
What I'm doing is to check if my package is buildable for the specified platform.
What did you expect to see?
An error, reporting that cgo is required for the platform but explicitly disabled by the user. The program should exit, instead of continuing.
What did you see instead?
android/arm
reports:android/amd64
andandroid/arm64
worksios/amd64
andios/arm64
reports:The text was updated successfully, but these errors were encountered: