-
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
cmd/go: ld: building for macOS, but linking in object file built for iOS #57397
Comments
Ran into this on Friday after upgrading from |
It sounds like once this problem occurs, it is repeatable. If so, then when it happens again, run with |
@simbadMarino could you show exactly what commands you run, including the |
Sure, thanks for the help!! and quick response :) @cherrymui I'm attaching the output with -x flag. I'm inspecting the binary .an objects (c-archives) . The command I'm using to inspect them is: |
What is the content of your clangwrap.sh?
In your output I see C compilation failures above, which looks like the C toolchain seg faulted, which seems like a bug in the C toolchain. Also, please paste output as plain text, no color or rich format. Thanks. |
@cherrymui My clangwrap:
Adding the file again as plain text I haven't noticed any segmentation faults before without adding the -x flag! :/ |
Without the -x flag, the seg fault is probably still there but not printed to users. Either way, seg fault in C toolchain is clearly unexpected. There is probably a bug in the C toolchain or the SDK. Maybe you could try setting CGO_CFLAGS=-v CGO_LDFLAGS=-v and see if it prints anything useful. Also maybe try a different version of the C toolchain or SDK. |
I noticed that by removing the Good news is that after trying the verbose option for CGO as you suggested Im getting the following: Linking error is pointing to a specific library(go-libutp), I'll dig into it and report how it goes :) Thanks again for all the support @cherrymui ! |
Okay, https://github.com/anacrolix/go-libutp has C++ files, which may be compiled targeting macOS instead of iOS. Try setting the |
You were right! by adding the CXX flag pointing to clang fixed my issue!, additional to this starting from go 1.20 if you are linking a c-archive binary with net dependency you need to add I case someone else need this below you can see how I ended up configuring my make and Xcode : make:
Xcode Build settings (add -lresolv flag under Other linker flags): Thanks a lot for the support @cherrymui ! , without your advice I would be still clueless 👍 |
Go 1.19.4
When building our application, a few of us occasionally get the error:
And the only way to recover is to do a
go clean -cache
and build again.We haven't figured out more than that, yet. And we don't have an on-demand repro.
Just filing this now in case anybody has any ideas.
Like, maybe piece of the environment is missing from the cache signature? Maybe an empty file is being created that's being interpreted as iOS instead of macOS?
But that error message is not a Go thing at all. I see tons of Google results for other languages. But maybe
cmd/go
can detect whatever broken state its input is in and ignore that input file and rebuild it instead? Totally guessing./cc @ianlancetaylor who likes linkers :)
The text was updated successfully, but these errors were encountered: