3 ms·
The super-easy cross compilation in go is one of the best parts. Every install comes with the capacity to compile to every go target with no differences in inpu
by infogulch 9y ago
The super-easy cross compilation in go is one of the best parts. Every install comes with the capacity to compile to every go target with no differences in input except setting it by name.
This is really something more languages should strive for.
- kibwen 9y ago> This is really something more languages should strive for. Most languages these days obviate cross-compilation in the first place by being interpreted. Of the languages that remain, the natively-compiled ones, most haven't gone to Go's lengths of writing a custom libc, which is emphatically not recommended for both Windows and Mac (the syscall interfaces aren't stable, and this has broken Go code in the past: https://github.com/golang/go/issues/16272 https://github.com/golang/go/issues/16272 ). And gc, the primary Go compiler and the one with out-of-the-box cross-compilation, supports relatively few platforms (I count 11, whereas rustc looks like it supports 50-70 platforms). You can use gccgo to get more platforms, but AFAICT gccgo's cross-compilation story isn't nearly as nice: https://github.com/golang/go/wiki/GccgoCrossCompilation https://github.com/golang/go/wiki/GccgoCrossCompilation . For Rust, cross-compilation looks like this: 1. Install the libc for the target system, and, if necessary, a compatible linker. 2. Run `rustup target add foo` where "foo" is one of the target triples on https://forge.rust-lang.org/platform-support.html https://forge.rust-lang.org/platform-support.html 3. Add the target triple to your Cargo.toml. Which isn't too shabby. You can read more about it here: https://github.com/japaric/rust-cross https://github.com/japaric/rust-cross