News for hackers. Stuff that matters.
Re:Mrustc: a Rust compiler written in C++ by andrewflnr on Thursday September 21, 2017 @10:27PM (#15308997)
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.
Re:Mrustc: a Rust compiler written in C++ by infogulch on Thursday September 21, 2017 @11:26PM (#15309205)
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.

Re:Mrustc: a Rust compiler written in C++ by kibwen on Friday September 22, 2017 @12:28AM (#15309391)
> 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 ). 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 .

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

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

Re:Mrustc: a Rust compiler written in C++ by falcolas on Friday September 22, 2017 @12:29PM (#15313585)
Well, 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.
Re:Mrustc: a Rust compiler written in C++ by andrewflnr on Friday September 22, 2017 @09:03PM (#15317385)
Dynamic libraries are also made of data. See also my response to coldtea here: https://news.ycombinator.com/item?id=15310255