Summary
Enable hew to cross-compile programs for any supported target from a single host, similar to GOOS=windows go build. This also simplifies the release pipeline by eliminating the need for native CI runners on every platform.
Background
Building Hew programs for a different native target requires a native toolchain on the target platform because:
libhew.a (the runtime) must be built for the target — requires cargo build --target <triple>
- The linker invocation in
link.rs calls the system cc/clang, which only links for the host
find_hew_lib() has no target-aware path resolution for native architectures
Current state
Phase 1: Multi-target hew-codegen ✅ COMPLETE (PR #261)
- hew-codegen is now embedded in the hew binary via C API (no subprocess)
- LLVM is built with all target backends (
AllTargetsCodeGens)
- Target triple wires through from CLI
--target flag to LLVM via the C API
- WASM target (
--target wasm32-wasip1) is production-ready with dedicated linker path
- Native cross-target code emission works (LLVM generates correct object files)
Phase 2: Pre-built libhew.a per target
- Cross-compile
hew-lib for each supported target using Cargo cross-compilation
- Ship pre-built
libhew.a archives per platform in the distribution (or download on demand)
- Store in
lib/<target>/libhew.a (pattern already exists for WASM: lib/wasm32-wasip1/)
Phase 3: Universal linker via lld
- Replace platform
cc with lld (LLVM linker) which handles all targets from a single binary
link.rs selects the right libhew.a and platform libs based on --target
find_hew_lib() needs target-aware path resolution
- User experience:
hew build --target windows-x86_64 main.hew
Phase 4: Simplified release pipeline
- Build hew once on Linux with all LLVM targets
- Cross-link for every platform without native runners
- Native runners only needed for platform-specific testing, not building
Benefits
- Developers on macOS can build Windows/Linux binaries locally
- CI releases go from 3 hours (LLVM builds) to ~15 minutes
- Enables embedded/IoT targets (ARM, RISC-V) without dedicated hardware
- Aligns with the actor model vision — actors should be deployable anywhere
Prior art
- Go:
GOOS=windows GOARCH=amd64 go build
- Zig:
zig build-exe -target x86_64-windows
- Rust:
cargo build --target x86_64-pc-windows-msvc (with linker toolchain)
Summary
Enable
hewto cross-compile programs for any supported target from a single host, similar toGOOS=windows go build. This also simplifies the release pipeline by eliminating the need for native CI runners on every platform.Background
Building Hew programs for a different native target requires a native toolchain on the target platform because:
libhew.a(the runtime) must be built for the target — requirescargo build --target <triple>link.rscalls the systemcc/clang, which only links for the hostfind_hew_lib()has no target-aware path resolution for native architecturesCurrent state
Phase 1: Multi-target hew-codegen✅ COMPLETE (PR #261)AllTargetsCodeGens)--targetflag to LLVM via the C API--target wasm32-wasip1) is production-ready with dedicated linker pathPhase 2: Pre-built libhew.a per target
hew-libfor each supported target using Cargo cross-compilationlibhew.aarchives per platform in the distribution (or download on demand)lib/<target>/libhew.a(pattern already exists for WASM:lib/wasm32-wasip1/)Phase 3: Universal linker via lld
ccwithlld(LLVM linker) which handles all targets from a single binarylink.rsselects the rightlibhew.aand platform libs based on--targetfind_hew_lib()needs target-aware path resolutionhew build --target windows-x86_64 main.hewPhase 4: Simplified release pipeline
Benefits
Prior art
GOOS=windows GOARCH=amd64 go buildzig build-exe -target x86_64-windowscargo build --target x86_64-pc-windows-msvc(with linker toolchain)