How to build syncthing for m1 platform on other os or arch?

We want to build syncthing for m1 on github action, but m1 machine is not provied, Help!

You’d build it the same way like you build any other go application.

More or less. go run build.go -goos darwin -goarch arm64 build syncthing will give you a Syncthing for macOS-arm64 that works, without filesystem notifications.

To enable fs notifications you need CGO_ENABLED and linking to the appropriate system libraries. That happens automatically if you build on arm64, otherwise I do this on the build server (which is macOS-Intel):

cat <<EOT > xgo.sh
#!/bin/bash
CGO_ENABLED=1 \
	CGO_CFLAGS="-target arm64-apple-macos10.15" \
    CGO_LDFLAGS="-target arm64-apple-macos10.15" \
    go "\$@"
EOT
chmod 755 xgo.sh
go run build.go -gocmd ./xgo.sh -goarch arm64 zip

If you intend to run it on a machine other than your own you probably need to look into proper signing and notarization as well. That works the same as any other macOS program.

1 Like

Thanks, it works!!!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.