3 ms·
Sure, based on the target CPU. But there's no fundamental reason I can't do all those optimizations for, say, x86 in a compiler that happens to be running on an
by andrewflnr 9y ago
Sure, based on the target CPU. But there's no fundamental reason I can't do all those optimizations for, say, x86 in a compiler that happens to be running on an Arm CPU. As far as the compiler is concerned it's all just data that gets stuffed in files, just like any other software.
- infogulch 9y agoThe 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
- falcolas 9y agoWell, it's not just data - it's also frequently pointers or labels to code in dynamically imported libraries; things which can't always be calculated without the exact library being used on hand.
- andrewflnr 9y agoDynamic libraries are also made of data. See also my response to coldtea here: https://news.ycombinator.com/item?id=15310255 https://news.ycombinator.com/item?id=15310255