-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
ARM64(M1 Mac) - bad CPU type in executable cgo #64750
Comments
Cgo is supported on darwin/arm64, what is the output of clang --version? It does appear that your clang is x86-64. Also, can you share a trimmed down reproducer and the commands used to build so we can try to reproduce the issue? Thanks. |
Clang version
Reproduced OutputWhen developing I use the
|
I think I solved the problem: After removing that line from the My question is how does cgo/go choose which clang version to use if multiple are installed? Is it the one that is exported in the shell that is automatically selects? This context may be important for others that run into the same problem |
That appears to be an issue with your PATH, you had multiple versions of clang installed and probably Go was picking the wrong one. On Go's side it uses the compiler you have exported in CC, but that might not be the one you want if you have multiple versions in your path. You can always use the absolute path to CC if you want more control in this case. I'm glad you fixed it. For questions please refer to https://github.com/golang/go/wiki/Questions |
Go version
go version go1.21.5 darwin/arm64
What operating system and processor architecture are you using (
go env
)?What did you do?
Hi, I have just set up my M1 mac and am having trouble running a go project that I had originally built using an Intel based mac
I downloaded the latest version of Go and Pulled down the repo
Project Set up and Installed Dependencies
More info
This project leverages Sqlite so I understand where the cgo dependency is needed. Am I missing a step in my go installation to link to the correct C compiler?
Dependencies that the project is pulling in from
go.mod
:What did you expect to see?
Program executes, in this instance a web server.
What did you see instead?
Stack trace
Related Issues:
Somewhat similar, different stack trace:
#45772
Same error building docker compose which is a go based project:
docker/for-mac#6232
Solution seemed to be:
But is x86 -> arm64 translation needed for such a simple project/build?
The text was updated successfully, but these errors were encountered: