-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: varying GOROOT_FINAL invalidates precompiled C dependencies of "net" #50183
Comments
Does you program use cgo anywhere? Is there any build tag that could cause different code to be built with Go 1.17 and Go 1.18? Thanks. If you don't have a C compiler installed, maybe try setting |
I confirm that I don't have a C compiler installed. I never needed one, don't need one for go 1.17. I confirm also that I don't use cgo anywhere. I can work around the problem indeed as follows:
However, I would say this is a regression problem as setting CGO_ENABLED is not needed when using go 1.17. |
How was |
I installed go 1.17 on Arch with pacman and I ran the following commands:
|
Seems reproducible with just: (tried with both
|
Please note that we had the same regression issue when we moved from 1.16 to 1.17: #47215 It had been fixed then. |
Ping: we think this is an RC blocker. |
I can reproduce this without even using a container by using a I think this is specific to the way that
Still investigating the root cause. |
This notably does not reproduce with a
|
Ah. This is probably from https://go.dev/cl/353352 (which fixed #48319). When
So when you run Indeed, setting
|
One possible resolution might be to build the release with Another possible resolution is to declare that you need a C compiler in order to build with A third possible resolution is to declare that if you want to use a precompiled Go distribution without a C compiler, you must either set |
As a more immediate workaround (but IMO clearly a hack), I suppose we could change (@golang/release: how do y'all feel about that?) |
Looking at #48319 the issues to be the |
I think that would be more-or-less equivalent to always using the |
Seems that we already do the equivalent for the Go code in the standard library, at least in the release. |
My understanding is that the Go linker expands the elided I don't know whether it does that only for Go libraries, or for C dependencies of Go libraries as well. (Or do we always use the C linker if the binary includes C dependencies?) |
I think that expansion only applies to Go code, as it applies to files from the FileTable from the CompilationUnit, which seems specific to Go object files. |
Change https://golang.org/cl/380503 mentions this issue: |
Absent a clear alternative, I'm going to go ahead and mail the |
If I understand correctly, once the accepted proposal #47257 is implemented, this issue (and others like it) will stop being relevant. So that is the long-term fix for this problem, and we just need a short-term one here.
It seems that it's not tenable to release with
Needing a C compiler to build with
This seems like the best option to improve things before #47257 is resolved. Its only downside is it increases complexity in Now that |
Based on analysis in #50183 (comment) and following discussion, it sounds like it's determined that |
@rsc pointed out that setting We're going to see if the |
Change https://golang.org/cl/380915 mentions this issue: |
Change https://golang.org/cl/380914 mentions this issue: |
Change https://golang.org/cl/380916 mentions this issue: |
For #50183 Change-Id: Ie384333fb7a69d0d2cfaba0cfc4eb7afba2fd745 Reviewed-on: https://go-review.googlesource.com/c/go/+/380916 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Russ Cox <[email protected]>
…property The test previously checked that the DWARF DW_AT_comp_dir attribute matched GOROOT_FINAL. However, on further consideration, we believe that DW_AT_comp_dir should not actually match GOROOT_FINAL: the DWARF spec says that DW_AT_comp_dir records “the current working directory of the compilation command that produced this compilation unit”, but the actual working directory of the compilation command proper is a throwaway directory in the build cache — it is neither stable nor meaningful. However, the test was getting at a real issue that we do care about: namely, that the binary produced by a 'go build' command with cgo enabled should not reuse a dependency that embeds a stale GOROOT_FINAL. This change refactors the test to verify the latter property instead of checking DW_AT_comp_dir specifically. For #50183 Updates #48319 Change-Id: I0b1151d9ba3d0ff903f72e27850306406e5cb518 Reviewed-on: https://go-review.googlesource.com/c/go/+/380914 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
The issue is fixed for me when using version 1.18beta2 instead of 1.18beta1. Many thanks! |
For golang#50183 Change-Id: Ie384333fb7a69d0d2cfaba0cfc4eb7afba2fd745 Reviewed-on: https://go-review.googlesource.com/c/go/+/380916 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Russ Cox <[email protected]>
…property The test previously checked that the DWARF DW_AT_comp_dir attribute matched GOROOT_FINAL. However, on further consideration, we believe that DW_AT_comp_dir should not actually match GOROOT_FINAL: the DWARF spec says that DW_AT_comp_dir records “the current working directory of the compilation command that produced this compilation unit”, but the actual working directory of the compilation command proper is a throwaway directory in the build cache — it is neither stable nor meaningful. However, the test was getting at a real issue that we do care about: namely, that the binary produced by a 'go build' command with cgo enabled should not reuse a dependency that embeds a stale GOROOT_FINAL. This change refactors the test to verify the latter property instead of checking DW_AT_comp_dir specifically. For golang#50183 Updates golang#48319 Change-Id: I0b1151d9ba3d0ff903f72e27850306406e5cb518 Reviewed-on: https://go-review.googlesource.com/c/go/+/380914 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
C archives for packages in GOROOT are shipped along with binary releases of the Go toolchain. Although we build the toolchain with GOROOT_FINAL set, we don't know actually know where the release will be installed: the user's real GOROOT can differ arbitrarily from our GOROOT_FINAL. (In the specific case of toolchains installed through golang.org/dl wrappers, the release's GOROOT_FINAL is /usr/local/go but the actual GOROOT to which the release is installed is $HOME/sdk/$(go env GOVERSION).) Fixes golang#50183 Updates golang#48319 Change-Id: If10a42f90c725300bbcb89c3b5b01a2d93ab6ef7 Reviewed-on: https://go-review.googlesource.com/c/go/+/380915 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
It reproduces with the latest beta of 1.18. However, it is fine with go 1.17.5!
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I tried to compile this program:
What did you expect to see?
I expected it to compile with go 1.18 as it compiles with go 1.17
What did you see instead?
I got the following error:
The text was updated successfully, but these errors were encountered: