Compiling GO for Synology NAS

I have a go app that runs via scheduled task on my Synology NAS DS218+. Compiling GO binaries for major platforms is fairly straight forward. Compiling GO binaries for Synology is a bit more involved. The following is what I’ve found to work.

First, install musl-cross.

$ brew install FiloSottile/musl-cross/musl-cross

Then run the following go build command.

$ CC=x86_64-linux-musl-gcc \
  CXX=x86_64-linux-musl-g++ \
  GOARCH=amd64 \
  GOOS=linux \
  go build -ldflags "-linkmode external -extldflags -static"

Published on April 22, 2020