logoalt Hacker News

Rust GCC backend: Why and how

185 pointsby ahlCVAyesterday at 1:33 PM113 commentsview on HN

Comments

mastaxyesterday at 3:11 PM

> On that note: GCC doesn't provide a nice library to give access to its internals (unlike LLVM). So we have to use libgccjit which, unlike the "jit" ("just in time", meaning compiling sub-parts of the code on the fly, only when needed for performance reasons and often used in script languages like Javascript) part in its name implies, can be used as "aot" ("ahead of time", meaning you compile everything at once, allowing you to spend more time on optimization).

Is libgccjit not “a nice library to give access to its internals?”

show 5 replies
keyleyesterday at 2:05 PM

If the author reads this...

I'd be very interested if the author could provide a post with a more in depth view of the passes, as suggested!

show 1 reply
grokxyesterday at 3:55 PM

When I studied compiler theory, a large part of the compilation involved a lexical analyser (e.g. `flex`) and a syntax analyser (e.g. `bison`), that would produce an internal representation of the input code (the AST), used to generate the compiled files.

It seems that the terminology as evolved, as we speak more broadly of frontends and backends.

So, I'm wondering if Bison and Flex (or equivalent tools) are still in use by the modern compilers? Or are they built directly in GCC, LLVM, ...?

show 9 replies
kunleytoday at 1:16 PM

A perhaps naive question: does it have a chance to be faster than LLVM backend?

MerrimanIndyesterday at 11:35 PM

Another reason to have a second compiler is for safety-critical applications. In the assessment of safety-critical tools if something like a compiler can have a second redundant version then each one of them can be certified to a lower criticality level since they'll crosscheck each other. When a tool is single-sourced the level of qualification goes up quite significantly.

show 1 reply
MangoToupeyesterday at 1:50 PM

I find it shocking that 20 years after LLVM was created, gcc still hasn't moved towards modularization of codegen.

show 3 replies
bfjjejskdjdyesterday at 2:57 PM

[flagged]

1718627440yesterday at 3:25 PM

I don't necessary like the focus on Rust, but if it happens, then we need to have support in the free compiler!

show 4 replies
notepad0x90yesterday at 9:19 PM

I would just like to encourage all Rust devs to distribute binaries. No matter what compiler you choose, or what Rust version, users shouldn't have to build from source. I mostly see this with small projects to be fair.