Skip to content

feat: add MLIR passthrough mode#239

Draft
hedgar2017 wants to merge 2 commits intomainfrom
feat/mlir-passthrough
Draft

feat: add MLIR passthrough mode#239
hedgar2017 wants to merge 2 commits intomainfrom
feat/mlir-passthrough

Conversation

@hedgar2017
Copy link
Contributor

Summary

  • When both solc and mlir features are active, solc's internal MLIR pipeline produces final EVM bytecode — solx becomes a thin wrapper
  • Decouples mlir feature into a marker (mlir = []) to avoid inkwell feature poisoning; actual MLIR codegen gated behind solx-mlir
  • Adds Build::from_solc_output() to extract bytecode/abi/metadata from solc standard JSON output
  • Splits standard_output_evm() and standard_json_evm() with cfg guards for passthrough vs normal paths
  • Guards CLI flags that would panic in passthrough mode
  • Wires CLI -O flag to solc's optimizer.mode via middle_end_as_char()
  • Strips optimizer.size_fallback (solc doesn't recognize it); keeps optimizer.mode (solc-mlir uses it)
  • Adds missing MLIR link libraries, fixes cmake path resolution, adds build-mlir/test-mlir cargo aliases
  • Updates solx-solidity and solx-llvm submodules for MLIR support

Test plan

  • cargo build-mlir compiles
  • cargo clippy --no-default-features --features solc,mlir clean
  • cargo fmt clean
  • Standard JSON produces bytecode (Counter contract)
  • CLI --bin produces bytecode (tests/solidity/simple/default.sol)
  • --version shows "Backend: MLIR (passthrough)"
  • CLI -O1/-O2/-O3/-Os/-Oz all produce bytecode; -O1 produces different (larger) output confirming mode reaches solc-mlir
  • Unsupported flags (--asm, --debug-info, --emit-llvm-ir, --evmla, --ethir) bail with clear error messages
  • CI validation (pending — default cargo build/cargo test requires non-MLIR solc)

When both `solc` and `mlir` features are active, solc's internal MLIR
pipeline produces final EVM bytecode. solx becomes a thin wrapper that
calls solc via FFI and extracts the result directly, bypassing the
normal LLVM codegen path.

Key changes:
- Decouple `mlir` feature into a marker (`mlir = []`) to avoid inkwell
  feature poisoning; actual MLIR codegen gated behind `solx-mlir`
- Add `Build::from_solc_output()` to extract bytecode/abi/metadata from
  solc standard JSON output
- Split `standard_output_evm()` and `standard_json_evm()` with cfg
  guards for passthrough vs normal compilation paths
- Guard CLI flags that would panic in passthrough mode (--asm,
  --debug-info, --emit-llvm-ir, --evmla, --ethir)
- Wire CLI -O flag to solc's optimizer.mode in passthrough CLI mode
- Strip optimizer.size_fallback before passing to solc (unrecognized);
  keep optimizer.mode (solc-mlir uses it for opt level)
- Skip retain_solc() and set_selector(via_ir) in passthrough so user
  output selection passes through to solc unchanged
- Add missing MLIR link libraries to build.rs
- Fix relative path resolution for MLIR cmake args in solx-dev
- Add cargo aliases: build-mlir, test-mlir
- Update solx-solidity and solx-llvm submodules for MLIR support
@hedgar2017 hedgar2017 force-pushed the feat/mlir-passthrough branch from 342f06a to bc609f3 Compare February 24, 2026 12:29
Wire `mlir` feature to enable `dep:solx-mlir` directly, replacing the
separate `solx-mlir` implicit feature. Simplify redundant
`cfg(all(solc, mlir))` to `cfg(mlir)` in solc-only modules. Replace
`Object::new` with purpose-built `new_passthrough` and `from_build`
constructors. Fix optimizer settings mutation leak in solc frontend.
Scope `build-mlir` alias to `-p solx` to prevent inkwell feature
poisoning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant