Email or username:

Password:

Forgot your password?
8 posts total
notgull

⚠️ BIG DOZER NEWS ⚠️

Dozer, my Rust compiler written in C, just compiled its first "hello world" application! Thanks to the power of "linking to libc" we can now print "hello world" to the console!

This is a start. Next I want to get traits and generics working.

#rust #rustlang

notgull

Sorry for the lack of updates for the past few weeks. It's been a little weird for me.

Anyways, function calls now work in dozer.

notgull

Some weirdness with this: the way I do expressions is that every expression gets a variable slot. So I first encounter the function pointer (add_two_numbers), put that into a QBE temporary, then call it with the later arguments.

I was worried that this would cause issues, but it looks like QBE is able to optimize it down to just calling the global. Which is nice!

Show previous comments
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?

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.

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.

notgull

🚨 BIG NEWS 🚨

Dozer has now compiled its first Rust program!

Granted, all it does is tokenize it, do some basic parsing, and the emission code only handles integer literals and doesn't handle signatures that aren't "() -> i32". But what is just compiled is basically valid Rust.

Only one way to go from here! rustc, here I come!

Zeeshan Ali Khan :rust: 🇺🇦

@notgull for C, I'd recommend using meson as your build system. It's super ergonomic, has a lot of useful features and can be really fast OOTB

notgull

Check it out! My Rust compiler written in C (now called "dozer") just parsed its first function!

notgull

I’m trying to think ahead as to how I want to do the expansion phase (e.g. macros, cfg directives, external modules). I’m thinking that it should be reasonable to do it at the same time I’m doing parsing, right? Since it’s just yielding tokens from other files/directives.

notgull

Haters in shambles! My Rust compiler (written in 100% C with no extensions) can now parse basic expressions.

pinkforest(she/her) 🦀

@notgull I've been thinking cutting the chains off to LLVM and hook the AST business to binaryen for specialist wasm use-case - involving multi-memories - How difficult .. or enjoyable lol ^o^ .. did you find doing the AST bit in C without hooking to the comp internal crate that does the AST via FFI ?

notgull

A while back I said it would be really nice for bootstrapping if there was a Rust compiler or interpreter written in C. Of course, that would be ridiculous.

But it’s worth trying.

I’ve written a tokenizer for Rust in pure C. I’ve tested it on a few Rust crates and it seems to work. Now moving on to the syntax tree parser.

Effectively rewriting the syn crate in C, with no real tools (no yacc!). I’ll probably give up on this eventually, but let’s see how far I can push it.

aismallard

@notgull Doesn’t Rust have its own bootstrapping compiler, which uses a non-safety checked subset of Rust or something like that? You could target that in portable C and then have that as your C bootstrapper compiler perhaps

notgull

My goal is that it should be possible to bootstrap a working copy of rustc using nothing but a basic C compiler (I'm targeting cproc and tinycc) as well as a basic shell interpreter (Kaem). This would mean Rust can be introduced at a very early point in the Live Bootstrap process.

Go Up