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: allow cross-compiling with cgo #5848

Closed
gopherbot opened this issue Jul 8, 2013 · 10 comments
Closed

cmd/go: allow cross-compiling with cgo #5848

gopherbot opened this issue Jul 8, 2013 · 10 comments
Milestone

Comments

@gopherbot
Copy link

by lexszero:

What steps will reproduce the problem?
Build any package using cgo wtih following command:
GOARM=5 GOARCH=arm go build -x

What is the expected output?
Package build process

What do you see instead?
lexs@nyapad ~/.go/src/code.google.com/p/gosqlite/sqlite > GOARM=5 GOARCH=arm go build
-x
WORK=/tmp/go-build982624259

and nothing more. return code is 0

Which compiler are you using (5g, 6g, 8g, gccgo)?
5g

Which operating system are you using?
linux/amd64

Which version are you using?  (run 'go version')
go version devel +1fcddf5fd778 Wed May 22 14:22:50 2013 -0700 linux/amd64

Please provide any additional information below.
Building packages that doesn't using cgo with command above works fine. Manual running
building commands analogous to those issued by 'GOARCH=amd64 go build -x' for the same
package (with replacing 6g to 5g, gcc to arm-none-linux-gnueabi-gcc, fixing cflags, etc)
also works fine, except for absent package 'runtime/cgo', which silently wasn't built
during go installation process for the same reason.
@davecheney
Copy link
Contributor

Comment 1:

I'm sorry but I don't understand the issue you have raised.
As I understand it you are trying to cross compile from linux/amd64 to linux/arm,
specifically for an older ARMv5 based host.
As I also understand, gosqlite requires cgo. It is currently not possible to cross
compile a binary that requires cgo.
Can you please restate the issue that you are seeing.

Status changed to WaitingForReply.

@gopherbot
Copy link
Author

Comment 2 by lexszero:

Yes, you understand the problem correctly.
Why it is not possible to cross-compile a binary that requires cgo?
I was able to cross-compile runtime/cgo and gosqlite package manually without using 'go
build' and it works fine, so the problem is only with the 'go build' tool. Maybe I'll
try to fix this bug and send a patch.

@minux
Copy link
Member

minux commented Jul 8, 2013

Comment 3:

it's a known limitation of cmd/go.

@gopherbot
Copy link
Author

Comment 4 by lexszero:

Fixed by reverting commit 139b5fe32880 (see issue #5104) and setting CC environment
variable. Maybe do this in upstream?

@gopherbot
Copy link
Author

Comment 5 by lexszero:

Fixed by reverting revision 139b5fe32880 (issue #5141) and setting correct CC environment
variable, since cmd/go nowadays don't have 'gcc' harcoded and respects environment.
Better to fix this in upstream.

@minux
Copy link
Member

minux commented Jul 8, 2013

Comment 6:

it is the issue tracker of the upstream. :-)
anyway, technically fixing this issue isn't hard (in fact, all required functionality is
there,
just remove the restriction in cmd/go). the hard part is the documentation as cross
compiling
has many caveats.
we will need a whole new document page about cross compiling with Go.

@gopherbot
Copy link
Author

Comment 7 by lexszero:

I'm working on cross-compiled Go project now (collecting some toolchain bugs :) and
really enjoying the language; so maybe I'll write a short 'go cross-compile howto"
article.
What caveats do you mean? Usually, setting some environment variables with correct paths
to toolchain, compiler/linker flags, include & lib dirs, etc is enough in case of
traditional GNU toolchain. There may be go-specific pitfalls, but fixing and/or
documenting them is just a question of time. IMHO, this discussion goes beyond the issue
tracker format.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 8:

Labels changed: added priority-later, go1.2maybe, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 9:

Status changed to Duplicate.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 10:

Merged into issue #4714.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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