r/Compilers • • 18h ago

[Project] MLIR-to-Vulkan HAL Prototype — looking for feedback on [lowering / architecture].

5 Upvotes

I've been working on a prototype for an MLIR-backed Vulkan Hardware Abstraction Layer (HAL) in response to https://github.com/modular/modular/issues/7413 and wanted to share it here for feedback: here is my attempt at it

Repo: https://github.com/billyblackburn/mlir-vulkan-hal-prototype

What it does:

Goal: [e.g., Lightweight, vendor-agnostic GPU compute execution in spirv]

Lowering pipeline: [e.g., linalg / gpu → spirv → Vulkan runtime dispatch]

Currently working: [e.g., Basic compute kernel lowering, buffer allocation, and dispatch]

What I'd love feedback on:

[e.g., Dialect/pass structure and whether the HAL boundary makes sense]

[e.g., Any pitfalls with SPIR-V lowering or Vulkan memory/descriptor management]

Happy to answer any questions or discuss the design choices.


r/Compilers • • 2h ago

What if a programming language could intelligently manage its own memory and execution?

Thumbnail reddit.com
0 Upvotes

Similarly, imagine a graphics application where only one object changes. The runtime could identify which data actually needs updating instead of recalculating everything unnecessarily.

My goal isn't simply to create another garbage collector or claim that this will automatically outperform existing languages.

I'm exploring whether a programming language can make resource management more intelligent while keeping it automatic for the programmer.

I'd like to hear your thoughts:

Would combining adaptive memory management, predictive execution, and incremental processing make sense as part of a language runtime?

Or would you prefer these responsibilities to remain separate systems?

I'm particularly interested in the architectural trade-offs and potential problems with this approach.


r/Compilers • • 8h ago

Keen: A Rust-syntax frontend for C

Thumbnail github.com
0 Upvotes

Hey everyone,

I’ve been working on Keen, a language that gives C a modern, Rust-inspired syntax and Cargo-like tooling without changing C’s underlying semantics.

The core idea

Keen changes C’s syntax only. There is no borrow checker, no type checker, and no safety enforcement. All of C’s rules (integer promotion, ABI, linkage, UB) remain completely intact. Keen transpiles .kn files to C, hands them off to gcc or clang for semantic checking and compilation, and maps compiler diagnostics directly back to your .kn source lines via #line directives.

It's aimed at C developers who want modern ergonomics (modules, match, for i in 0..n, no header boilerplate, built-in testing/formatting) without giving up C's simplicity, or C devs looking to get comfortable with Rust's syntax before tackling the borrow checker.

What a quick example looks like

use <stdio.h>;

struct Point { x: f32, y: f32 }

impl Point {
    pub fn len2(p: *const Point) -> f32 { p->x * p->x + p->y * p->y }
}

pub fn main() -> i32 {
    let p = Point { x: 3.0, y: 4.0 };
    printf("%.1f\n", Point::len2(&p) as f64);
    return 0;
}

