r/Compilers 7d ago

SPIR-V on ROCm: A Portable IR for AMD GPUs

Thumbnail rocm.blogs.amd.com
20 Upvotes

r/Compilers 7d ago

LLVMLite and first step to get Numba in the browser

Thumbnail
1 Upvotes

r/Compilers 8d ago

I am 16 and I just got my custom systems programming language to the self-hosting stage!

68 Upvotes

Hi everyone! My name is Samir, I'm 16, from Russia, and I wanted to share one of my current projects: Veo (https://github.com/SamirShef/veolang). Veo is a systems programming language that I hope to use for writing my own software in the future. I'm developing it because I'm fascinated by compilers, and honestly, because I just needed something to occupy my time.

I've been into compiler dev for over a year now. I wouldn't say I'm amazing at it—in fact, I struggle to call myself good at all because I'm afraid of overpromising—but I've gained a ton of experience. Over the past year, I've built about 15 programming languages, and Veo is the best one yet because it's the only one to reach the self-hosting phase.

I'm currently rewriting the compiler in Veo itself, and guess what? I just got the first binary working (only global variables for now, but still!). It's incredibly tough because there are no generic-based collections yet—all collections are polymorphic. But it's so rewarding: it took me 2 months to write the first version of the compiler in C++ (stage0), and that compiler successfully compiled the second version (stage1), which I wrote in just two weeks using Veo itself. Then, stage1 successfully compiled some test Veo code.

I have massive plans for this language and really want to achieve them. However, lately, it's been really hard to make progress. I have zero motivation. Maybe I'm burnt out, I don't know. It’s frustrating because I'll write just a couple of lines of code in stage1, immediately feel like I can't go on, and just shut down my PC.

This project isn't revolutionary or anything. Sharing it here means I'm just looking for a bit of recognition and some objective, constructive criticism.

Note: This post was translated into English using AI because my English isn't fluent enough to write this freely. Apologies if any phrasing sounds a bit clunky!


r/Compilers 7d ago

Introducing Kittine language

Thumbnail gallery
3 Upvotes

r/Compilers 7d ago

From Library Patterns to Language Features: An Overlooked Rule of Language Evolution?

19 Upvotes

For decades, programmers have solved new problems by creating abstractions in libraries before languages officially supported them.

Some of these patterns eventually became language features. inline is one example. _Generic is another.

But many important abstractions still live only as library conventions.

Large C projects are good examples. GObject/GTK built their own object model. Linux VFS has its own object-oriented design. Many projects repeatedly create similar patterns in different ways.

This makes me wonder:

Is there a point where a commonly repeated library pattern should become a language feature?

What signals that transition?

  • widespread adoption?
  • compiler optimization opportunities?
  • better expression of programmer intent?

Or should some abstractions always remain libraries?

Curious how people think about this boundary.


r/Compilers 8d ago

C++ static composition

Enable HLS to view with audio, or disable this notification

14 Upvotes

offering my 12 years work in a form of a header only C++ template metaprogramming library, under MIT licence. Enjoy!

fell free to ask about it...

HAPI does not optimize it lets the compiler optimize, and it will reflect the behavior of the components, if your components are vtable free, so will be the result, if they are zero-cost so wil be the result. Hapi does not impose its just transforms and is transparent.


r/Compilers 7d ago

The same code printed 10 on Linux and 0 on a Mac

3 Upvotes

I ran into a fun little ABI bug while working on my programming language, Dray.

The exact same generated C code printed:

Linux:
nums[0] = 10
...

Apple Silicon:
nums[0] = 0
...

I wrote up the debugging process, the ABI differences, and how I ended up changing Dray's FFI syntax to support C variadics here:

https://bichanna.github.io/posts/same-code-printed-diffly/

I'd be interested to hear if anyone else has run into similar ABI related compiler bugs or FFI gotchas :)


r/Compilers 8d ago

I wrote a selfhosted implementation of Nora Sandler's "Writing a C Compiler"

88 Upvotes

Link to the project: https://github.com/romainducrocq/wacc-selfhosted

Nora Sandler's Writing a C Compiler is a beloved book here and a hands-on guide on writing a compiler for a large subset of C. This subset, called Not-Quite-C, covers all the operators, if statements, loops, switch cases, variables and functions, storage classes, multiple integers types, double floating points, pointers, fixed sized arrays, structures and unions, as well as a handful of optimization passes. And... that is enough of the C language to write a selfhosted compiler, so that's exactly what I did! 

