<p>LLVM and GCC are two popular choices for back-ends. They both have good compilation frameworks. What are the advantages and disadvantages of each?</p>
<p>Credit to Mousetail for <a href="https://area51.stackexchange.com/proposals/127456/programming-language-design-and-implementation/127482#127482">the idea</a> on Area 51</p>

<compilers><backend>
Why would you choose a LLVM over a GCC back-end or vice versa for a compiled language?
CC BY-SA 4.0
2023-05-22T22:08:35.653Z
Is it even possible to use a GCC backend? It was my impression that they don't provide an API like LLVM's.
Bbrk24
CC BY-SA 4.0
2023-05-22T22:09:59.147Z
I think it is but I could be wrong @Bbrk24
Starship
CC BY-SA 4.0
2023-05-22T23:30:29.840Z
What do you mean by GCC back-end? GCC is a set of compilers.
Nike Dattani
CC BY-SA 4.0
2023-05-22T23:44:14.490Z
@NikeDattani I have assumed that they are talking about libgccjit, GCC's solution for non-gcc compilers to use the GCC backend framework.
blueberry
CC BY-SA 4.0
2023-05-23T00:06:02.147Z
@Bbrk24 GCC exposes multiple APIs: GENERIC, libgccjit, and also has a front-end for the GIMPLE IR.
Longinus
CC BY-SA 4.0
2023-05-23T00:59:32.990Z
Have you asked Mousetail for permission? I think you should let the original posters of the example questions post them on the live site.
justANewbie
CC BY-SA 4.0
2023-05-23T01:04:29.920Z
Since when do you need permission? @justANewbie its been 6 days if mousetail wanted to ask it they could have
Starship
CC BY-SA 4.0
2023-05-23T01:10:57.690Z
@Starshipisgoforlaunch maybe he's saving the question for the public beta, where questions are qualified for HNQ. maybe he wanted to polish it before posting it. Or maybe he just doesn't want to post it yet. In any case, you should ask for permission first.
justANewbie
CC BY-SA 4.0
2023-05-23T09:38:44.397Z
This has been done alll over the site, if mousetail has any objection they may say it here
Starship
CC BY-SA 4.0
2023-05-23T10:48:49.113Z
I don't have a problem with re-using the basic premise of my examples as the basis for a more complex, fully fleshed out, high quality question but please refrain from just copying the title and and adding only very minimal context that clearly shows you know nothing about the subject
mousetail 'he-him'
CC BY-SA 4.0
2023-05-23T20:55:31.443Z
Why would I ask a question if I already knew a ton about it/the answer as a rule? @mousetail
Starship
CC BY-SA 4.0
2023-05-23T20:57:44.680Z
You don't need to know the answer but you at least need to be able to intelligently describe the question
mousetail 'he-him'
<h1>LLVM</h1>
<h2>Pros</h2>
<ul>
<li>Better well known, leading to:</li>
<li>More documentation and examples</li>
<li>If it's your thing, more recognisability</li>
<li>More bindings for various languages</li>
<li>Text based format, if you don't have/want to use bindings</li>
</ul>
<h2>Cons</h2>
<ul>
<li>Large, and slow, both to compile and to run</li>
<li>Not present on as many (linux) systems by default</li>
<li>Slightly more complex interface (in my opinion)</li>
</ul>
<h1>libgccjit</h1>
<h2>Pros</h2>
<ul>
<li>Simpler interface (in my opinion)</li>
<li>Very slightly better optimisation engine in some cases</li>
<li>Supports more assembly languages, and has been ported to more systems</li>
<li>More likely to be present on a given (linux) system</li>
</ul>
<h2>Cons</h2>
<ul>
<li>No text based format, and only bindings for C/C++</li>
<li>Not as battle-tested, for lack of a better term</li>
<li>Can't really be used as a performant JIT compiler, despite the name</li>
</ul>
<h1>Similar</h1>
<p>Both have similarly powerful optimisation engines, so if you use them well, they'll both generate good code.</p>

