3 ms·
> Compiled ones need more effort I think Go needs a flag specified at compile time to work on ARM. Instead of `go build`, run `env GOOS=linux GOARCH=arm64 go b
by nindalf 5y ago
> Compiled ones need more effort
I think Go needs a flag specified at compile time to work on ARM. Instead of `go build`, run `env GOOS=linux GOARCH=arm64 go build`.
Rust is similar, except it requires the appropriate toolchain to be installed first (1-liner).
It’s probably less effort what I’ve described because there are GitHub Actions that will generate appropriate binaries out of the box.
- liftm 5y agoIt remains that easy until your Go/Rust project relies on libraries written in other languages, say C. (This holds true for JS/python/… too.)
- cure 5y agoRight. But even then it does not become that much worse. Just tell Go to use the appropriate cross compilation chain for the C bits, e.g. `apt install gcc-aarch64-linux-gnu` and set the `CC=aarch64-linux-gnu-gcc` environment variable to compile for arm64. Compilation becomes a bit slower, but it's still manageable. It's that easy thanks to the foundations laid by the distribution that ships a solid cross-compiler setup (in this example, thank you Debian!) and of course the brilliance of the Go design and toolchain.
- creamytaco 5y agoRelying on libraries written in C is not an issue if the library doesn't make assumptions about / isn't tied to, a particular architecture. Some do but most (especially newer codebases written to C11 and beyond) don't.
- ajdlinux 5y agoThere's also the issue of performance-optimised assembly routines, which impacts many native libraries doing things such as crypto, image processing, etc.
- blihp 5y agoThe issue is that someone has to initially write the code to emit the native assembly/machine code for each architecture that a given compiler supports. (i.e. assuming it actually emits native code and not code for another compiled language like C/C++) The flag simply means that someone has already done that work for a particular language on a particular architecture.
- nindalf 5y agoAbsolutely, it’s a lot of work. Just saying the work had already been done for Go and Rust even before M1 made it mainstream.