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/go: Problems with cross-compiling gccgo - go tool is in target and not in source format #10310

Closed
samm-git opened this issue Apr 1, 2015 · 3 comments

Comments

@samm-git
Copy link

samm-git commented Apr 1, 2015

Hi.
I am trying to build go cross compilation toolchain for the powerpcspe arch. I am using snapshot of GCC5 and crosstool-ng. GCCGO builds and run just fine, but "go" command is built for the target arch, so i cant use it on the build host. Here is an example, correct arch, g++:

builder@5dc5de8d9844:~$ file x-tools/powerpc-e500v2-linux-gnuspe/bin/powerpc-e500v2-linux-gnuspe-gcc
x-tools/powerpc-e500v2-linux-gnuspe/bin/powerpc-e500v2-linux-gnuspe-gcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xa447f175ef636962a6445e2cd8579371abb23898, stripped

Correct arch, gccgo:

builder@5dc5de8d9844:~$ file x-tools/powerpc-e500v2-linux-gnuspe/bin/powerpc-e500v2-linux-gnuspe-gccgo
x-tools/powerpc-e500v2-linux-gnuspe/bin/powerpc-e500v2-linux-gnuspe-gccgo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x3f95ab813c5f38204fc1938fc61a28c6e56cc4c0, stripped

Wrong arch, go tool:

builder@5dc5de8d9844:~$ file x-tools/powerpc-e500v2-linux-gnuspe/bin/powerpc-e500v2-linux-gnuspe-go
x-tools/powerpc-e500v2-linux-gnuspe/bin/powerpc-e500v2-linux-gnuspe-go: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.9.11, with unknown capability 0x41000000 = 0x11676e75, with unknown capability 0x10000 = 0x90402, not stripped

Because of this limitation i am unable to compile anything for the target platform if "go" is required. What do i need to get "go" tool in native format usable for crosscompilation?

@ianlancetaylor
Copy link
Contributor

The go tool is not inherently target-specific. You will have to build a version of the go tool for your build system, and use that go tool with your cross-compiler. For example, you can set the GCCGO environment variable to tell the go tool which compiler to use when building. Building the go tool as part of gccgo is quite new, and it is likely that you will run into trouble. Please report specific problems that you discover as specific issues. Thanks.

@mikioh mikioh changed the title Problems with cross-compiling gccgo - go tool is in target and not in source format cmd/go: Problems with cross-compiling gccgo - go tool is in target and not in source format Apr 2, 2015
@samm-git
Copy link
Author

samm-git commented Apr 2, 2015

Thank you for reply :) I compiled "go" for the buildhost and it works fine. I created "gocross.env" script which sets all required variables:

alias gccgo='/opt/turris/x-tools/powerpc-turris-linux-gnuspe/bin/powerpc-turris-linux-gnuspe-gccgo'
alias go='/opt/turris/x-tools/x86_64-turris-linux-gnu/bin/x86_64-turris-linux-gnu-go'
declare -x GCCGO="/opt/turris/x-tools/powerpc-turris-linux-gnuspe/bin/powerpc-turris-linux-gnuspe-gccgo"
declare -x GOARCH="ppc"
declare -x GOPATH="/opt/turris/go-packages-ppc/"
declare -x GOROOT="/opt/turris/x-tools/powerpc-turris-linux-gnuspe/powerpc-turris-linux-gnuspe/sysroot/lib/go/5.0.0/powerpc-turris-linux-gnuspe"
declare -x CC="/opt/turris/x-tools/powerpc-turris-linux-gnuspe/bin/powerpc-turris-linux-gnuspe-gcc"
declare -x CXX="/opt/turris/x-tools/powerpc-turris-linux-gnuspe/bin/powerpc-turris-linux-gnuspe-g++"

And everything works as expected. It should be fine to document this somewhere, i will probably do a blog post about cross compiling with gccgo.

@davecheney
Copy link
Contributor

Please, please, blog about this.

On 2 Apr 2015, at 16:38, Alex Samorukov notifications@github.com wrote:

Thank you for reply :) I compiled "go" for the target and it works fine. I created "gocross.env" script which sets all required variables:

alias gccgo='/opt/turris/x-tools/powerpc-turris-linux-gnuspe/bin/powerpc-turris-linux-gnuspe-gccgo'
alias go='/opt/turris/x-tools/x86_64-turris-linux-gnu/bin/x86_64-turris-linux-gnu-go'
declare -x GCCGO="/opt/turris/x-tools/powerpc-turris-linux-gnuspe/bin/powerpc-turris-linux-gnuspe-gccgo"
declare -x GOARCH="ppc"
declare -x GOPATH="/opt/turris/go-packages-ppc/"
declare -x GOROOT="/opt/turris/x-tools/powerpc-turris-linux-gnuspe/powerpc-turris-linux-gnuspe/sysroot/lib/go/5.0.0/powerpc-turris-linux-gnuspe"
declare -x CC="/opt/turris/x-tools/powerpc-turris-linux-gnuspe/bin/powerpc-turris-linux-gnuspe-gcc"
declare -x CXX="/opt/turris/x-tools/powerpc-turris-linux-gnuspe/bin/powerpc-turris-linux-gnuspe-g++"
And everything works as expected. It should be fine to document this somewhere, i will probably do a blog post about cross compiling with gccgo.


Reply to this email directly or view it on GitHub.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
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