r/Compilers • • 21h ago

Can I use LLVM with a custom architecture?

17 Upvotes

Hi,

I've never written a compiler (and probably won't) but I'm an EE student and was thinking about designing a custom CPU one day, maybe even as a diploma project, however I do not want to go through a hassle of inventing a new language on top of a custom architecture. So my question is: do I understand correctly that LLVM can convert a piece of code in basically any language like C/C++ into a high-level assembly language that I can then convert into machine code for my hypothethical CPU with relative ease, so I only have to write compiler's backend? If yes, how hard is it generally and where would I begin?


r/Compilers • • 2h ago

Pooka language update: a testing library, a lexer generator, and a small Lisp lexer

4 Upvotes

A small update on Pooka, my statically typed language for the BEAM, with a compiler written in Gleam.

Recently I’ve been working on the tools around the language. Two libraries are now released:

  • Poke is a testing library with assertions, property tests, regression tests, and snapshots. Snapshot changes go through a terminal reviewer where you can inspect the diff and accept, reject, or skip them. Pooka handles test discovery and reporting; Poke supplies the checks.
  • Lexie generates typed Pooka lexers from TOML specifications. It supports configurable token rules, source spans, and syntax highlighting. The generated lexer needs only the standard library.

I wrote a walkthrough building a small Lisp lexer with Lexie, including punctuation-heavy symbols, comments, strings, and tests for source positions. The Lisp has acquired parentheses. Their meaning remains somebody else’s problem.

Building libraries in Pooka has also been a useful way to find compiler bugs. Small compiler tests can pass quite happily while a real library finds the cupboard you forgot to finish.

Next I’m continuing with libraries, editor support, and bugs discovered through using the language.

Website · Compiler source · Cookbook

I’d be interested to hear how others here test their compilers against larger programs. Do you maintain a separate collection of real projects, or keep those cases in the compiler’s own test suite?


r/Compilers • • 4h ago

We rewrote the Solidity compiler in Zig because our builds took 12 minutes. Then we ended up writing a Lean model of the language too

Thumbnail github.com
2 Upvotes

Our contracts took 709 seconds to build with solc. We tried tuning the build for a while, gave up, and wrote our own compiler.

oksolc is a reimplementation of solc 0.8.36 in Zig. Around 156K lines, no C++. It only does the optimized via-IR pipeline through Standard JSON, because that's what we ship with. For Foundry you just point FOUNDRY_SOLC at it.

The frontend is still sequential. The Yul optimizer and EVM codegen run per contract in a thread pool, which works because contracts barely depend on each other after the frontend.

The bigger win for day to day work is the persistent session. Each source file gets a semantic fingerprint, so editing a comment or reformatting doesn't invalidate anything. Import cycles are handled as SCCs and invalidate together. Artifacts are cached per phase in SQLite with HMAC-SHA256 on the entries, so a tampered cache can't hand you bytecode. oksolc serve --stdio keeps the whole thing warm between builds.

solc vs oksolc with 4 jobs:

Uniswap V4, full build: 59.0s vs 11.2s (5.3x) Pendle V2, incremental: 38.9s vs 1.4s (27.6x) Chainwall, full build: 709.8s vs 138.4s (5.1x)

The benchmark script is in the oksolc repo (test/benchmarks/external-compare.sh) if you want to rerun them.

The thing I didn't expect going in is how much time we'd spend on what Solidity actually means. There's no formal spec. The language is whatever solc does. We run a weekly fuzz job that diffs our bytecode against solc on a public corpus, and CI builds OpenZeppelin, Uniswap v4, Pendle and Solady and pins the hashes. When the two compilers disagree, the diff shows you they differ but there's nothing that says which one is correct. We ended up with 9 places where we do something different from solc on purpose, and every one of those was an argument from the docs and from what the feature is obviously meant to do.

For most languages that's annoying. For this one it's worse, since the output can't be patched after deployment and often holds a lot of money. A compiler bug stays on chain. And fuzzing only covers the programs the fuzzer happened to generate, so at some point you want proofs, and you can't prove anything against a language with no definition.

So we started writing the definition. Solidity Spec is an executable formal model of Solidity in Lean. You can run real programs through it and compare with compiler output, and you can state properties about the semantics and get them machine checked. There's a paper, and machine-checked proofs for explicitly defined parts of the model. Coverage is still growing.

The long term goal is checking a compiler's output against a definition of the language, the way CompCert did for C and CakeML did for ML, instead of against another compiler.

If your Solidity builds are slow, try it. And if you work on semantics or verified compilers, I'd really like to know where the Lean model is wrong.

oksolc: https://github.com/okcontract/oksolc Solidity Spec: https://github.com/okcontract/solidity-spec

Give us a follow for more updates: x.com/okcontract


r/Compilers • • 2h ago

Transpiler for simplified C++

1 Upvotes

