Skip to content
This repository was archived by the owner on Nov 27, 2017. It is now read-only.

go: unknown relocation type 42; compiled without -fpic? #1057

Closed
2 of 3 tasks
xu-cheng opened this issue Apr 8, 2016 · 8 comments
Closed
2 of 3 tasks

go: unknown relocation type 42; compiled without -fpic? #1057

xu-cheng opened this issue Apr 8, 2016 · 8 comments

Comments

@xu-cheng
Copy link
Contributor

xu-cheng commented Apr 8, 2016

From @int03h on April 8, 2016 15:16

Trying to brew install go on debian SID .. (I did try it on testing too) .. it does compile natively on the OS, not problem. ( tried with and without export HOMEBREW_BUILD_FROM_SOURCE=1)

I compiled ethereum-cpp successfully but I can't get GETH ( go version to compile because of it's dependency on golang )

  • Ran brew update and retried your prior step?
  • Ran brew doctor, fixed as many issues as possible and retried your prior step?
  • If you're seeing permission errors tried running sudo chown -R $(whoami) $(brew --prefix)?

https://gist.github.com/1b3367f01fd05e67af2c027782cab3f9

/tmp/go20160408-29305-1dninkg/go/gobootstrap/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
/tmp/go20160408-29305-1dninkg/go/gobootstrap/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
runtime/cgo(.text): unexpected relocation type 298
runtime/cgo(.text): unexpected relocation type 298
# cmd/go
/tmp/go20160408-29305-1dninkg/go/gobootstrap/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
/tmp/go20160408-29305-1dninkg/go/gobootstrap/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
runtime/cgo(.text): unexpected relocation type 298
runtime/cgo(.text): unexpected relocation type 298

thanks!
int

Copied from original issue: Homebrew/brew#48

@sjackman sjackman changed the title brew install go go: unknown relocation type 42; compiled without -fpic? Apr 8, 2016
@sjackman
Copy link
Member

sjackman commented Apr 8, 2016

I have seen other issues with this error message reported. Try
brew install binutils go
I'm not convinced that will work, but it's worth a shot.

@sjackman
Copy link
Member

sjackman commented Apr 8, 2016

It looks as though this issue is known upstream. See
golang/go#13114
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=807136

@sjackman
Copy link
Member

sjackman commented Apr 8, 2016

Maybe my binutils guess is correct. See #1057

Your system linker (/usr/bin/ld) is not up to date with your compiler/assembler. It's not a Go problem at all.

Please report /usr/bin/ld --version

@int03h
Copy link

int03h commented Apr 8, 2016

HI thanks for all the help! :)

I did see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=807136 but I assumed that it would be "handled" by brew since it's installed in the native environment - i.e. it is buildable (somehow)

doing a dpkg -l :

ii  go                                     1.6-godeb1                   amd64        Go language compiler and tools (gc)

testing :
brew reinstall binutils go

==> Reinstalling binutils
==> Downloading http://ftpmirror.gnu.org/binutils/binutils-2.26.tar.gz
Already downloaded: /root/.cache/Homebrew/binutils-2.26.tar.gz
==> ./configure  --with-sysroot=/ --prefix=/root/.linuxbrew/Cellar/binutils/2.26
==> make
==> make install
/root/.linuxbrew/Cellar/binutils/2.26: 3,178 files, 192.2M, built in 1 minute 50 seconds
==> Reinstalling go
==> Downloading https://storage.googleapis.com/golang/go1.6.src.tar.gz
Already downloaded: /root/.cache/Homebrew/go-1.6.tar.gz
==> Downloading https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
Already downloaded: /root/.cache/Homebrew/go--gobootstrap-64.tar.gz
==> ./make.bash --no-clean
Last 15 lines from /root/.cache/Homebrew/Logs/go/01.make.bash:
net/http/pprof
cmd/pprof
net/rpc
net/http/fcgi
net/rpc/jsonrpc
# cmd/pprof
/tmp/go20160408-30952-xu75d5/go/gobootstrap/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
/tmp/go20160408-30952-xu75d5/go/gobootstrap/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
runtime/cgo(.text): unexpected relocation type 298
runtime/cgo(.text): unexpected relocation type 298
# cmd/go
/tmp/go20160408-30952-xu75d5/go/gobootstrap/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
/tmp/go20160408-30952-xu75d5/go/gobootstrap/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
runtime/cgo(.text): unexpected relocation type 298
runtime/cgo(.text): unexpected relocation type 298

i.e. it throws the same errors.

root@crunk:/# /usr/bin/ld --version

GNU ld (GNU Binutils for Debian) 2.26

and root@crunk:/# /root/.linuxbrew/bin/ld -v

GNU ld (GNU Binutils) 2.26.20160125

Thanks!

@sjackman
Copy link
Member

sjackman commented Apr 8, 2016

This comment golang/go#13114 (comment) mentions setting the environment variable CGO_ENABLED=0, but I believe that has to be done when compiling go 1.4, and we download a binary of go 1.4, used to bootstrap go 1.5.

@sjackman
Copy link
Member

sjackman commented Apr 8, 2016

Perhaps I misunderstood though. Try

CGO_ENABLED=0 brew install go

@int03h
Copy link

int03h commented Apr 8, 2016

Fixed !

root@crunk:~# CGO_ENABLED=0 brew install go
==> Downloading https://storage.googleapis.com/golang/go1.6.src.tar.gz
Already downloaded: /root/.cache/Homebrew/go-1.6.tar.gz
==> Downloading https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
Already downloaded: /root/.cache/Homebrew/go--gobootstrap-64.tar.gz
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> /root/.linuxbrew/Cellar/go/1.6/bin/go install -race std
==> Cloning https://go.googlesource.com/tools.git
Cloning into '/root/.cache/Homebrew/go--gotools--git'...
remote: Sending approximately 10.68 MiB ...
remote: Counting objects: 774, done
remote: Finding sources: 100% (5/5)
remote: Total 15898 (delta 10660), reused 15896 (delta 10660)
Receiving objects: 100% (15898/15898), 10.28 MiB | 8.95 MiB/s, done.
Resolving deltas: 100% (10660/10660), done.
Checking connectivity... done.
==> Checking out branch release-branch.go1.6
==> go build
==> go build
==> Caveats
As of go 1.2, a valid GOPATH is required to use the `go get` command:
  https://golang.org/doc/code.html#GOPATH

You may wish to add the GOROOT-based install location to your PATH:
  export PATH=$PATH:/root/.linuxbrew/opt/go/libexec/bin

after setting PATH and logout ..

root@crunk:~# which go
/root/.linuxbrew/bin/go
root@crunk:~# go version
go version go1.6 linux/amd64

Thanks!

@sjackman sjackman self-assigned this Apr 8, 2016
@sjackman sjackman added ready and removed help wanted labels Apr 8, 2016
@sjackman
Copy link
Member

sjackman commented Apr 8, 2016

Great!

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

3 participants