Skip to content

cmd/compile: incomplete relocation support on ppc64le #53345

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

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

cmd/compile: incomplete relocation support on ppc64le #53345

nehaljwani opened this issue Jun 13, 2022 · 6 comments
Assignees
Labels
arch-ppc64x compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest Issues asking for a new feature that does not need a proposal. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@nehaljwani
Copy link
Contributor

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

@golang/ppc64 @laboger

@mengzhuo mengzhuo added the FeatureRequest Issues asking for a new feature that does not need a proposal. label Jun 13, 2022
@pmur
Copy link
Contributor

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 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

Hello @pmur, we use:

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

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 15, 2022
@pmur pmur self-assigned this Jun 16, 2022
@gopherbot
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
@mknyszek mknyszek moved this to Triage Backlog in Go Compiler / Runtime Jul 15, 2022
@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Repository owner moved this from Triage Backlog to Done in Go Compiler / Runtime Sep 15, 2022
@dmitshur dmitshur modified the milestones: Unplanned, Go1.20 Sep 26, 2022
gopherbot pushed a commit that referenced this issue Oct 5, 2022
Indirect branches are much more expensive than direct. If the call is
known to be local, we can replace most of the operations with a nop,
and call directly.

Updates #53345

Change-Id: Icfff9ec1f6c7f8e4181f0f28976033308d2f53eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/412715
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-ppc64x compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest Issues asking for a new feature that does not need a proposal. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

7 participants