CC BY-SA 4.0
2023-05-22T23:43:20.857Z
2023-05-22T23:43:20.857Z
blueberry
CC BY-SA 4.0
2023-05-22T23:53:05.460Z
"No text based format." GIMPLE is a textual IR that GCC accepts as input with GIMPLE FE.
Longinus
CC BY-SA 4.0
2023-05-22T23:56:57.087Z
@Longinus I am aware - I was talking about libgccjit, which does not have a text based format. As far as I know, libgccjit is intended as the "proper" way for outside programs to interface with GCC, so I did not mention GIMPLE.
blueberry
# Why would you choose a LLVM over a GCC back-end or vice versa for a compiled language?
Posted by: username_0 on 2023-05-22
LLVM and GCC are two popular choices for back-ends. They both have good compilation frameworks. What are the advantages and disadvantages of each?

Credit to Mousetail for [the idea](https://area51.stackexchange.com/proposals/127456/programming-language-design-and-implementation/127482#127482) on Area 51
**Tags:** compilers backend
> **Comments:**
> **username_1**: Is it even possible to use a GCC backend? It was my impression that they don't provide an API like LLVM's.  
> **username_0**: I think it is but I could be wrong @Bbrk24  
> **username_2**: What do you mean by GCC back-end? GCC is a set of compilers.  
> **username_3**: @NikeDattani I have assumed that they are talking about libgccjit, GCC's solution for non-gcc compilers to use the GCC backend framework.  
> **username_4**: @Bbrk24 GCC exposes multiple APIs: GENERIC, libgccjit, and also has a front-end for the GIMPLE IR.  
> **username_5**: Have you asked Mousetail for permission? I think you should let the original posters of the example questions post them on the live site.  
> **username_0**: Since when do you need permission? @justANewbie its been 6 days if mousetail wanted to ask it they could have  
> **username_5**: @Starshipisgoforlaunch maybe he's saving the question for the public beta, where questions are qualified for HNQ. maybe he wanted to polish it before posting it. Or maybe he just doesn't want to post it yet. In any case, you should ask for permission first.  
> **username_0**: This has been done alll over the site, if mousetail has any objection they may say it here  
> **username_6**: I don't have a problem with re-using the basic premise of my examples as the basis for a more complex, fully fleshed out, high quality question but please refrain from just copying the title and and adding only very minimal context that clearly shows you know nothing about the subject  
> **username_0**: Why would I ask a question if I already knew a ton about it/the answer as a rule? @mousetail  
> **username_6**: You don't need to know the answer but you at least need to be able to intelligently describe the question  
---
## 1 answers
### Answer by username_3 on 2023-05-22. Score: 5 | Accepted answer
# LLVM

## Pros

* Better well known, leading to:
* More documentation and examples
* If it's your thing, more recognisability
* More bindings for various languages
* Text based format, if you don't have/want to use bindings

## Cons

* Large, and slow, both to compile and to run
* Not present on as many (linux) systems by default
* Slightly more complex interface (in my opinion)

# libgccjit

## Pros

* Simpler interface (in my opinion)
* Very slightly better optimisation engine in some cases
* Supports more assembly languages, and has been ported to more systems
* More likely to be present on a given (linux) system

## Cons

* No text based format, and only bindings for C/C++
* Not as battle-tested, for lack of a better term
* Can't really be used as a performant JIT compiler, despite the name

# Similar

Both have similarly powerful optimisation engines, so if you use them well, they'll both generate good code.
> **Comments:**
> **username_4** (2023-05-22): "No text based format." GIMPLE is a textual IR that GCC accepts as input with GIMPLE FE.  
> **username_3** (2023-05-22): @Longinus I am aware - I was talking about libgccjit, which does not have a text based format. As far as I know, libgccjit is intended as the "proper" way for outside programs to interface with GCC, so I did not mention GIMPLE.  
---
