Dimitri John Ledkov: cross-compile go code, including cgo
By all means cross-compiling a new language/stack is not going to be pretty, but it didn't turn out that bad.
A few weeks back, I was told that go code which uses cgo (that is utilising C api calls to shared libraries exporting C interface) cannot be cross-compiled. Well, if it's just calling out a C compiler it should totally be easy to cross compile, since so much of our platform is.
So there we go, first I've picked a moderately small project which only does a couple cgo calls, and check that it compiles correctly:
I didn't want to polute my system, so I quickly created a chroot with go, build-dependencies in armhf architectures and cross-compiler:
A few weeks back, I was told that go code which uses cgo (that is utilising C api calls to shared libraries exporting C interface) cannot be cross-compiled. Well, if it's just calling out a C compiler it should totally be easy to cross compile, since so much of our platform is.
So there we go, first I've picked a moderately small project which only does a couple cgo calls, and check that it compiles correctly:
$ sudo apt-get build-dep ubuntu-push-clientWell, when your gcc is all is easy.
$ go get launchpad.net/ubuntu-push/...
$ cd $GOPATH/src/launchpad.net/ubuntu-push/
$ go build ubuntu-push-client.go
I didn't want to polute my system, so I quickly created a chroot with go, build-dependencies in armhf architectures and cross-compiler:
# Get a chroot with build-dependencies installed, I am basing on top of a click-chrootAfter that the tricky bit was advising go to cross-compile:
# one should be able to use any chroot which is armhf multiarch enabled.
$ sudo click chroot -aarmhf -fubuntu-sdk-14.04 -s utopic create
$ sudo click chroot -aarmhf -fubuntu-sdk-14.04 -s utopic maint apt-get install golang-go golang-go-linux-arm golang-go-dbus-dev golang-go-xdg-dev golang-gocheck-dev golang-gosqlite-dev golang-uuid-dev libgcrypt11-dev:armhf libglib2.0-dev:armhf libwhoopsie-dev:armhf libubuntuoneauth-2.0-dev:armhf libdbus-1-dev:armhf libnih-dbus-dev:armhf libsqlite3-dev:armhf crossbuild-essential-armhf
$ click chroot -aarmhf -fubuntu-sdk-14.04 -s utopic run CGO_ENABLED=1 GOARCH=arm GOARM=7 PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig GOPATH=/usr/share/gocode/:~/go CC=arm-linux-gnueabihf-gcc go build -ldflags '-extld=arm-linux-gnueabihf-gcc' ubuntu-push-client.go
Ignoring the click chroot wrapper:
- CGO_ENABLED=1 - by default cgo is disabled when cross-compiling, but really shouldn't be as compiler names are standard $(GNU_TRIPPLET) prefixed tools
- GOARCH=arm - set the target arch
- GOARM=7 - set ABI level
- PKG_CONFIG_LIBDIR - the ugly beast to pass where pkg-config should search for .pc files. With autoconf one simply sets PKG_CONFIG environment variable pointing at a cross-pkg-config, $(GNU_TRIPPLET)-pkg-config but go tool doesn't support it. I've raised merge proposal to get that added https://codereview.appspot.com/104960043/
- Next I just set GOPATH to where my packages are and CC as to which compiler to use
- The last portion to the puzzle was to pash "-ldflags '-extld=$CC'" because the linker tool (5l) didn't use environmental variable CC and simply defaults to gcc. I'll raise a merge proposal for this.
Overall that's it. Given that all of above can be re-factored into standard variables (e.g. use $GNU_TRIPPLET prefix, and offer to override it), I see no reason why cross-compilation in go with cgo cannot eventually become a simple
GOARCH=arm go build
Some days ago, I bit the bullet and accepted the 
[update] I will do another blog post. Good news: My Tor node is alive again! Just no longer as an exit relay, as properly pointed out by many, but as a

I m writing this on the train back from the
I ve been learning about android development over the last few weeks, and I think I m slowly getting the hang of best practices.
It s a bit tough, there s a lot of stuff that s not super Java-idomatic that s become Android-idiomatic, so getting over that stuff has been interesting.
I ve been finding that Android tends to re-implement most things in a similar enough way, but always with some small tweak that feels kinda funny.
It s working well enough, and I m hoping that I can clean up a few android libraries to deal with some of the OpenGov datasets I m interested in.
If anyone has any tips on proper handling of what to make a fragment, and what activities should look like, I d really love posts about that.
It seems like sometimes I have a 1-to-1 mapping of Fragments to Activity, but I want to keep it a fragment for large devices.
Anyway, best practices welcome.
According to the
The heading might be ambiguous, but I couldn't figure out better
heading so let me start by explaining what I'm trying to solve here.
If anybody has access to a complete mirror of the Debian Wheezy release, and was willing to share a list of all setuid/setgid binaries that would be greatly appreciated.
It doesn't seem to be something you can find online, so you need to manually unpack each .deb file and look at the permissions.
I don't have access to a (complete) local mirror, and so I cannot easily build such a thing, unless I go to ebay and buy a random DVD-archive.
This list would be useful for folk wanting to direct their audits ..
I just got my tickets to Portland, to assist to one of my favorite events:
See you there and let s