What’s included out of the box

  • Zero-dependency toolchain (whet + keen): Includes keen new, incremental keen build, keen run, keen fmt (comment-preserving, idempotent), and keen test (runs #[test] functions in isolated processes).
  • Seamless C interop: Use #include via use <stdio.h>;, drop down to raw C anytime with c!("..."), link existing .c/.o/.a files, or use keen emit --split to generate clean .h/.c files for existing C projects.
  • No forward-declaration headaches: Types and functions can be declared in any order; pub handles external linkage while everything else defaults to static.

Try it out

GitHub: https://github.com/romishalom/keen

I'd love to hear your thoughts on the syntax mapping, edge cases with C interop, or what features you'd want to see next!


r/Compilers • • 2d ago

Is compilers worth it to specialise in ?

50 Upvotes

(19M, Nepal(south asia)) I am currently in the third year of my ug and am fascinated by this field and preferably want to continue it till masters or pHd if i can get one . unfortunately i come from pretty strapped background and would need to sustain myself , but dont really have enough judgement to discern what implications of ai would be here, and if i should really continue.
I am also find doing lc pretty enjoyable , but i dont think that skill would be any valuable here.

Thanks , i would really appreciate your input.


r/Compilers • • 1d ago

oksolc 0.2.5, a faster Solidity compiler written in Zig, now supports solc 0.8.36 to 0.8.39

Thumbnail github.com
1 Upvotes

oksolc 0.2.5 now supports solc 0.8.37, 0.8.38 and 0.8.39, as well as solc 0.8.36.

Before oksolc 0.2.5, the compiler targeted only solc 0.8.36. A project pinned to a later release had no way to get the same bytecode from oksolc that its own solc produces.

What oksolc is

oksolc is a new Solidity compiler written in Zig. It accepts the same Standard JSON input as solc, and on the 12 projects we measured it built 3.3 to 6.0 times faster than solc's via-IR pipeline.

We wrote it for our own use while developing Chainwall. The goal was shorter build times during contract development.

oksolc provides a command-line tool, a C library with the same interface as libsolc, and a Zig module. The supported compilation path is optimized via-IR through Standard JSON.

What changed in oksolc 0.2.5

  • The default is now solc 0.8.39, and --solc-version selects any of the three earlier releases. The selected release controls pragma checks, code generation, diagnostics and metadata.
  • block.slotnum and Yul slotnum() compile on the Amsterdam EVM version from the solc 0.8.37 target onwards.
  • solc fixed four via-IR bugs between solc 0.8.37 and solc 0.8.39: SOL-2026-4, SOL-2026-6, SOL-2026-7 and SOL-2026-8 in the Solidity compiler bug list. oksolc applies the same fixes on every target.
  • Checked and unchecked arithmetic get separate constant helpers, and Yul returndatacopy calls that can revert keep their bounds checks.

I compiled the 14 projects bundled with the oksolc benchmark with both compilers, on each of the three new solc releases. The complete Standard JSON output was the same every time. The README reports the same result for 17 workloads.

The solc 0.8.36 target keeps the security fixes and the constant-helper fix, so its bytecode can differ from solc 0.8.36. The README documents each difference.

Build times on 12 open-source projects

For each project we sent the same Standard JSON build request to solc 0.8.39 and to oksolc 0.2.5 targeting solc 0.8.39. oksolc ran on 1 job and on 4 jobs. The benchmark records a result only when both compilers produce the same bytecode. Both compilers ran the optimized via-IR pipeline, so these times compare oksolc with solc via-IR, not with solc's default pipeline.

Projectsolc 0.8.39oksolc, 1 joboksolc, 4 jobs
Sablier v2 1.2.0523.1 s208.4 s145.9 s
EigenLayer 0.3.0175.1 s77.9 s40.0 s
Solady 0.1.2658.1 s29.2 s17.5 s
Uniswap v4 (2024-06-06)39.3 s18.2 s7.4 s
Pendle v2 (2026-09-16)26.0 s12.1 s6.8 s
OpenZeppelin 4.8.020.9 s9.7 s3.7 s
OpenZeppelin 4.7.018.9 s8.8 s3.2 s
Liquity (2024-10-30)14.7 s7.0 s3.4 s
OpenZeppelin 4.9.013.6 s6.4 s2.7 s
OpenZeppelin 5.0.210.8 s5.1 s2.0 s
OpenZeppelin 5.6.110.3 s4.9 s1.7 s
Uniswap v4 (2022-06-16)6.6 s3.1 s1.3 s

With a single job, oksolc built every project 2.0 to 2.5 times faster than solc. With 4 jobs, it was 3.3 to 6.0 times faster. Building all twelve took 15 minutes 17 seconds with solc and 3 minutes 56 seconds with oksolc on 4 jobs.

Incremental builds are faster still. In a serve or watch session, oksolc keeps the compiler in memory and reuses work between edits.

I measured on my Apple Silicon MacBook Air with 16 GB of memory. The solc times and the oksolc 4-job times are the median of 3 runs after 1 warmup run. The 1-job times are single runs. On 4 jobs, oksolc used more memory than solc on most projects, for example a peak of 5.3 GiB against 2.4 GiB on Solady. Sablier v2 peaked at about 8 GiB with either compiler in these runs, and its three runs varied more than any other project's.

Sablier v2, the largest project in the set, went from 8 minutes 43 seconds with solc to 2 minutes 26 seconds with oksolc on 4 jobs, with the same bytecode.

How to use it

You need Zig 0.17.1. Build oksolc from the release tag:

git clone https://github.com/okcontract/oksolc
cd oksolc
git checkout v0.2.5
zig build -Doptimize=ReleaseFast
./zig-out/bin/oksolc version

For a Foundry project, point foundry.toml at the oksolc executable and enable optimized via-IR:

[profile.default]
solc = "/absolute/path/to/oksolc/zig-out/bin/oksolc"
via_ir = true
optimizer = true
optimizer_runs = 200

Then run forge build as usual. If the project has artifacts from another compiler, run forge clean first.

This configuration builds with via-IR. If your project does not use via-IR today, the bytecode will differ from your current build.

Parallel compilation is off by default. Turn it on with an oksolc.toml next to foundry.toml:

parallel = true
jobs = 4

The incremental compiler keeps its cache between runs only if you set cache = true in ~/.config/oksolc/config.toml.

Through Foundry, oksolc uses its default target, solc 0.8.39. To select another release, use the command line:

oksolc standard-json --solc-version 0.8.37 request.json

oksolc has a web server built in

oksolc can serve a local page for browsing a compiled project. It lists the project's source files next to the file you select, with an outline of everything that file declares.

For each contract the page also shows the ABI and the creation and runtime bytecode with their sizes. You can search the project, and two side panels list diagnostics and references.

open in the oksolc browser

The browser is left out of a default build. Build with -Dbrowser=true, which needs Bun 1.4.5 and TypeScript 7.0.2, then run it from your project:

oksolc serve --browse

Open http://127.0.0.1:8080. serve watches the Solidity files in src/ and recompiles when they change. To browse a single Standard JSON request instead, run oksolc browse --request input.json.

Including the browser adds about 0.3 MB to the binary.

What should it show next? Open an issue and tell us.

Try it on your project

Build one of your own projects with oksolc and compare the result with solc. If the two differ, open an issue on github.com/okcontract/oksolc and include the output of oksolc version --json.

If oksolc is useful to you, star the repository. For new releases, follow us on X at u/okcontract.


r/Compilers • • 1d ago

An Intermediate Language Case Study

6 Upvotes

In this post I just want to present the API for my own IR, as an example of what one might look like at a vastly smaller scale (compared to LLVM). I am not selling it, and I'm not giving any links (none exist anyway). It's just something different.

Only the high-level functions for managing an entire program are listed. 'PCL' is the IL name.

Possibly, it might be simpler than QBE, however QBE deals with only a small part of the pipeline (it turns SSA text into ASM text).

proc pcl_start    (int nunits = 0)       # (Syntax is my systems language.)
proc pcl_end
func pcl_runpcl   :int
proc pcl_genmcl
proc pcl_genss    (int obj = 0)
proc pcl_exec
proc pcl_writeexe (ichar filename)       # ('ichar' is like char* in C)
proc pcl_writedll (ichar filename)
proc pcl_writeobj (ichar filename)
proc pcl_writemx  (ichar filename)

func pcl_writeasm (ichar filename = nil, int atype = 'AA')ichar
func pcl_writepcl (ichar filename = nil)ichar
func pcl_writepst (ichar filename = nil)ichar
func pcl_writess  (ichar filename = nil, int obj = 0)ichar 
proc pcl_cmdskip  (int cmdskip, psymbol dcmdskip = nil)

pcl_start Start a new IL program and ST. The optional 'nunits' argument gives an estimate of the program size.

At this point, there is set of 40 lower-level functions, starting with 'pc_' and 'gen_', used to build IL code, data and symbols. This is done for an entire program as this is designed for whole-program compilation.

This library uses a single global context so no context handles need to be returned or passed.

pcl_end Write an end-of-program marker. This IL program is now complete.

pcl_runpcl Run the program via interpretation of the IL. This is not fast or efficient, but it is useful for debugging, experiments, profiling or for fun. The return value is the program exit code.

pcl_genmcl Turn the IL into a native code representation. Mainly this is for x64/Windows. Experimental backends have been done for 8-bit Z80, with a brief foray into ARM64/SYS V.

pcl_genss Turn the native code representation into binary machine code.

pcl_exec Fix up the binary machine code and run it in memory.

pcl_writeexe pcl_writedll Write Windows EXE or DLL files.

pcl_writeobj Write an object file in PE+ format (this is the only time a linker is needed)

pcl_writemx Write the program in my private executable binary format

pcl_writeasm Dump as ASM source to a file or string. Supports four formats: AA (mine), NASM, GAS, and MASM, although usually only one is configured in a particular build.

pcl_writepcl Dump as IL source code to file or string. This is for debugging mainly but the result can represent an entire program (see below).

pcl_writepst pcl_writess Write the IL symbol table or dump the generated binary to a file or string.

pcl_cmdskip This is to do with moving the command line parameters when invocation is complex (see example below).

The call-pattern to generate an EXE file say might be:

  pcl_start()
  genpcl() ...
  pcl_end()
  pcl_writeexe(outfile)  # calls pcl_genmcl/pcl_genss if needed

The above library is normally built-in to a compiler. The library can also be built into a standalone DLL, a dynamically linked library. I might do that if I wanted to use it from my scripting language, say.

What I don't have in this API is a way to read textual IL from a file. That is done in a standalone application that contains the necessary front-end.

Some stats for this library that includes all the above:

Line count:   17 Kloc
Build time:   60 msec
EXE size:    180 KB

JIT This is not needed since compilation is so fast.

Optimisation That is not used, but generated code is decent: typically within a factor of two of optimised code.

(Shortened and edited.)


r/Compilers • • 2d ago

LLVM C API vs LLVM C++ API for own compiler on C++

17 Upvotes

What is better?


r/Compilers • • 3d ago

I traced one C program through every stage of GCC: preprocessor, GENERIC, GIMPLE, SSA, RTL, assembly and linking

Thumbnail satvikcode.com
26 Upvotes

r/Compilers • • 3d ago

Is ClangIR(CIR) better than raw LLVM IR?

8 Upvotes

Just found it, and it seems more easily to understand than LLVM IR


r/Compilers • • 2d ago

I'm building a TypeScript type checker in Rust. It agrees with tsc on 56.6% of the official test suite

0 Upvotes

I wanted to see if TypeScript could get a rustc-style checker: query-based, incremental, and designed to be embedded. It's a from-scratch semantic engine, not a port. I skipped writing a parser and built on Oxc, so the work goes into the hard part: types, generics, flow narrowing, and cross-file incremental checks.

```

TS source → Oxc (parse, scopes) → bridge → tsox semantic core → diagnostics

```

What it does today

- Matches tsc exactly on 56.6% of the TypeScript v6.0.3 test corpus (8,072 of 14,274 files). The corpus is the whole release: single-file, multi-file and JSX cases.

- Checks classes, generics with inference, `keyof`, conditional types with `infer`, overloads, async and narrowing.

- Re-checks only what an edit reaches, through a Salsa-backed project engine.

- Ships an LSP (diagnostics, hover, completion, go-to-definition, references, rename), VS Code and Zed extensions, and a WASM build.

How it's built

- Queries: every semantic question is memoized, so an edit re-runs only the queries it touches.

- Cycles: import cycles are resolved as strongly connected components.

- Types: they're interned IDs in one arena, so type equality is an integer compare.

- Rules: they're table rows, so adding a rule means adding one line.

What it doesn't do yet

It's experimental. It misses some errors that tsc reports and, less often, reports one that tsc doesn't. I publish the gap with every change, measured against the corpus, so you can see exactly where it stands.

A note on speed and memory

I'm deliberately not publishing speed or memory numbers. tsc and the other full checkers check every file completely. tsox doesn't yet: it still skips, or only partly checks, a large share of what tsc checks (the 43.4% of the corpus that doesn't match exactly), so its times and memory use would be for less work. A comparison like that isn't correct, however good it looks. I'll publish numbers once tsox checks the same things they do.

How you can help

- Conformance triage: pick a diagnostic code, read what tsc does, and write the smallest fix that turns a batch of files into matches.

- Fixtures: a failing case in `tests/fixtures/` is how most changes start.

- Real code: try it on your own TypeScript and open an issue where it disagrees with tsc.

To try it

```bash

git clone https://github.com/tsoxide/tsox.git

cd tsox

bash scripts/ci.sh

```

AI-assisted PRs are fine. I use an assistant too, so please read and test what you send and say so in the description.

Repo: https://github.com/tsoxide/tsox

Docs: https://tsoxide.github.io/tsox/


r/Compilers • • 3d ago

An IL2CPP decompiler

0 Upvotes

Hi there, im working on a apk to source decompiler tool chain with full game compiled and run smoothly on almost any IL2CPP Unity game apk/ipa. Actually i have done for almost 40 games top of market focus on hybrid casual even the liveops part. Some game with pairIP anti Frida and BeeByte Obf still can break. But im not sure about public the kit since i dont know how it will impact. The de-compilation process took 1 day for everage size game to 5 days on massive game with million lines of code decompiled with LLM support.


r/Compilers • • 3d ago

Has anyone implemented capability types for a programming language?

0 Upvotes

A recent news where NEAR AI reported that an attacker exploited a RCE vulnerability in SGLang exposing account details etc.

At this point it seems like we need a better way to program inference systems. As per Claude's research and SGLang's published RCEs this year share a pattern: Python features that run code by design, exposed to the network.

  1. Pickle over sockets. A ZMQ broker calls pickle.loads() on unauthenticated data, and one scheduler socket binds to 0.0.0.0 by default.
  2. Malicious model files. A GGUF chat_template can carry a Jinja2 template-injection payload because templates weren't sandboxed, and a torch.load(weights_only=False) fallback unpickles .bin files.
  3. Weak admin endpoints. LoRA loading allowed unauthenticated RCE through an incomplete pickle denylist, and /server_info returned API keys.

This is where *capability types* can help programmers and tools and AI reason about the attack surfaces. Vx is in early stages so adding capability types is not too difficult at this point but I'd like to learn from someone who has done it before.


r/Compilers • • 5d ago

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

30 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 • • 4d ago

I got tired of Python-wrapped VMs, so I rewrote my language’s entire frontend in Pure C. Here’s what happened in FoxVC v2.0 & the 0.7.1 “Titan” update.

0 Upvotes

Hey r/Compilers !

 A while back, I started building FoxVC—a lightweight, zero-dependency scripting language and bytecode virtual machine designed around 25 deterministic keywords
 (act, emit, pick, alt, spin, pulse, etc.).

 Like a lot of hobby language projects, it originally started with a classic architecture: a Python frontend (lexer, AST parser, bytecode compiler) that called
 into a fast C VM (foxvm.so) via ctypes.
 It was fun, it worked, but eventually, I hit what I call the "3-language duplication trap":
 1. You write a feature in Python.
 2. You have to sync it with your C VM.
 3. Then you want a WebAssembly browser playground, so you end up maintaining a third JavaScript parser that slowly drifts out of sync.
 4. Worst of all: cold-start latency sucked. Spawning Python just to parse a 20-line .fox script took ~200ms before the C VM even touched the first bytecode opcode.

 Over the last few weeks, I pushed two massive updates—v2.0.0 (Engine 0.7.0) and today’s v0.7.1 “Titan” update—to completely overhaul the engine.


r/Compilers • • 5d ago

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

7 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 • • 5d ago

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

4 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 • • 4d ago

A C compiler in C whose IR is printed text, which the x86-64 backend parses back

0 Upvotes

I have been building a C compiler in C, about 14,000 lines with no dependencies. Two decisions in it are worth other people's opinions, and both are the kind you only get to make once.

The repo: https://github.com/IzonIcy/LumiComp

The IR is printed text.

codegen prints a textual IR to stdout. The assembly backend then parses that same text back to build its own representation.

Why: the IR stays diffable, golden tests are just text files, and codegen output can be read without a debugger. Every stage of the pipeline is a subcommand, and this is the decision that made that possible. You can run codegen and look at the result.

What it costs: the backend re-derives types from text instead of being handed a typed structure. It guesses from the operation and the operands, and three of those guesses were wrong before I found them. The IR carries less information than it should, and that is a real defect I have chosen to live with.

The backend does no register allocation.

Every value lives in a stack slot. Load, operate, store, for everything.

Why: the output is correct before it is fast, and the backend stays small enough to read. It is about 3,400 lines.

What it costs: the generated code is slow, and the backend cannot use the register count as a signal about anything. I think this is the right trade for a compiler meant to be read, but I would like to be argued out of it.

What it covers

Integers, doubles, pointers, control flow, function calls. The assembly backend rejects structs, local arrays, single-precision floats, sizeof, and more than six integer arguments, each with a located diagnostic. The front end is wider than the backend.

What I am asking

  1. If you have built a compiler with a text IR, did you keep it or move to an in-memory structure, and what made you move?
  2. Is there a version of "no register allocation" that stays readable but produces code someone would actually ship? A linear scan is maybe 200 lines, and I keep deciding not to.
  3. The preprocessor rewrites the program as text rather than as tokens, so source locations are approximate inside macros. Is that fixable without rewriting the stage?

Build log, one post per stage, each about one trade and one bug: https://github.com/IzonIcy/LumiComp/tree/main/docs/build-log


r/Compilers • • 5d ago

Pyrefly 1.5: 100% Conformance and 40% Faster

15 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 • • 4d ago

I built Oster with AI – a memory-safe language with NLL borrow checking that compiles to portable C11

0 Upvotes

Hey everyone,

I’ve been working with AI on Oster, an experimental programming language and compiler written in Rust that compiles down to portable C11.

Why Oster?

The main goal is to combine modern static safety guarantees (ownership, non-lexical lifetimes / borrow checking, escape analysis, exhaustive pattern matching) with the ubiquity and zero-runtime portability of standard C11 — making it easy to target anything with a C compiler and integrate seamlessly with existing C codebases.

My repo:

https://github.com/kapimati/Oster

What it looks like

Here is a small snippet in Oster:

extern fn puts(s: str) -> i32;

enum Result { Err(str), Ok(i32) }

fn checked_div(a: i32, b: i32) -> Result {

if b == 0 { return Result::Err("division by zero"); }

return Result::Ok(a / b);

}

fn sum_divs() -> Result {

mut let total = 0;

for d in \[2, 4, 5\] {

total += checked_div(100, d)?;

}

return Result::Ok(total);

}


r/Compilers • • 5d 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.


r/Compilers • • 5d ago

optimistic or pessimistic compiler?

7 Upvotes

for those that compose and craft compilers, do you find the results better and more satisfying for you if the compiler you work on is permissive/optimistic or strict/pessimistic?

permissive/optimistic here means that the starting point is the compiler assumes the line of code that it is parsing/evaluating is probably ok but needs to pass some checks before translating to the target backend? (this is “the compiler is your friend” approach)

strict/pessimistic here means that the starting point is the compiler assumes the line of code that it is parsing/evaluating has something wrong and its job is to discover that wrong thing, and it is disappointed when the line passes all checks before translating to the target backend? (this is “the compiler is the teacher we’ve all had at one point in our life where they assume you’re going to do something bad as soon as they’re not looking” - and they’re not wrong)

obviously there has to be some balance here, but i’m curious, what has been your experience with these two approaches?


r/Compilers • • 6d ago

Is there any other compiler backend other than LLVM, MLIR?

30 Upvotes

I tried searching but maybe what i want doesnt exist. I want simple IR that has vectors(something like C++ vectors), struct fields and functions. Ik that too high level for ir but transpilation to C++ is slow to compile into final binary file. If anyone from you know if this kind of IR exists, i would appreciate to know about it. I use C++ for my compiler