-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
runtime: binaries should fail at startup when built with a GOARM64 version not supported on the runtime hardware #69124
Comments
@cespare , thanks for reporting this! I'm the original author of GOARM64 feature, so it's appropriate for me to fix this issue. In general, I fully agree with @cespare proposal -- we should do the same on ARM64 what we do on AMD64, if only for the sake of consistency. @cherrymui , could you, please, assign this on me? |
Change https://go.dev/cl/609855 mentions this issue: |
Go 1.23 introduced GOARM64 environment variable; this patch documents it. Related to golang/go#69124 Change-Id: I148b1295d8772041f2379771a2f2e682fd4bfdbe Reviewed-on: https://go-review.googlesource.com/c/wiki/+/609855 Reviewed-by: Cherry Mui <cherryyz@google.com>
Change https://go.dev/cl/610195 mentions this issue: |
CL with a fix submitted for review: https://go-review.googlesource.com/c/go/+/610195 Note that it only checks presence of LSE extension if compilation targeted it (which is true for all ARM64>=v8.1). Why not all other extensions? Two reasons:
|
@andreybokhanko Let me highlight something I mentioned in the original report: Compiling with a particular GOARM64 value does not only have an effect on the instructions generated by the Go compiler. It also is made available to user code via the |
I also think that checking the required version and features would be better. What is the best way to check the CPU version and features? From https://go-review.googlesource.com/c/go/+/610195/comment/219aedb1_f5d5dd4e/ it sounds like we can only check individual features, and it would be pretty complex to check the version? |
OK, got it. Note, though, that while build tags with an arch version number can be used in theory, in practice this happens extremely rare -- for example, there is just one case in the entire Go compiler + runtime source code base that checks for a specific version of I'm not saying that checking for all possible ARM64 versions + extensions would be a bad thing -- just that in case of ARM64 it's quite cumbersome and error-prone see my comment for details) while relatively low in importance. |
Sure, it's not a super common need. But I don't think it will be that uncommon -- if you are going to the trouble of writing assembly, it is often because you want to squeeze as much performance as possible out of the hardware for a specialized tasks, and using newer instructions on newer hardware is one aspect of that. The |
Go version
go version go1.23.0 linux/arm64
Output of
go env
in your module/workspace:What did you do?
On an arm64 host, I ran
on a simple hello world test.
What did you see happen?
The test ran and passed.
What did you expect to see?
This is on an AWS c7g instance. This is a graviton3 chip. I'm not 100% sure what the exact arm64 architecture version of that chip is (anyone know a good way to tell?), but I'm pretty sure it's v8.x. Someone on Hacker News claims that graviton3 is v8.4. In
/proc/cpuinfo
I seeAnyway, I'm pretty sure that it does not support arm64 v9.5. Yet, the binary I compiled with GOARM64=v9.5 does not check for CPU capabilities and exit on startup.
By contrast, on my local machine (AMD Ryzen 9 3900X) if I run
because my chip only supports GOAMD64=v3.
From the CL 559555 it sounds like GOARM64 support isn't being used in the compiler to do anything yet. However, it's still important that we fix this, because the
arm64.vX.Y
build tags are available to user code. I am able to write code today using (for example) thearm64.v9.3
build tag to guard some v9.3-specific feature; when I run this binary on a v8.0 CPU it won't crash on startup but will hit some invalid instruction later.P.S. It would be good if someone would update some of the wiki pages for GOARM64; in particular, MinimumRequirements and GoArm. I found it a little hard to get info about GOARM64; as far as I can tell, besides the Go 1.23 release notes, the only places it's mentioned are
go help environment
andgo help buildconstraint
./cc @andreybokhanko @cherrymui
The text was updated successfully, but these errors were encountered: