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/link: RISC-V external link, failed to find text symbol for HI20 relocation #65646

Closed
Xeonacid opened this issue Feb 10, 2024 · 8 comments
Closed
Assignees
Labels
arch-riscv Issues solely affecting the riscv64 architecture. compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Xeonacid
Copy link

Xeonacid commented Feb 10, 2024

Go version

go version go1.22.0 linux/riscv64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='riscv64'
GOBIN=''
GOCACHE='/home/xeonacid/.cache/go-build'
GOENV='/home/xeonacid/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS='-buildmode=pie -ldflags=-linkmode=external'
GOHOSTARCH='riscv64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/xeonacid/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/xeonacid/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_riscv64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/xeonacid/rekor/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build549560519=/tmp/go-build -gno-record-gcc-switches'

What did you do?

export GOFLAGS="-buildmode=pie -ldflags=-linkmode=external"
git clone https://github.com/sigstore/rekor -b v1.3.5 --depth 1
cd rekor
go build -o cmd/rekor-server/rekor-server cmd/rekor-server/main.go

What did you see happen?

# command-line-arguments
failed to find text symbol for HI20 relocation at 16198024 (f72988)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to runtime.morestack_noctxt
failed to find text symbol for HI20 relocation at 16198076 (f729bc)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to regexp.MustCompile
failed to find text symbol for HI20 relocation at 16198096 (f729d0)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to runtime.gcWriteBarrier2
failed to find text symbol for HI20 relocation at 16198128 (f729f0)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to github.com/aws/aws-sdk-go/aws/endpoints.map.init.0
failed to find text symbol for HI20 relocation at 16198136 (f729f8)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to github.com/aws/aws-sdk-go/aws/endpoints.init.func1
failed to find text symbol for HI20 relocation at 16198156 (f72a0c)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to runtime.gcWriteBarrier2
failed to find text symbol for HI20 relocation at 16198188 (f72a2c)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to runtime.makemap_small
failed to find text symbol for HI20 relocation at 16198228 (f72a54)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to runtime.duffzero
failed to find text symbol for HI20 relocation at 16198280 (f72a88)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to runtime.newobject
failed to find text symbol for HI20 relocation at 16198356 (f72ad4)
github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to runtime.newobject
failed to find text symbol for HI20 relocation at 16198448 (f72b30)
/usr/lib/go/pkg/tool/linux_riscv64/link: too many errors

What did you expect to see?

Build successfully.
A successor of #62465 , but no the same issue.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Feb 10, 2024
@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 12, 2024
@mauri870 mauri870 added the arch-riscv Issues solely affecting the riscv64 architecture. label Feb 12, 2024
@mauri870
Copy link
Member

We are facing the same issue in rqlite/rqlite#1682.

@mauri870
Copy link
Member

cc @golang/riscv64 @golang/compiler

@mauri870
Copy link
Member

As an update, this failure seems to go away if I revert CL 520095.

@cherrymui
Copy link
Member

That CL addresses #62465, so we probably could not simply revert.

@4a6f656c 4a6f656c self-assigned this Feb 26, 2024
@gopherbot
Copy link

Change https://go.dev/cl/567375 mentions this issue: cmd/link/internal/riscv64: generate local text symbols for R_RISCV_CALL

algitbot pushed a commit to alpinelinux/aports that referenced this issue Feb 28, 2024
Build fails with following errors:

> failed to find text symbol for HI20 relocation at 17057632 (1044760)
> github.com/aws/aws-sdk-go/aws/endpoints.init: unsupported obj reloc 62 (R_RISCV_CALL)/8 to runtime.morestack_noctxt
> [...]
> failed to find text symbol for HI20 relocation at 17058056 (1044908)
> /usr/lib/go/pkg/tool/linux_riscv64/link: too many errors
> >>> ERROR: grype: build failed

Relevant issue for Go compiler: golang/go#65646
@4a6f656c
Copy link
Contributor

4a6f656c commented Mar 1, 2024

@cherrymui seems like something we could/should backport?

It can be avoided/worked around by using internal linking, rather than forcing external linking.

@cherrymui
Copy link
Member

I think it is reasonable to backport. Internal linking is not the default mode, and has limitations.

@gopherbot please backport this to Go 1.22. Thanks.

@gopherbot
Copy link

Backport issue(s) opened: #66060 (for 1.22).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

algitbot pushed a commit to alpinelinux/aports that referenced this issue Mar 3, 2024
Go does not support internal linking while -buildmode=pie on riscv64.
Enable CGO on riscv64 as well.

See: golang/go#65646
bell-sw pushed a commit to bell-sw/alpaquita-aports that referenced this issue Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-riscv Issues solely affecting the riscv64 architecture. compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

7 participants