-
Notifications
You must be signed in to change notification settings - Fork 17.4k
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/link: support -linkmode=internal with Cgo #38918
Comments
Copying from my comment on #38917 : Some cgo code relies on libraries that are written in C++. C++ code requires extra work from the linker to support things like global constructors and destructors and exception handling. If we can't invoke the external linker, we have to implement all of that code in cmd/link, and we have to maintain it as C++ changes. This can be done, of course. I've done it myself in projects like the gold linker. But it's hard. |
We might be able to handle this specific case of R_X86_64_64. Instead of supporting the full C/C++ linking, if you have a list of relocations that you need support, and not involving C++, we may be able to do that. |
That is a good point: we can likely do a better job of supporting pure C libraries that don't use |
The interesting targets for me are iOS, macOS, Android, and to a lesser extent Linux. I've updated the original report with the errors reported when internal linking is forced. Thank you. |
For experimenting with golang/go#38918. Signed-off-by: Elias Naur <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
linux/amd64:
darwin/amd64 with
applied:
android/*, buildmode=c-shared:
With
the
gogio -target android
build completes, but the resulting apk fails at runtime with:(e_type 2 is ET_EXEC, the loader expects ET_DYN)
darwin/arm64 (iOS):
With
What did you expect to see?
A running program.
What did you see instead?
Link errors.
By itself,
-linkmode=internal
doesn't seem important when using Cgo, but in combination with #38917 internal linking is a crucial step towards dropping the native toolchain altogether.The text was updated successfully, but these errors were encountered: