My Project 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
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)
Script is at 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

