by tptacek · 3y ago · 0 comments
https://words.filippo.io/easy-windows-and-linux-cross-compil...
I debated doing the pure-Go SQLite thing, but musl-cross worked just fine for me, and kept things simpler.
export GOARCH=arm64
export CC=zig cc -target aarch64-linux-musl
export CXX=zig cc -target aarch64-linux-musl CC="/path/to/cross/compiler" CGO_CFLAGS=—I/path/to/sdk/header/files/include" CGO_LDFLAGS="-L/path/to/sdk/obj/files/lib”
I suppose with .so files, you might have to specify "-Wl,-rpath" if the SDK libraries don’t reside under /usr/lib or /usr/local/lib on the target system. But I haven’t actually tried any of this yet, so I could be wrong. Are there any gotchas that I’m missing?You're missing all the tooling and OS specific steps required to produce a proper package.
GOOS= GOARCH= CGO_ENABLED=1 go build \
-tags osusergo,netgo,sqlite_omit_load_extension \
-ldflags="-extldflags=-static"
[0]: https://www.arp242.net/static-go.html1. https://github.com/ClickHouse/sysroot/
2. https://github.com/ClickHouse/ClickHouse/blob/master/cmake/f... and the `CMAKE_TOOLCHAIN_FILE` variable.
No one should touch servers directly, unless for down tracking stuff or remote development, in which case, they also don't need to cross compile.
No devs on production servers unless for tracking down issues, or servers configured for remote development.
Which in both cases, don't require cross compilation to start with.
The downside is that people (especially the ones who are just joining the workforce) are less efficient with the command line and more dependant on GUI. For example some of the junior devs do not know git cli anymore and rely on the VSCode plugin to interact with git. This becomes an issue when there is a bug in the plugin and you should use the CLI.
The developer should alao maintain their software and deploy it. Has IMHO a lot of advantages
Linux OEM vendors will appreciate it.