sapir / gcc-rust

a (WIP) Rust frontend for gcc / a gcc backend for rustc
GNU General Public License v2.0
202 stars 5 forks source link

Frontend versus backend #19

Open Serentty opened 4 years ago

Serentty commented 4 years ago

I was talking to Centril about this project, and he suggested that it would make more sense to structure it as a codegen target for the Rust compiler instead of a GCC frontend. These were his words, specifically:

also, I think that the perspective "gcc frontend" is a mistake -- I think a "gcc backend" makes more sense in that if this project wants to be viable, it should really be a rustc_codegen_gcc crate

I'm not familiar with compiler internals and have no opinion on this myself, but given that Centril is a central figure in the development of Rust, I figured it would be a good idea to pass this on.

sapir commented 4 years ago

Thanks!

I'm not sure I understand, though. I think it's really both a frontend for gcc and a backend for rustc. But do you mean that it should use librustc_codegen_ssa?

bjorn3 commented 4 years ago

I think he means that you use can execute rustc with an extra flag instead of gcc with a rust file to use gcc-rust. This makes it easier to support cargo.

In cg_clif I use -Zcodegen-backend to load a .so as backend. That .so file just needs to provide a __rustc_codegen_backend symbol: https://github.com/bjorn3/rustc_codegen_cranelift/blob/6652f466efc93a8706c07cda0502fd487ce8219d/src/lib.rs#L286

sapir commented 4 years ago

My impression of gcc so far is that doing this without libgccjit would be difficult, and in any case it might not integrate as well with gcc.

bjorn3 commented 4 years ago

That is unfortunate.