bug(forge): the 1.10.0 compiler split slows down compilers that run in parallel themselves
Component
Forge
Have you ensured that all of these are up to date?
- [ ] Foundry
- [ ] Foundryup
What version of Foundry are you on?
083e22994195d6a7e3ad3104d0b57f478c9b9062
What version of Foundryup are you on?
foundryup 2.0.0 (ca05497 2026-10-24T16:32:57.888128000Z)
What command(s) is the bug in?
forge build
Operating System
macOS (Apple Silicon)
Describe the bug
Since 1.10.0 (foundry-rs/foundry-core#310), forge compiles a large input (32 or more files) as several compiler processes at once, up to one per core. Each process gets every source and a share of the output selection, and forge merges their outputs. For solc, which runs on a single thread, this spends more total CPU to finish much sooner.
Compilers that already run in parallel lose from it. forge splits any binary given with --use or solc = "<path>"; only Solar is exempt, by its version metadata. solx (slang) spreads its own work over every core. Under the split it runs once per core, and each run parses and analyzes the whole project again and starts its own workers. The machine runs many times more processes than it has cores, so builds get much slower and use far more memory.
Setting the compiler in foundry.toml instead of --use gives the same result. -j 1 does not reach the split: it sizes forge's thread pool, while the number of parts comes from Project::solc_jobs, which forge leaves at available_parallelism().
Could the split apply only to the solc releases forge installs itself, or could there be an option to turn it off, such as a config key and flag that sets solc_jobs, with 1 disabling the split?
Good report — I traced the mechanism through current foundry-core and the diagnosis checks out, with one detail worth noting for the fix.
The split count never comes from -j: forge builds the project with ProjectBuilder::<MultiCompiler>::default() (crates/common/src/compile.rs) and never calls .solc_jobs(...) anywhere in the foundry repo, so ProjectBuilder::build falls back to std::thread::available_parallelism() (crates/compilers/crates/compilers/src/lib.rs:1459-1463). That value flows into CompilerSources.jobs (compile/project.rs:803) and then into compile_with_jobs per input.
The actual split gate is in SolcCompiler::compile_with_jobs (compilers/solc/mod.rs:161): jobs > 1 && input.compiler_name() == "Solc". And compiler_name() (solc/mod.rs:684-690) is just a version-metadata check — "Solar" iff the build string contains "solar", "Solc" otherwise. So the Solar exemption is a name check, not a capability check: solx reports "Solc" and gets split, and any future parallel solc-compatible compiler will hit the same bug unless it is special-cased too.
Two notes for the fix:
- The config-key/flag option you suggest is cheap on the compilers side:
ProjectBuilder::single_solc_jobs()already exists (lib.rs:1237), so it is just plumbing asolc_jobskey through to the builder incrates/common/src/compile.rs. - If the maintainers prefer to fix it in the split itself rather than add config, the gate probably wants to be about the compiler rather than its name — e.g. split only for binaries forge installed as genuine solc releases. Otherwise the exemption list grows one compiler at a time.