Email or username:

Password:

Forgot your password?
33 comments
Daniel Paoliello :rust:

@notgull "Which is fine for us users, since we can just download rustc from the internet and use it."

Yeah, some of us don't have the luxury of downloading and running arbitrary unsigned binaries from the internet. Makes the security folks nervous for some reason...

Glad to see that this is coming along! I'm excited for another way to bootstrap Rust.

Lord

@notgull Is there really a point in bootstrapping now ? Isn't it useful only when a new CPU architecture arrive and you want to have all those languages on there ?

yosh

@notgull tbh I was pretty confused when I first saw you posting about this, but it makes a lot of sense now. This is really cool! Thank you for sharing!

William D. Jones

@notgull If one of your goals is to compile Rust itself, which is the main point of mrustc, how is Rust's LLVM dep being handled?

Don't get me wrong, I would love to get rid of it, just based on the fact it's 10 million lines of C++, arguably the only language more complex to write a compiler for than Rust. But we don't have that luxury :/.

notgull

@cr1901 My plan is to replace it with the Cranelift backend. It's written entirely in Rust, so it should be usable if we have a Rust compiler.

If that doesn't work, my plan is to write a QBE backend for rustc and use that instead.

William D. Jones

@notgull Does Cranelift do optimizations? I've heard conflicting info about this ("it doesn't optimize", "it does optimize, but debug-friendly opts only, no further opts planned", "release opts are planned/in progress").

notgull

@cr1901 I don't know, as far as I know there are some optimization passes but it's nowhere near LLVM's caliber.

William D. Jones

@notgull Actual no-optimization builds of rustc are so slow that config.toml itself says they're unsupported. Hopefully getting an acceptable speed compiler doesn't require LLVM-like levels of effort (i.e. 80% of the speed for 20% of the work).

Anyways, if you succeed in this project, I will have to find something else to bit- err, nothing left to bitch about- wrt rustc's bootstrap situation, so I do hope its feasible, and that e.g. upstream (if QBE is required) and Cranelift are supportive :D.

William D. Jones

@notgull This is OT, but while its on my mind...

Is GH Discussions a reasonable place to ask questions about design decisions about smol? (Specifically, I have a lifetime question, and can't figure it out for the life of me)

bjorn3

@notgull @cr1901 There are indeed a couple of optimizations, but not much. A cg_llvm compiled cg_clif builds the standard library in 19s. A cg_clif compiled rustc/cg_clif builds the standard library in 4m 42s, or in other words about a 14x slowdown. github.com/rust-lang/rustc_cod To shrink the gap, implementing clif ir level inlining (which should be more effective than mir inlining) as well as better optimizations of loads and stores should help a fair bit.

@notgull @cr1901 There are indeed a couple of optimizations, but not much. A cg_llvm compiled cg_clif builds the standard library in 19s. A cg_clif compiled rustc/cg_clif builds the standard library in 4m 42s, or in other words about a 14x slowdown. github.com/rust-lang/rustc_cod To shrink the gap, implementing clif ir level inlining (which should be more effective than mir inlining) as well as better optimizations of loads and stores...

William D. Jones

@bjorn3 @notgull Idk about 14x, but I think even a 3x slowdown would be acceptable to me personally :P.

Josh Triplett
If this is designed primarily for bootstrapping purposes, are you planning to pick a particular version of Rust that'll let you compile some early self-hosting Rust compiler to shorten the bootstrap chain and stop there, so that you don't have a moving target?
Rhialto

@notgull This sounds potentially very useful for systems like #NetBSD. NetBSD runs on lots of platforms that are badly supported by upstream Rust and that is very frustrating. It breaks everything that depends on having a Rust compiler, such as librsvg and Python cryptography...

Tommy Thorn

@notgull I like it. I really want the moral equivalent of TinyCC but for [a subset of] Rust, but having a "TinyRust" written in C is also great.

calvin, ","

@notgull i don't think using bison/yacc or C++ is a sin for bootstrapping, IMHO, so it can be a lot easier on yourself. the bootstrapping use cases I'd care about are "i have a unix environment with gcc and full dev environment, just without rutstc" (i..e a distro or a port of rust to like, aix) more than "i am keying linux in from switches"

FSMaxB

@notgull Have you considered having Dozer compile an intermediate language that is similar to rust but not full rust and then implement the actual rust compiler in that intermediate language? That would follow the "Descent Principle" you describe in your blog post and probably be easier than doing the entire compiler in C.

oli

@notgull maximally dumb idea: could we write a cranelift backend that produces C code instead of machine code, and then compile that on the target machine?

FSMaxB

@oli @notgull From a bootstrapping perspective, how is that different from just cross compiling though?

Esteban K�ber :rust:

@FSMaxB @oli @notgull the only difference would be (depending on what C version is targeted) that you would have a single backend for any platform that has a C compiler, instead of needing one backend per platform.

Esteban K�ber :rust:

@oli @notgull it's not the main goal of the project, but github.com/FractalFir/rustc_co has some support for C codegen. It's where I'd start if we wanted to put some extra effort on this.

Kyle Strand

@notgull One thing the post doesn't really explain is why it matters how "late in the process" Rust shows up.

> So if you wanted to use Rust at any point before C++ is introduced, you’re out of luck.
>
> So, for me, it would be really nice if there was a Rust compiler that could be bootstrapped from C.

Are you working on something else that requires Rust, which you'd like to have available earlier in bootstrapping? Do you just want to be able to "cut off" bootstrapping entirely before C++?

@notgull One thing the post doesn't really explain is why it matters how "late in the process" Rust shows up.

> So if you wanted to use Rust at any point before C++ is introduced, you’re out of luck.
>
> So, for me, it would be really nice if there was a Rust compiler that could be bootstrapped from C.

notgull

@BatmanAoD Yeah, I have plans which require Rust to be available early on in the process.

notgull

@BatmanAoD Not really. Mostly I want to replace the Perl bootstrap that happens in the process

Kyle Strand

@notgull Replacing Perl with Rust certainly worthwhile!

Andrius Štikonas

@notgull @BatmanAoD In saw another attempt to replace perl but without rust. Somebody is trying to write autotools in C.

Andrius Štikonas

@BatmanAoD @notgull Well, one simple example might be using uutils instead of coreutils. Or findutils in rust...

Joshua Barretto

@notgull Good luck! How much have you looked into the implementation of a trait solver, out of interest? I'll bet that's likely going to be the most complex element of the project.

Go Up