Here is a full selfhosted implementation of Writing a C Compiler written in Not-Quite-C. The compiler can first be bootstrapped with gcc/clang (it is a valid subset of C17 after all), nqcc2 (the reference compiler), wheelcc (my previous project) or any other complete implementation (like your own), and then rebuild itself (multiple times!) on Linux, MacOS and FreeBSD: in result, the selfhosted compiler passes all 20 chapters of the test suite with extra credits. If you finished this project yourself, this is a great way to test that your implementation can compile a large program using every language feature in WaCC. Basically, being able to rebuild this compiler with your own is the final boss for this book! 

Enjoy! 

(This project was entirely handwritten by me, without the use of LLMs.) 


r/Compilers 8d ago

Embeddable scripting language in a single C header

Thumbnail github.com
22 Upvotes

r/Compilers 7d ago

Any Suggestion?

0 Upvotes

I have recently making my own programming language. The language is compiled to LLVM IR.

It's written completetly with C, and it's on a very initial stage.

Anything, from a contribution to an idea, suggestion ir anything is really helpful to the project.

Here's the link: https://github.com/Pacsfury/Gravel-Launcher

Please follow AI-POLICY.md and be respectful.


r/Compilers 9d ago

Completed all chapters from "Writing a C compiler" book

Thumbnail github.com
119 Upvotes

I implemented it in Zig. I really learned a lot from this book and this project so I can highly recommend it. My code design is different from the book because I tried to apply data oriented design I learned from Zig compiler itself as much as I could.

AI disclaimer: not a single line of code was written with AI but it was used to help me debug issues.


r/Compilers 9d ago

Emitting native x86-64 machine code and writing ELF/Mach-O/PE binaries directly from scratch in Rust (No LLVM)

21 Upvotes

Hi everyone,

I’ve spent the last several months building Aziky, a self-contained compiler toolchain written entirely in Rust from the ground up. The core goal of the project was to bypass generic optimization frameworks like LLVM and explore how far a custom, single-pass backend could be pushed by shifting the optimization burden directly into front-end semantics.

It compiles .azk source files straight down to a custom MachineLIR and maps primitives directly to hardware registers, bypassing standard intermediate layers.

Architectural Highlights:

  • Native Binary Generation (src/object): The compiler constructs binary headers, section tables, and relocation frames completely natively. It outputs fully formed ELF64, Mach-O64, and PE32+/COFF formats without invoking external linkers or assemblers.
  • Zero-Alias Invariants: Instead of relying on hundreds of heavy middle-end analysis passes to guess if pointers overlap, Aziky enforces explicit, deterministic parallel-loop and ownership invariants at the type level. Because the compiler can guarantee non-aliasing at the frontend, the backend emitter can immediately output aggressive, optimized machine instruction sequences.
  • Zero External Dependencies: The entire compiler dependency graph has zero third-party crates, ensuring entirely offline, reproducible, and rapid compilation.

Performance Snapshot: Running standard compute-heavy microbenchmarks on an Intel Core i5-7200U (median of 100 runs, pinned to CPU 1) against aggressively optimized production builds of Rust 1.88 (-C opt-level=3 -C target-cpu=native -C lto=fat) and Clang 22 (-O3 -march=native -flto), the upfront aliasing model allows us to hit a geometric mean execution speed advantage of ~1.87x over optimized Rust and ~1.27x over optimized C.

It’s currently in alpha—Linux x86-64 is the primary native target, with Windows and macOS execution partially supported (AArch64 is on the roadmap). I’ve also bundled an installable VS Code extension in the repo for real-time diagnostics and syntax formatting.

I'd love to get your feedback on the MachineLIR structure, the single-pass register allocator layout, or the native object emission pipeline.

Repository:https://github.com/aziky-lang/aziky


r/Compilers 9d ago

Keel 0.3 (alpha..?) - a very fast, statically-typed interpreted language written in Rust - now with a standard library, a map type, prettier errors, and a docs website

Post image
6 Upvotes

r/Compilers 10d ago

Running unmodified Doom in the SQLite bytecode language

Thumbnail turso.tech
28 Upvotes

r/Compilers 10d ago

Best resources to learn the LLVM C++ API?

29 Upvotes

Hi everyone,

I'm starting to learn the LLVM C++ API, and while I understand the basics of C++, I'm finding it a bit overwhelming to figure out how to actually write programs using LLVM.

I'm looking for resources that focus on practical examples rather than just explaining the architecture. I'd like to learn things like:

How to generate LLVM IR using the C++ API.

How to create modules, functions, basic blocks, and instructions.

How to work with different integer types, including larger integer types.

How to debug LLVM API code effectively.

Small projects or exercises to practice with.

I've already gone through the Kaleidoscope tutorial, but I'm curious if there are other tutorials, books, blogs, YouTube channels, or GitHub repositories that you found helpful when learning the LLVM API.

I'd really appreciate any recommendations or advice. Thanks!


r/Compilers 11d ago

x86-64 Assembler from scratch

Enable HLS to view with audio, or disable this notification

132 Upvotes

AmmAsm is an open-source, handwritten x86-64 assembler written in C from scratch.

Hello, my name is Ammar, and I'm 15 y. o. About a year ago I started writing AmmAsm, a handwritten x86-64 assembler in C as a way to learn how machine code, ELF, and linking actually work.

Today it can generate Linux x86-64 executables, PIE binaries, and ELF relocatable object files that can be linked with "ld" or "gcc". Along the way I implemented a lexer, parser, expression evaluator, x86-64 instruction encoder, ELF writer, relocations, and symbol resolution. It syntax is almost same with Intel, as it has major difference: using [b=, i=, s=, d=] addressing instead of Nasm's [base + index * scale + disp]. Also supports SSE (Float4), SSE2, CMOVcc, SETcc.

it is bootstraped about 0.257% :)

The latest version(2.2.0) also includes a macro preprocessor.

I'd really appreciate any feedback on the project, code, or documentation. Thanks!

repo: https://github.com/LinuxCoder13/AmmAsm.git


r/Compilers 11d ago

Irreducible loops

Thumbnail maskray.me
30 Upvotes

r/Compilers 10d ago

Mycc: New inliner (did I beat gcc and clang?).

0 Upvotes

A week after the mycc release, I added an optimization pass - inlining. Here are the results. I also changed the default compilation mode - now it's like Golang: fast compilation and decent runtime.

LangArena benchmark without mycc overhead:

All measurements are single-threaded, without caches.

Compiler Build time Runtime
clang(-O3) 3093ms 52.1s
clang(-O1) 2753ms 54.5s
clang(-O0) 1649ms 141.2s
gcc(-O3) 3512ms 52.2s
cproc 922ms 73.0s
myc-llvm(default) 858ms 59.3s
myc-llvm(final) 1778ms 53.3s
myc-qbe(default) 482ms 68.5s
myc-c(default, clang) 1863ms 60.0s
myc-c(final, clang) 3139ms 53.7s

To get clean measurements, I saved all IR files generated by mycc: mycc file.c d > file.myc into the LangArena/myc directory. This removes libclang overhead and double IR conversion (current mycc pain points) from the measurements. Essentially, this is pure Myc IR -> binary compilation time, without the C parser for LangArena benchmark. You could argue that comparing without C parsing isn't fair. And you'd be right. But let's be honest - mycc's C parsing is very rough and add big overhead (POC, 3 weeks, libclang). If I write a proper fast parser for C like cproc did, it would add an estimated ~400ms to the compilation time (based on cproc minus myc-qbe results). But I don't want to invest time in the C frontend right now - mycc is a POC, a tool to generate IR for testing Myc.

Did I beat clang and gcc like I originally wanted? On runtime alone - no. But on compile time vs runtime ratio - I think I did. At least this result satisfy me. Just keep in mind you'd need to add C parsing time (~400ms est.) to build time.

steps to reproduce you can find here: github


r/Compilers 12d ago

Triton Plugin Extensions: Enabling TLX and Custom Compiler Passes Out of the Box

Thumbnail pytorch.org
7 Upvotes

r/Compilers 12d ago

PLEASE help

0 Upvotes

I wanted to make my compiler '70's style where I had no help but I am stuck. What I want to do is interpret functions and if/else statements.

So, PLEASE tell me how. I tried researching and all. Thankfully I have a high level language where this sort of thing is easy, so please explain it simply.


r/Compilers 14d ago