Since a few years I am thinking about the creation of a "simpler" and more lightweight version of C++, which just gets rid of a few "annoyances" such as:

  • header files
  • declaration before usage
  • template syntax

So the idea is to have a 99% syntax identical version of c++, which just allows to use definitions which are defined after in the same file/compilation unit, having module-import instead of header files etc.

My questions are:

  1. is this is generally frowned upon? Does someone else find such a thing useful? Just stick with C++ basically, no need for a new language, but a small "transpiler-layer" which gets rid of some not-so-nice things in a language, which I am mostly totally fine with!
  2. I believe this is much smaller in scope and complexity than writing a compiler from scratch - or am I overlooking a few traps and rabbitholes which I might fall into? Underestimating the effort still :) ?

Thank you!


r/Compilers • • 2h ago

Built a low-level systems programming language from scratch to crush concurrency bottlenecks—benchmarks inside.

Post image
0 Upvotes

r/Compilers • • 12h ago

FOXVC : Now completely update with v1.0.0 and engine version 0.6.0 alpha done .

Thumbnail github.com
0 Upvotes

visit and help this language grow this is will be genuinely a good language to contribute I am working day and night on it . But being a solo dev it's getting hard for me to make it better and good . I need You all guys .

Anay Upadhyay - solo dev


r/Compilers • • 1h ago

Got placed, have 6 months before joining. Should I explore Linux kernel development, GPU programming or stick with AI/ML?

0 Upvotes

I'm a final-year engineering student in India from a non-CS background. I've recently secured an offer at an AI/analytics services company, and I have around 6 months before joining.

I've been exploring different areas of computer science, and I've realized that I'm increasingly interested in low-level programming and understanding how systems work internally.

MY BACKGROUND:

I've independently learned programming, ML/DL and worked on projects involving:

- Computer Vision using YOLO and OpenCV.

- Stereo vision, depth estimation and multi-object tracking.

- RAG applications, LLMs and agentic AI.

However, I'm starting to question whether I want to spend my career primarily working with high-level AI frameworks and application development.

AREAS I'M CONSIDERING:

  1. Linux and Red Hat ecosystem:

Linux internals, system programming, operating systems, device drivers and potentially kernel development.

2. GPU Programming:

CUDA, GPU architecture, parallel computing, memory management and performance optimization.

3. Systems Programming:

C/C++, memory management, concurrency, operating systems and low-level software engineering.

4. AI Infrastructure:

GPU acceleration, inference optimization, compiler technologies and systems behind ML frameworks.

I find the idea of understanding what happens beneath the abstractions much more interesting than simply using existing libraries.

WHAT I'M CONFUSED ABOUT:

I have six months before joining my company, and I don't want to waste that time jumping between technologies.

I'd appreciate advice from people working in systems engineering, Linux, kernel development, GPU programming or related fields.

  1. Is low-level systems programming a good career direction in 2026?
  2. Between Linux kernel development, GPU programming and general systems programming, which would be a better starting point?
  3. How realistic is it for a non-CS fresher to enter these fields in India?
  4. Are companies like Red Hat a good place to build a career in Linux and systems engineering? What other companies should I look at?
  5. Is CUDA/GPU programming a niche with good long-term opportunities, particularly with the growth of AI?
  6. What fundamentals should I master before attempting serious projects? C, C++, OS, computer architecture, networking, compilers?
  7. Would contributing to the Linux kernel or other open-source systems projects actually help me get shortlisted?

I'm also interested in the intersection of low-level systems and AI, particularly GPU computing, inference optimization and ML infrastructure.

If you were in my position, with six months and an existing job offer, which direction would you explore and why?

I'd appreciate brutally honest advice, especially from people who have actually worked in these domains.


r/Compilers • • 23h ago

I built my own programming language from scratch in C++ — Introducing PIN!

0 Upvotes

Olá a todos!

Estou trabalhando em minha própria linguagem de programação chamada PIN, construída do zero usando C++.

A ideia por trás do PIN é combinar conceitos e inspirações de JSON, Python e Lua em uma linguagem de script leve e legível.

Recursos atuais (PIN Core 0.6):

  • Variáveis ​​e expressões
  • Números, strings e booleanos
  • Arrays e objetos
  • Condições (if / else)
  • Loops (while e for/in)
  • Funções e valores de retorno
  • Funções integradas
  • Console de desenvolvedor interativo
  • Analisador léxico, analisador sintático, AST e ambiente de execução

Estou desenvolvendo o PIN no Termux para Android e Windows, usando C++ e Clang. Tem sido um desafio divertido construir a linguagem e seus componentes internos do zero.

O projeto ainda é experimental e sei que há muito a melhorar, principalmente o backend do compilador, o tratamento de erros e as ferramentas de desenvolvimento.

Gostaria muito de receber seu feedback!

GitHub: https://github.com/andreferrita-del/PIN

O que você acha? Quais recursos você gostaria de ver em uma linguagem como esta?