-
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
cmd/link: relocation error on ppc64le musl with cgo and CGO_CFLAGS=-Os #52336
Comments
Interesting. Presumably this causes the C compiler to emit symbols (like A workaround is to try On #51787 (comment) you also mentioned "unexpected trampoline for shared or dynamic linking" errors. When/how could that happen? Could you provide the command line for that one? Thanks. |
That does seem to work, yes.
I debugged this a bit further and since it seems that different flags are needed to reproduce the two I decided to create two separate issues. I hope that's ok. The other issue is #52337. |
This re-enables 866f2e1. While Go 1.18.1 fixed the initial linking error we encountered with Go 1.18 on ppc64le it seems there are two more regressions with -buildmode=pie and CGO_CFLAGS=-Os. See: * golang/go#52336 * golang/go#52337 Forcing external link mode seems to be a workaround for now. Fixes #13692
This is a PPC64 (and likely -Os) only quirk. binutils ld generates these symbols. Also, I noticed the project in question uses a makefile which explicitly requests external linking. @nmeum is alpine using the project supplied makefile? @Cherry should I be matching this behavior in the internal linker? These functions are part of the PPC64 ELF ABIs. |
I think it is okay to require external linking for some C compiler flags. However, it would be nice to support ones that are system default. How complex that would be to add the support? Thanks. |
Yep, Alpine is using |
I think it is feasible support generating those ABI functions when linking internally. I'll make a patch. |
Change https://go.dev/cl/400796 mentions this issue: |
Change https://go.dev/cl/400796 mentions this issue: |
Change https://go.dev/cl/401114 mentions this issue: |
This is a follow-up for #51787.
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?
This is issue we encountered when packaging Go software for Alpine Linux Edge ppc64le. On all other architectures, supported by Alpine, the affected Go software builds fine but on ppc64le it fails with a relocation error (which makes me think that this is related to #51787).
This issue only seems to appear with
-Os
in theCGO_CFLAGS
environment variable (keep in mind though many wrappers aroundgo build
, e.g. Makefiles, setCGO_FLAGS=$CFLAGS
). Without settingCGO_CFLAGS
the software builds fine.For example:
I have not yet been able to produce a minimal example but this seems to affect a lot of software #51787 (comment) has more examples. Let me know if you need me to provide more information.
What did you expect to see?
A successful build.
What did you see instead?
CC: @pmur, @cherrymui
The text was updated successfully, but these errors were encountered: