Community Packages

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#30287 - [go] include support for crosscompiling

Attached to Project: Community Packages
Opened by Kev (Kev) - Thursday, 14 June 2012, 09:54 GMT
Last edited by Alexander F. Rødseth (xyproto) - Thursday, 02 May 2013, 13:53 GMT
Task Type Feature Request
Category Packages
Status Closed
Assigned To Alexander F. Rødseth (xyproto)
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 4
Private No


go has great support for crosscompiling builtin but the archlinux package does not include the necessary tools for it.

These are:

* 5g
* 5l
* 5c
* 5a
(for ARM)

* 8g
* 8l
* 8c
* 8a
(for 32 Bit)

See [1] for reference.
So please modify the PKGBUILD so that these tools are included in the package.

Additional info:
* package version(s):
community/go 2:1.0.1-6

Steps to reproduce:
1. install go.
2. Create a helloworld.go example (from [2])
3. Try to compile for ARMv5:
export GOARCH=arm
export GOARM=5
go build helloworld.go
go build runtime: exec: "/usr/lib/go/pkg/tool/linux_amd64/5g": stat /usr/lib/go/pkg/tool/linux_amd64/5g: no such file or directory

This task depends upon

Closed by  Alexander F. Rødseth (xyproto)
Thursday, 02 May 2013, 13:53 GMT
Reason for closing:  Fixed
Additional comments about closing:  552MB is a bit too much for adding cross compilation for all platforms. Might split this package in the future. Uploading an alternative package to AUR for now.
Comment by Alexander F. Rødseth (xyproto) - Saturday, 16 June 2012, 15:34 GMT
Thanks for reporting, I will look at this.
Comment by Kev (Kev) - Sunday, 17 June 2012, 09:04 GMT
Thanks for working on this issue.

You may want to have a look at my tweaked PKGBUILD:

It produces the compiler for 6G (AMD64) and 5G (ARM) or 8G (x86) and 5G (ARM).

There are some failed tests during the build sometimes(!) but the produced binaries are fine so far.

Maybe you need to compile the toolchain twice to get all three architectures and then merge them together during the package process. But maybe there is a better way.
Comment by Tom Wambold (tom5760) - Wednesday, 14 November 2012, 23:55 GMT
  • Field changed: Percent Complete (100% → 0%)
It appears this was removed in commit 42fad187fe31b754d37e709e26d3da18b57a534f. I just tried this with the current PKGBUILD by adding:

export GOARCH=arm
bash make.bash

at the end of the build function, and it appears to work. I was able to successfully compile a Go program for ARM too.

Could this be re-enabled?
Comment by Alexander F. Rødseth (xyproto) - Thursday, 15 November 2012, 00:48 GMT
Hi, when adding export GOARCH=arm and bash make.bash to the end of the build() function I get a lot of error messages that look like this:

fork/exec /tmp/go-build457724733/unicode/utf16/_test/utf16.test: exec format error
FAIL unicode/utf16 0.002s

That is the background for the removal, since this happened after one of the later Go releases.

Do you get different output?

Any ideas or solutions are welcome, as I too want to include support for crosscompiling for ARM.
Comment by Tom Wambold (tom5760) - Thursday, 15 November 2012, 01:33 GMT
I get the same output. This happens when running the tests in the "check" function. This seems to be because its compiling the test binaries for ARM and then trying to run them (and failing, as we are not running Arch on ARM processors).

I just tried copying the "export GOARCH" test at the top of the build function into the check function, which seems to fix the issue.

Either way, even if the check function fails (because of the ARM binaries), the compilers for both x64 and arm seem to work well.
Comment by Alexander F. Rødseth (xyproto) - Thursday, 15 November 2012, 01:39 GMT
Okay, thanks for investigating. I'll re-enable arm support, then.
Comment by Alexander F. Rødseth (xyproto) - Thursday, 15 November 2012, 01:54 GMT
Compiling and checking worked as you described. The updated package will appear in [community] shortly.
Comment by Tom Wambold (tom5760) - Thursday, 15 November 2012, 01:59 GMT
Comment by sorcix (sorcix) - Monday, 29 April 2013, 15:05 GMT
  • Field changed: Percent Complete (100% → 0%)
Golang supports cross compilation to windows/freebsd/darwin too. Would it be possible to include support for those in this package as well?
Comment by Alexander F. Rødseth (xyproto) - Thursday, 02 May 2013, 12:05 GMT
Will look at it.
Comment by Alexander F. Rødseth (xyproto) - Thursday, 02 May 2013, 12:21 GMT
Enabling crosscompilation for the other platforms as well. Will also upgrade to 1.1rc1 while I'm at it. The package is currently building and if everything looks fine and passes the test cases I have, I'll move it to [community] today.
Comment by Alexander F. Rødseth (xyproto) - Thursday, 02 May 2013, 13:52 GMT
Enabling all the cross compilation targets increases the package size with 552MB. This is a bit too much. I'll close this bug report, upgrade the package to 1.1rc1 and just maybe add split-package support for cross compiling for freebsd/darwin/windows in the future.

In the mean time, there is "go-full" on AUR, that I just uploaded: