4 ms·
Go compiler is built in Go, big difference ( all of Go is built in Go). Cross-compiling in Go is the easiest of any languages as far as I know. Ex: GOOS=window
by Thaxll 8y ago
Go compiler is built in Go, big difference ( all of Go is built in Go). Cross-compiling in Go is the easiest of any languages as far as I know.
Ex: GOOS=windows go build .
GOOS=linux GOARCH=arm go build .
And you can run that from any os / arch, I can build a single Windows binary from my Raspberry Pi with the above example.
https://golang.org/doc/install/source#environment https://golang.org/doc/install/source#environment
- krylon 8y agoAs opposed to C/C++ compilers being built in C/C++? EDIT: Try to build NetBSD for some esoteric platform from the comfort of your desktop machine. Remember to pick up your jaw from the floow when you're done. ;-) My point is, it does not have to be hard.
- steveklabnik 8y agoIn my understanding, Go re-implements the system's interface, rather than using libc (or the equivalent), even on platforms where the syscall interface isn't considered stable. This means cross-compiling is really easy, but it can also mean breakage when the unstable interface changes. A tradeoff like anything else.
- Thaxll 8y agoRust compiler is LLVM afaik so C++, same for the JVM / C#. Having your entire runtime / tools in the same language make it easier.
- steveklabnik 8y agoThis is true for Rust, however, given that LLVM is the project doing the codegen, it's a little bit special; cross-compiling it to the platforms it supports is a bit easier than a random C++ library, since it's the one with the support in the first place. Rust projects make much more use of C libraries than Go projects do, though, so for things other than the Rust compiler, this is still a good point.
- jhawk28 8y agoGo uses a common assembly with ways to covert into the specific architecture which makes porting the toolchain to new targets somewhat trivial. (https://www.youtube.com/watch?v=KINIAgRpkDA https://www.youtube.com/watch?v=KINIAgRpkDA)