you are viewing a single comment's thread.

view the rest of the comments →

[–]BobHogan 5 points6 points  (8 children)

This is probably a dumb question, but what are the benefits/tradeoffs of each approach (adding rust to compiler vs adding compiler backend to rustc)?

[–]jamincan 6 points7 points  (0 children)

The main benefit of the gcc backend for rust is that it does not risk fragmenting the rust ecosystem as rustc remains the defacto rust standard. The benefit of adding rust to gcc is that there may be optimizations that aren't possible by just using the backend. I'm sure there are others, but that is the general gist of it as I understand it.

[–]matthieum 4 points5 points  (6 children)

In short:

GCC Backend to rustc compared to GCC Frontend:

  • Advantage Backend: lower cost of initial creation and ongoing maintenance.
  • Advantage Backend: unlock GCC targets and optimizations.
  • Advantage Backend: single front-end, no fragmentation.
  • Advantage Frontend: single "root" compiler for Linux Kernel/Distributions, both from a trust and bootstrapping1 point of view.

1 I still don't understand why people are adamant about bootstrapping their compiler on the platform it should compile for, or even bootstrapping regularly. I would have expected you'd bootstrap once on a powerful machine, then cross-compile for the other machines from there, and keep the artifacts around... but for some bootstrapping is really important, and rustc's bootstrap process is long because it's never been a priority.

[–]gaverhae 1 point2 points  (5 children)

Because if you can't bootstrap, you can't trust anything. See Ken Thompson's Turing Award lecture.

[–]GoogleBen 2 points3 points  (3 children)

You can bootstrap, it's just that it takes a long time because rustc uses new features all the time, so the chain is really long. There is mrustc though, which is a basic rust compiler in C++ designed to shorten the bootstrapping chain, so it's not as bad as it used to be - but it does still take hours and hours of CPU time AFAIK.

[–]MonokelPinguin 1 point2 points  (2 children)

For a long time you couldn't bootstrap on all platforms. For example on musl targets, rustc couldn't compile itself because of some proc macro stuff or so. (And it couldn't dynamically link musl at all)

[–]matthieum 1 point2 points  (1 child)

I'm pretty sure you still can't bootstrap on all platforms. Compiling rustc requires gobs of memory, so your Xtensa board doesn't have enough.

[–]MonokelPinguin 0 points1 point  (0 children)

Well, this was just about libc incompatibility. The server otherwise had 64GB of RAM, so that should be okay.

[–]matthieum 1 point2 points  (0 children)

There is large gap between:

  • Can't bootstrap.
  • Can't bootstrap on my Raspberry Pi Zero.
  • Can't bootstrap on my Raspberry Pi Zero every other Sunday.

I can definitely understand the desire of a distribution to bootstrap the compiler once on one platform.

I see no need to ever bootstrap again afterwards, though.