-
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/internal/work, cmd/cgo: duplicate libobjc library with 2 or more cgo packages with Objective-C #67799
Comments
In the general case we can't drop duplicate libraries, because traditional Unix linkers search the library at a specific point on the command line. It's normal for people to write things like |
Okay, sounds like on darwin hosts we should pass in the flags to disable the warnings. Is this something that would need to be done by the next release? |
Note that if the linker in older Xcode 14 doesn't support the same flag to disable the warning, such that passing it unconditionally causes an error (as mentioned in [2]), then that needs to be taken into account. This is a warning that doesn't prevent successful compilation of programs, and it's been around since last year (Xcode 15 was publicly released in September 2023). I think this would be good to fix when possible, since |
We can pass the flag in the Go linker to the C linker only when the flag is supported. That said, as |
Is that the preferred solution? To just pass in -lobjc once? |
Personally I would prefer passing The duplicate libraries warning doesn't seem to be really helpful anyway. But as the Apple linker decides to emit it, if we don't have a strong reason to suppress it, we may well just keep it. If there is a reason that it is hard for us to avoid passing a |
If I'm understanding this correctly, this seems like something we'd have to fix in cmd/link, right? My understanding is that the go command passes in |
Instead of writing a As @ianlancetaylor mentioned above, generally it is not always okay to dedup C linker flags. But for the case of |
Go version
go version go1.22.3 darwin/arm64
Output of
go env
in your module/workspaceWhat did you do?
Consider a minimal program that involves at least two cgo packages, both of which with Objective-C code:
I tried to build it on macOS Sonoma 14.5 with Xcode 15.4 without custom flags:
What did you see happen?
A warning is printed:
What did you expect to see?
No warning printed.
I believe this is a minified reproduce for an issue like fyne-io/fyne#4502.
The duplicate library outcome for 2+ cgo packages with Objective-C has likely been happening for a while, but what's changed recently is that the new linker in Xcode 15 causes the duplicate library to be printed as a warning unless
-ldflags=-extldflags=-Wl,-no_warn_duplicate_libraries
is used to disable duplicate library warnings. See [1], [2].[1]: issue #61229 ("cmd/link: issues with Apple's new linker in Xcode 15 beta")
[2]: https://indiestack.com/2023/10/xcode-15-duplicate-library-linker-warnings/
CC @matloob, @cherrymui.
The text was updated successfully, but these errors were encountered: