Crosscompiling go with C library on powerpc64

Recently, we wanted to use go language to write an application for our powerpc64 board. This is not an issue, since go supports crosscompiling out of the box. But to increase performance, we decided to use C sqlite3 bindings with go-sqlite3. Unfortunately, when crosscompiling, we ran into error:

This is most likely because it tries to link ppc64 object with amd64 libraries. We are not alone. After couple of hours of digging the web, and stracing the go compiler, I managed to crosscompile the whole thing. Below you have ready-to-use solution. It is quite dirty but it works. Tested with go versions devel +387d5b8 linux/amd641.5.3 linux/amd64 and gccgo (crosstool-NG crosstool-ng-1.22.0) 5.2.0.

Using go-sqlite3, we can crosscompile example modules:

Check the binary:

And run it on the machine:



Leave a Reply

Your email address will not be published. Required fields are marked *