Skip to content
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/compile: incomplete relocation support on ppc64le #53345

Open
nehaljwani opened this issue Jun 13, 2022 · 6 comments
Open

cmd/compile: incomplete relocation support on ppc64le #53345

nehaljwani opened this issue Jun 13, 2022 · 6 comments
Assignees
Labels
arch-ppc64x FeatureRequest NeedsInvestigation

Comments

@nehaljwani
Copy link
Contributor

@nehaljwani nehaljwani commented Jun 13, 2022

Since 2c4f389c I am unable to compile go with CGO_ENABLED=1 on ppc64le with GCC 10.3.0 and binutils 2.36.1

I see errors like:

/path/to/go/pkg/linux_ppc64le/a/b/c/d.a(_x???.o): unknown relocation type <>; compiled without -fpic?

Where <> are numbers: 31, 60, 119, 120. I am not sure if I am reading this correctly, but these correspond to:
R_PPC_PLT16_HA, R_PPC64_PLT16_LO_DS, R_POWERPC_PLTSEQ, R_POWERPC_PLTCALL and references to these are missing in:

src/cmd/link/internal/loadelf/ldelf.go
src/cmd/link/internal/ppc64/asm.go
src/debug/elf/elf.go
@mengzhuo mengzhuo changed the title Incomplete relocation support on ppc64le cmd/compile: incomplete relocation support on ppc64le Jun 13, 2022
@mengzhuo
Copy link
Contributor

@mengzhuo mengzhuo commented Jun 13, 2022

@golang/ppc64 @laboger

@pmur
Copy link
Contributor

@pmur pmur commented Jun 13, 2022

Hi @nehaljwani, thank you for reporting. Would you be able to share the gcc flags used to compile the C code? A simplified test case would help me. I suspect it just needs to make libc call with the compiler options used on the project.

I am still digging through the linked CI logs trying to understand how the linked utility is being compiled.

A trivial workaround is to explicitly request external linking on ppc64le. This was the behavior prior 1.18 with any cgo usage. I will try to implement these relocs. They are fairly new (introduced with ELFv2 1.5), but I suspect we need to handle with newer GCC.

@pmur
Copy link
Contributor

@pmur pmur commented Jun 13, 2022

@nehaljwani is one of the CFLAG options -fno-plt, or similar option to optimize library calls in C/C++? I can reproduce a similar error using this option.

@nehaljwani
Copy link
Contributor Author

@nehaljwani nehaljwani commented Jun 13, 2022

Hello @pmur, we use:

CGO_CFLAGS=-ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe

@thanm thanm added the NeedsInvestigation label Jun 15, 2022
@pmur pmur self-assigned this Jun 16, 2022
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 16, 2022

Change https://go.dev/cl/412715 mentions this issue: cmd/link: optimize PPC64 inline plt sequences if local

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 16, 2022

Change https://go.dev/cl/412714 mentions this issue: debug/elf, cmd/link: support -fno-plt compiled gcc objects on ppc64le

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-ppc64x FeatureRequest NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

5 participants