s05 — Driver Integration: oric Two-Hat Dispatch
Goal
oric carries a complete native_backend feature seam: cargo wiring, the shared compiled-backend dispatch, direct target selection including WASM, and native artifact handling — LLVM behavior byte-identical when the feature is off or unselected.
Implementation Sketch
Implements plans/backend-boundary; it does not mirror LLVM orchestration:
- Workspace: register
ori_backend, the backend-neutralori_targetcrate, and the pureori_codegeninterface crate;oric/Cargo.tomlgains the narrow optionalori_backendedge while shared realization/layout/interface crates remain independent of concrete backends. - Implement
ori_codegen::CodegenBackendforori_backend: immutableExecutableProgram + explicit TargetSpec + matching CompiledLayoutPlanin; backend-private BIR/MIR stays insidecompile;finalizereturns the common typed relocatable-object or complete-WASM artifact, or a typed error. Do not addcompile_to_native_*twins, anative_codegen_pipeline, or native-only artifact handling inoric; realization and compiled-layout planning run once before exhaustive dispatch. CodegenBackendChoice { Llvm, Native }ownsori buildselection.ExecutionBackend { Vm, Compiled(CodegenBackendChoice) }ownsori run/ori test; the user-facing--backend=nativevalue maps to the compiled arm without duplicating orchestration.ORI_BACKENDfollows the same typed precedence path.TargetSpecis parsed/canonicalized outside concrete backends. A WASM target withCodegenBackendChoice::Nativeproduces a complete WebAssembly module; an explicit runner/host adapter executes it when requested. No evaluator/VM routing exists for WASM.RuntimeConfig::detect()reuse verified for native AOT linking (same libori_rt.a, same five-candidate search); the shared linker consumes the artifact’s typed link manifest without matching on concrete backend identity.ori_compilerfacade purity preserved: zeroori_backenddependency.
Test Strategy
- Matrix: {feature on, feature off} x {—backend native, llvm, vm, unset} x {build, run, test} x {host, wasm target} — dispatch lands in the right typed arm with the right diagnostic every cell;
build --backend=vmis rejected by construction. - Semantic pin: default build with feature ON but flag unset produces byte-identical LLVM behavior (two-hat invariant); negative pin: —backend=native without feature -> the new E-code, never a panic.
- Evaluator/VM/LLVM parity remains green; native/WASM cells join the differential gate as they become runnable.
Work Items
- ori_backend crate registered (workspace members + oric native_backend feature + explicit version); cargo build matrix green both feature states.
-
ori_backendimplementation ofori_codegen::CodegenBackendover the one shared realization, explicit target, and compiled-layout path; private BIR/MIR plus typed native-object/complete-WASM finalization; architecture pins forbid native orchestration or post-codegen artifact forks. - Typed codegen/execution dispatch, target selection,
--backend+ORI_BACKENDprecedence, direct compiled WASM routing, and backend-unavailable E-code with spec-style diagnostic. - Dispatch test matrix (feature x flag x command) + two-hat semantic pin + negative pin; ori_compiler purity assertion (no ori_backend in its dep tree).