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

gccgo: Trouble cross-compiling to GOARCH=mips using gccgo #18942

Open
elimisteve opened this issue Feb 4, 2017 · 6 comments

Comments

@elimisteve
Copy link
Contributor

commented Feb 4, 2017

What version of Go are you using (go version)?

go version go1.8rc3 linux/amd64

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

I tried cross-compiling a trivial "hello world" Go program -- namely https://github.com/elimisteve/hello/blob/master/hello.go -- with this command:

$ GOOS=linux GOARCH=mips go1.8rc3 build -x -compiler=gccgo .

What did you expect to see?

No output and a successfully-compiled 32-bit MIPS binary in my local directory.

What did you see instead?

$ GOOS=linux GOARCH=mips go1.8rc3 build -x -compiler=gccgo .
WORK=/tmp/go-build262885004
mkdir -p $WORK/github.com/elimisteve/hello/_obj/
mkdir -p $WORK/github.com/elimisteve/hello/_obj/exe/
cd /home/ubuntu/go/src/github.com/elimisteve/hello
/usr/bin/gccgo -I $WORK -c -g -mabi=32 -march=mips32 -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/elimisteve/hello -o $WORK/github.com/elimisteve/hello/_obj/_go_.o ./hello.go
# github.com/elimisteve/hello
gccgo: error: unrecognized argument in option ‘-mabi=32’
gccgo: note: valid arguments to ‘-mabi=’ are: ms sysv

This is using gccgo 6, which installed 'libgo9as a dependency when I ranapt-get install gccgo`.

At https://tip.golang.org/doc/install/gccgo it says,

The GCC 6 releases include a complete implementation of the Go 1.6.1 user libraries. The Go 1.6 runtime is not fully merged, but that should not be visible to Go programs.

so I believe this is supposed to work? Thanks!

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Feb 5, 2017

It looks like your gccgo isn't the cross compiler, i.e. it's targeting the host (amd64) instead of mips. I don't know how to cross compile with gccgo though. You probably needs to set up some environment variable.

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Feb 5, 2017

Maybe apt-get install gccgo-mips-linux-gnu?

@minux

This comment has been minimized.

Copy link
Member

commented Feb 5, 2017

@elimisteve

This comment has been minimized.

Copy link
Contributor Author

commented Feb 5, 2017

@minux Well the key line seems to be

/usr/bin/gccgo -I $WORK -c -g -mabi=32 -march=mips32 -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/elimisteve/hello -o $WORK/github.com/elimisteve/hello/_obj/go.o ./hello.go

which is using gccgo directly. Not sure if I should try xgo or whether building my own cross-compiling version of GCC, a la https://github.com/golang/go/wiki/GccgoCrossCompilation#build-the-cross-compiler, is necessary.

@minux

This comment has been minimized.

Copy link
Member

commented Feb 5, 2017

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Feb 5, 2017

Setting GOOS and GOARCH when running the go tool works to do cross-compiling with the gc toolchain, but it does not work when using the gccgo toolchain. It would be nice to make this work better, but it will never be as simple as it is with the gc toolchain.

@gopherbot gopherbot added this to the Gccgo milestone Mar 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.