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

x/sys/unix: go get -u -linkshared -buildmode=shared golang.org/x/sys/unix results in error: call to `syscall.Syscall' lacks nop, can't restore toc; recompile with -fPIC #16662

Closed
laboger opened this issue Aug 10, 2016 · 4 comments

Comments

@laboger
Copy link
Contributor

laboger commented Aug 10, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version devel +ff37d0e Tue Aug 9 17:13:43 2016 +0000 linux/ppc64le
  2. What operating system and processor architecture are you using (go env)?
    ppc64le Ubuntu 16.04
  3. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.
    Set up a directory and set the GOPATH to it.
    go install -buildmode=shared std
    go get -u -linkshared -buildmode=shared golang.org/x/sys/unix
  4. What did you expect to see?
    No output, correct shared library built for golang.org/x/sys/unix.
  5. What did you see instead?
    go get -u -linkshared -buildmode=shared golang.org/x/sys/unix
    //# /tmp/go-build737614428/libgolang.org-x-sys-unix.so
    /home/boger/golang/upstream/go/pkg/tool/linux_ppc64le/link: running gcc failed: exit status 1
    /usr/bin/ld: /tmp/go-link-742945850/go.o: In function local.golang.org/x/sys/unix.Syscall': go.go:(.text+0x1b4c8): call tosyscall.Syscall' lacks nop, can't restore toc; recompile with -fPIC
    /usr/bin/ld: go.go:(.text+0x1b4c8): unresolvable R_PPC64_REL24 against syscall.Syscall' /usr/bin/ld: /tmp/go-link-742945850/go.o: In functionlocal.golang.org/x/sys/unix.Syscall6':
    go.go:(.text+0x1b4d8): call to syscall.Syscall6' lacks nop, can't restore toc; recompile with -fPIC /usr/bin/ld: go.go:(.text+0x1b4d8): unresolvable R_PPC64_REL24 againstsyscall.Syscall6'
    /usr/bin/ld: /tmp/go-link-742945850/go.o: In function local.golang.org/x/sys/unix.RawSyscall': go.go:(.text+0x1b4e8): call tosyscall.RawSyscall' lacks nop, can't restore toc; recompile with -fPIC
    /usr/bin/ld: go.go:(.text+0x1b4e8): unresolvable R_PPC64_REL24 against syscall.RawSyscall' /usr/bin/ld: /tmp/go-link-742945850/go.o: In functionlocal.golang.org/x/sys/unix.RawSyscall6':
    go.go:(.text+0x1b4f8): call to syscall.RawSyscall6' lacks nop, can't restore toc; recompile with -fPIC /usr/bin/ld: go.go:(.text+0x1b4f8): unresolvable R_PPC64_REL24 againstsyscall.RawSyscall6'
    /usr/bin/ld: final link failed: Bad value
    collect2: error: ld returned 1 exit status
@mwhudson
Copy link
Contributor

Some BRs need to become BLs I bet.

@laboger
Copy link
Contributor Author

laboger commented Aug 11, 2016

Hmm thought I tried that a few weeks ago and it didn't work, but now it does. I'll create a fix for it.

@laboger
Copy link
Contributor Author

laboger commented Aug 11, 2016

I think there might be a problem with doing that, because the code in zsyscall_linux_ppc64le.go needs the LR to be correct, and if I change the BRs to BLs in asm_linux_ppc64x.s then the link register would have to be saved and restored in the asm, which would be unnecessary and bad for performance.
In looking further, I don't understand why zsyscall_linux_ppc64le.go has to call the syscall functions in asm_linux_ppc64x.s which then does a BR to the syscall.Syscall (or syscall.Syscall6, or syscall.RawSyscall, etc.). Couldn't the asm file be avoid altogether and just call syscall.Syscall directly from zsyscall_linux_ppc64le.go?

@quentinmit quentinmit changed the title sys/unix: go get -u -linkshared -buildmode=shared golang.org/x/sys/unix results in error: call to `syscall.Syscall' lacks nop, can't restore toc; recompile with -fPIC x/sys/unix: go get -u -linkshared -buildmode=shared golang.org/x/sys/unix results in error: call to `syscall.Syscall' lacks nop, can't restore toc; recompile with -fPIC Aug 26, 2016
@quentinmit quentinmit added this to the Unreleased milestone Aug 26, 2016
@gopherbot
Copy link

Change https://golang.org/cl/146518 mentions this issue: unix: fix errors in syscalls when using -linkshared

@golang golang locked and limited conversation to collaborators Nov 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants