-
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: always pass -lang to cmd/compile #66092
Comments
This is closely related to
However, in the absence of any |
CC @golang/compiler |
@bcmills |
In runtime/compiler triage, we think this is a Go command issue? Is that right? Thanks. |
I think it is a composite of a The |
-lang
is not set
Will this be fixed in 1.22.3+? |
When no -lang is specified, in general we don't know how to interpret cc: @rsc for input. |
Is it a good idea to use the version of the |
@go101 Is the top comment wrong? It says got true, expected false for |
I mean the |
I'm just trying to puzzle through this all since I don't know what "gotv 1.22." does either... |
|
For future bug reports it would help to use reproduction instructions that are limited to standard tooling. |
Here is a clearer reproduction case:
|
CL 567435 in progress should fix this. The fix is to just make sure that cmd/go passes -lang to the compiler always. I looked into changing what the compiler does when -lang is empty, but right now it intentionally ignores the //go:build lines to avoid downgrades, and for good reason (for example see GOROOT/src/internal/types/testdata/check/go1_xx_19.go). If we change the compiler, we risk breaking other uses of the compiler like Bazel. And the go command needs the logic anyway to help cmd/vet, so we might as well just make sure the go command always makes the decision. |
-lang
is not set
Change https://go.dev/cl/567435 mentions this issue: |
Change https://go.dev/cl/593156 mentions this issue: |
Will this be backported to 1.22 and 1.23? |
@gopherbot pretty please backport this to 1.21 and 1.22 |
Backport issue(s) opened: #68048 (for 1.21), #68049 (for 1.22). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/593315 mentions this issue: |
Change https://go.dev/cl/593295 mentions this issue: |
Change https://go.dev/cl/593297 mentions this issue: |
Go 1.17 is long since out. Furthermore, CL 516575 added a use of parser.SkipObjectResolution to a file with a go1.16 build constraint. This used to be fine, but not now that vet checks for this (see go.dev/issue/66092) since that API is new to Go 1.17. For golang/go#66092. Change-Id: I749b2aa52e02308415c27028be15a436ee11d95c Reviewed-on: https://go-review.googlesource.com/c/tools/+/593297 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Sam Thanawalla <samthanawalla@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change https://go.dev/cl/593376 mentions this issue: |
Pull in CL 593297: f2d2ebe4 go/analysis/passes/buildtag: retire Go 1.15 support Along with other changes that have landed into x/tools. This fixes a vet failure reported on longtest builders. For #66092. Change-Id: I549cc3f8e2c2033fe961bf014ff8cc1998021538 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/593376 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
@zigo101 We're looking into backporting it, but we'd like more information to see if this meets the bar to be backported. The backports policy states that backports should be "fixes for security issues, serious problems with no workaround, and documentation fixes". This isn't a security issue or documentation fix, so the question is whether this is a serious problem with no workaround. Could you give us more information about whether this is a serious problem with no workaround? |
Personally, I think it is a serious problem with no workaround. |
Hi @zigo101, could you provide more information about what your use case is and why there is no workaround? |
The example in the first comment of this thread is my use case. What is the workaround do you think? |
Hi, the workaround would depend on the environment your programs is running in, what the program does, why you can't modify the programs, etc. The best workaround would be to put your each of your single file programs in a module and run the program as a package instead of passing in individual files to the go command. If your program depends on the semantics of the version of Go it's being run under, that's your best bet, and I would recommend doing that even after this change is in. What this change does is always pass There are other, less desirable, things you could do to get your builds to work: for example, you could pass in the |
Okay, let me explain it clearly. I have written many Go books and tutorials. I just want to show gophers that how to use Without the fix for v1.22 and v1.23, it is hard to say v1.22 and v1.23 don't break Go 1 promise of compatibility. |
BTW, maybe it is meaningless to backport this to 1.21. |
@zigo101 Thanks for your explanation. Unfortunately this doesn't meet the bar for backporting. It doesn't seem like there are user workflows that are broken by the incorrect behavior with |
Maybe, The Persnoally, I just hope this fix can be backported, to let your Go dev get a better reputation on code quality. This will not affect my production code, because I'm fully aware all the problems caused I will help you make this known to my readers on my website, books and social platforms. |
@zigo101 I'm sorry, I know it's frustrating. Thanks for looking out for Go developers and sharing this with your audience. You're doing the community a solid. |
Just found this fix has been merged into v1.23rc1. Interesting, so it is worth being merged into 1.23, but not 1.22. |
@zigo101 When fixes are made, they're included in the next major release. That is the default, and this resolved issue is in the Go1.23 milestone. Only in rare cases when it is deemed necessary they are also backported to currently supported major releases (1.22 and 1.21 at this time). See https://go.dev/s/release and https://go.dev/wiki/MinorReleases for more information on the Go release process. |
Okay, glad to know it is deliberately. |
Go version
go version go1.22.0 linux/amd64
Output of
go env
in your module/workspace:.
What did you do?
main.go:
What did you see happen?
What did you expect to see?
Note that when the
-gcflags=-lang=go1.22
compiler flag is specified, then the "//go:build go1.xy" comment directive is respected (go run .
with a go.mod file also respects it).The text was updated successfully, but these errors were encountered: