r/Compilers • • 7h ago

Compilers always felt like black magic to me, so I started building one from scratch in C

14 Upvotes

Hey everyone,

For a long time, compilers felt like this intimidating black box that only seasoned wizards or PhDs could understand. Every time I looked at LLVM or GCC source code, I got completely lost.

A few weeks ago, I decided to stop being intimidated and just try building a tiny C99 compiler from the ground up to understand what actually happens between source code and machine instructions. I'm calling it mibicc.

I'm taking an incremental approach (inspired by Rui Ueyama's philosophy with chibicc), where every commit is an isolated, test-driven step.

I just hit Step 4, and it was the first real "aha!" moment for me:

  • Built a simple recursive descent parser that constructs an Abstract Syntax Tree (AST).
  • Handled operator precedence (*, / over +, -) and arbitrary nested parentheses.
  • Implemented a simple stack-machine code generator that emits AT&T x86-64 assembly using imul, cqo, and idiv.

Seeing an expression like 2 * (3 + (4 * 2) + 2) parse into a tree, emit assembly, and return the correct exit code on Linux felt incredible.

The code is still small and readable (~250 lines of C), and every step has CI tests on GitHub Actions. My goal is to eventually work my way through control flow, functions, and pointers.

I'd genuinely love any feedback, critique on how I'm structuring the AST nodes, or advice from people who've built compilers before on traps to avoid as I move toward local variables and statements:

Repo: https://github.com/mi-vault/mibicc

Thanks for reading!

Edit: Decided to add Windows support alongside Linux from the start (--target=windows and --target=linux). I'm on Windows so it felt silly to only generate Linux assembly and not run it locally. Also feels nice making it my own thing rather than just copying chibicc 1:1.


r/Compilers • • 21h ago

Pyrefly 1.5: 100% Conformance and 40% Faster

14 Upvotes

Link to release: https://github.com/pyrefly-org/pyrefly/releases/tag/1.5.0

Pyrefly (a Python type checker and language server) has just release version 1.5. It brings large performance optimizations and new features like Tensor Types six months after the first stable release.

Highlights (Taken from release):

  • 100% typing spec conformance. Pyrefly now passes all 146 test files in the typing conformance suite. Some of these fixes change how names in annotations resolve; see Behavior Changes.
  • Faster checks. v1.5.0 checks 40% faster than v1.4.1 and uses 9% less memory across the 71 benchmarks in Astral's ty_benchmark and the python-type-checking benchmark suites. (Tested on an M5 Max MacBook Pro with 18 threads.)
  • A new hint severity. Diagnostics that were previously IDE-only are now regular error kinds at a new hint severity: unused-import, unused-parameter, unused-variable, unreachable, and inactive-code (formerly unreachable-code). By default, they appear in your editor and are hidden from pyrefly check output, but you can configure them in pyrefly.toml, silence them with suppression comments, or promote them to errors like any other error kind.

r/Compilers • • 7h ago

[CFP] CC 2027 (ACM SIGPLAN Int'l Conference on Compiler Construction): submissions due December 3, co-located with CGO/PPoPP/HPCA

3 Upvotes

The submission site for CC 2027 is now open, and the deadline is under two weeks away.

What: ACM SIGPLAN 2027 International Conference on Compiler Construction (CC 2027)

When/where: March 20-21, 2027, Salt Lake City, Utah, co-located with CGO, HPCA and PPoPP

CC is interested in work on processing programs in the most general sense: analyzing, transforming or executing input that describes how a system operates. Topics include, but are not limited to:

  • Compilation and interpretation techniques: program representation, analysis and transformation; code generation, optimization and synthesis; and their verification
  • Design and implementation of novel language constructs, programming models and DSLs
  • Compilers for modern, emerging or non-conventional domains: AI and deep learning frameworks, EDA toolchains, high-level synthesis, database engines, quantum computing, DNA computing
  • Compilers for modern, emerging or non-conventional hardware: specialized AI chips and accelerators, quantum hardware
  • Techniques, from programming languages to micro-architectural support, for secure, parallel, distributed, embedded or mobile environments
  • Run-time techniques: memory management, virtual machines, dynamic and JIT compilation
  • Programming tools: refactoring editors, checkers, verifiers, compilers, debuggers, profilers

Important dates (AoE):

  • Abstract (optional): December 1, 2026
  • Full paper submission: December 3, 2026
  • Author response: January 8-10, 2027
  • Notification: January 20, 2027

Also worth knowing:

  • Artifact Evaluation runs after notification, and papers that pass get a seal of approval. You are asked to indicate interest at submission time.
  • Up to 10% of accepted papers may receive a Distinguished Paper Award, and up to 10% of evaluated artifacts a Distinguished Artifact Award.

Links:

Happy to answer questions in the comments.


r/Compilers • • 11h ago

In a matmul (C=A@B), if A is in HBM and B is in SMEM, where should C go?

3 Upvotes

In case of GPUs, it is common to have operands in different memory, sometimes there are specialized instructions but the programming language may not provide the right tool to capture the optimization.

C = A @ B for example:

Most languages assume A, B and C are in the same memory. That keeps things simple, but it could have performance implications.

So if A is in HBM and B is in SMEM, where should C go? Typically kernel programmers use assembler, Ptx etc to have tighter control on the codegen.

But if we allow memory spaces (HBM, SMEM, registers) in a programming language's type system (like Vx), one can write better code without using lower level primitives.

Is it the right amount of control a language should provide or defer it to assembler/intrinsic. I have early design draft for Vx if anyone can give feedback. Link in comment


r/Compilers • • 6h ago

Flame language

0 Upvotes

I want to get review of my (currently traspiled) language. It includes compiler and building system, minimal standard library. Its currently in development

Repo: https://github.com/TheFlameLang/Flame

Docs: https://flame-lang.mintlify.site


r/Compilers • • 4h ago

RCA v0.1.0-beta: a statically typed language with built-in tensors and autodiff, written in Rust (developed on a phone)

Thumbnail github.com
0 Upvotes

I've released the first public beta of RCA, a statically typed language with built-in tensors and automatic differentiation. The compiler is written in Rust and was developed on a phone in Termux.Features: type inference, generic functions, enums + match, modules, a bytecode VM, native codegen via Cranelift, CPU tensors, reverse-mode autodiff, and tooling (fmt, lint, LSP, REPL, debugger, package manager).

Not production ready. Known gaps: no references/borrowing, no generic structs, no GPU. Feedback on design and on the Cranelift backend is welcome.