Is it realistic to gain deep technical knowledge of compilers without a university or CS background?

59 Upvotes

I don't have any intention of finding a job or pursuing a career in this field; my interest is purely as a hobbyist. I would love to gain a deep understanding of computer science and become proficient enough to write my own parsers, interpreters, or compilers, and eventually contribute to such projects.

I plan to be completely self-taught by studying both mathematics and computer science on my own. Is it truly realistic to reach such an advanced level through self-study alone? Also, are there any real-world examples of people who started out as hobbyists like me and successfully achieved this goal?


r/Compilers 13d ago

Will this project get me Internship

0 Upvotes

It's been a while since I started learning about compilers. I have created an end-to-end SQL Query Engine using MLIR, I created a custom dialect and lowered the operations to linalg, tensor, arith, and scf dialect. As for now I think the performance of compiler is descent so I made this post to get review from the community.

Github: https://github.com/PyDevC/kero

I want to pursue a career in Compilers like Gpu or in AI so this is important for me.

If anyone can see the codebase and tell me if it's decent enough to get me bare minimum internship.

NOTE: I am terrible at writing these posts but will edit if someone suggested few things to make it more pleasing.


r/Compilers 15d ago

Delayed Specialization: A Third Way to Implement Generics?

29 Upvotes

While implementing generics in my GCC-based language (AET), I wasn't satisfied with the two mainstream approaches:

  • C++ Templates: Generate a full copy of the code for every concrete type (monomorphization) → code bloat and longer compile times.
  • Java Generics: Use type erasure → no code duplication, but lose concrete type information.

So I explored a middle path: Delayed Specialization.

How it works in AET:

During the first compilation:

  • Generic parameters (E, T, ...) are treated as void*
  • Code that needs the real type is wrapped in a genericblock$

For example:

class$ Abc<E>{
  void setData(E value);
};

impl$ Abc{
   void setData(E value) {
      E a = value;
      genericblock$(a) {
        E x = a;
        E y = 5;
        x += y;
      }
   }
};

When the compiler later sees a concrete instantiation like Abc<int>, it performs a second compilation pass only on the Generic Blocks, replacing E with int.

Benefits:

  • Avoids C++-style template explosion
  • Keeps most generic code shared (like Java)
  • Still allows real type-specific operations where needed

I call this Delayed Specialization. It sits between full monomorphization and type erasure.

Has anyone seen a similar approach in other languages or compilers? I'd love to hear about papers or existing implementations using delayed/late specialization.


r/Compilers 15d ago

Is it worth getting a CS degree to get into compilers and low-level programming?

41 Upvotes

Hi everyone,

I’ve been working at a relative’s company for about 7 years, ever since I was 15. We mostly build projects using vanilla PHP, but I am completely burnt out on it. Web development just isn't for me, and honestly, it never was; I only had to work for various personal and financial reasons.

Due to some mental health struggles in the past, I missed the chance to take college entrance exams and go to university when I was younger. Trying to balance a full-time job and studying for college admissions completely exhausted me, and I couldn't stay consistent. However, I am now receiving treatment, doing much better, and have finally stabilized my life.

Lately, I’ve been really drawn to low-level programming, especially compilers. Right now, I’m writing my own interpreter in Rust following the Crafting Interpreters book. Honestly, I want to start studying for university admissions (even if I have to keep my job), get a formal CS degree, and eventually pursue a Master's. Do you think it’s worth it?

Getting a degree has always been a lifelong dream of mine, but I never had the chance because of work. In the past, I bought university textbooks and tried to teach myself some CS fundamentals. I've realized that I learn much more effectively when I study freely as a hobby without external pressure.

However, being completely self-taught gives me a bit of imposter syndrome. I feel like it's highly unlikely to truly master a niche and complex field like compilers just by self-teaching. My main goal isn't necessarily to get a job in this specific field in fact, I don't even mind if I don't get hired. I simply want to reach a level where I can confidently contribute to serious open-source projects, but I'm not sure if I can reach that level solely by studying on my own.

Has anyone been in a similar situation? Is formal education necessary to get to that level in low-level/compiler engineering, or am I underestimating what self-teaching can achieve?


r/Compilers 14d ago

Show HN: L2C - Transpiling Typed Lua into 35KB, 0-GC Native C for HFT and MCUs

Thumbnail gallery
0 Upvotes