Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis

cellularmitosis/README.md

Last active Jan 29, 2020
Embed
What would you like to do?
Cross-compiling golang for an AMD Geode

Blog 2019/4/30

<- previous | index | next ->

Cross-compiling golang for an AMD Geode

Here's the script I used to cross-compile go for an old, slow i586 box (an AMD Personal Internet Communicator, 366MHz, 128MB RAM).

The resulting tarball will be named go-1.12.4-linux-386-387.tar.gz.

To install it on the target machine:

cd /opt
cat go-1.12.4-linux-386-387.tar.gz | gunzip | tar x
ln -sf /opt/go-1.12.4/bin/linux_386/go /usr/local/bin/go
ln -sf /opt/go-1.12.4/bin/linux_386/gofmt /usr/local/bin/gofmt

There's probably a more "official" way to do this. But for now, this hack seems to work.

See also Installing Linux on the AMD Personal Internet Communicator .

EDIT: I also built an ARMv5 tarball which I'll use on an old NSLU2 (266MHz, 32MB RAM) and a few Pogoplugs.

EDIT2: I also added a mipsle build script.

Why?

Because the stock 386 go binary distribution requires SSE support. See https://github.com/golang/go/issues/35789

#!/bin/bash
# cross-compile and package up golang for a non-SSE i386 box.
set -e -o pipefail
set -x
version=1.13.7
export GOOS=linux
export GOARCH=386
export GO386=387
os_arch=linux_386
dist_tarball=go-${version}-linux-386-387.tar.gz
src_tarball=go${version}.src.tar.gz
mkdir -p ~/Downloads/dist
cd ~/Downloads/dist
if [ ! -e $src_tarball ]
then
url=https://dl.google.com/go/$src_tarball
wget $url
fi
mkdir -p ~/tmp
cd ~/tmp
rm -rf go
cat ~/Downloads/dist/$src_tarball | gunzip | tar x
cd ~/tmp/go/src
GOROOT_FINAL=/opt/go-$version ./make.bash -v
dest=~/tmp/go-${version}
rm -rf $dest
mkdir $dest
cd ~/tmp/go
cp -a api doc lib misc src test $dest
mkdir $dest/pkg
cp -a pkg/include pkg/$os_arch $dest/pkg/
mkdir $dest/pkg/tool
cp -a pkg/tool/$os_arch $dest/pkg/tool/
mkdir $dest/bin
cp -a bin/$os_arch $dest/bin/
cd $dest
cd ..
tar c go-${version} | gzip > $dist_tarball
echo "see ~/tmp/$dist_tarball"
#!/bin/bash
# cross-compile and package up golang for an ARMv5 box.
set -e -o pipefail
set -x
version=1.13.7
export GOOS=linux
export GOARCH=arm
export GOARM=5
os_arch=linux_arm
dist_tarball=go-${version}-linux-arm-5.tar.gz
src_tarball=go${version}.src.tar.gz
mkdir -p ~/Downloads/dist
cd ~/Downloads/dist
if [ ! -e $src_tarball ]
then
url=https://dl.google.com/go/$src_tarball
wget $url
fi
mkdir -p ~/tmp
cd ~/tmp
rm -rf go
cat ~/Downloads/dist/$src_tarball | gunzip | tar x
cd ~/tmp/go/src
GOROOT_FINAL=/opt/go-$version ./make.bash -v
dest=~/tmp/go-${version}
rm -rf $dest
mkdir $dest
cd ~/tmp/go
cp -a api doc lib misc src test $dest
mkdir $dest/pkg
cp -a pkg/include pkg/$os_arch $dest/pkg/
mkdir $dest/pkg/tool
cp -a pkg/tool/$os_arch $dest/pkg/tool/
mkdir $dest/bin
cp -a bin/$os_arch $dest/bin/
cd $dest
cd ..
tar c go-${version} | gzip > $dist_tarball
echo "see ~/tmp/$dist_tarball"
#!/bin/bash
# cross-compile and package up golang for a MIPS (little endian) box.
set -e -o pipefail
set -x
version=1.13.7
export GOOS=linux
export GOARCH=mipsle
export GOMIPS=hardfloat
os_arch=linux_mipsle
dist_tarball=go-${version}-linux-mipsle.tar.gz
src_tarball=go${version}.src.tar.gz
mkdir -p ~/Downloads/dist
cd ~/Downloads/dist
if [ ! -e $src_tarball ]
then
url=https://dl.google.com/go/$src_tarball
wget $url
fi
mkdir -p ~/tmp
cd ~/tmp
rm -rf go
cat ~/Downloads/dist/$src_tarball | gunzip | tar x
cd ~/tmp/go/src
GOROOT_FINAL=/opt/go-$version ./make.bash -v
dest=~/tmp/go-${version}
rm -rf $dest
mkdir $dest
cd ~/tmp/go
cp -a api doc lib misc src test $dest
mkdir $dest/pkg
cp -a pkg/include pkg/$os_arch $dest/pkg/
mkdir $dest/pkg/tool
cp -a pkg/tool/$os_arch $dest/pkg/tool/
mkdir $dest/bin
cp -a bin/$os_arch $dest/bin/
cd $dest
cd ..
tar c go-${version} | gzip > $dist_tarball
echo "see ~/tmp/$dist_tarball"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.