Core Engine Compilation

Rust WASM Engine Compilation

The core query transpilation engine is built in Rust (orcha-rust-engine) and compiled to WebAssembly (WASM). This binary parses queries, resolves calculated virtual columns, and converts them to native database dialects.

Overview

If you modify the Rust files under orcha-rust-engine/src/, or perform a clean build on a fresh environment, you must compile the WASM binary using wasm-pack and place the build output into lib/wasm-engine/.

Prerequisites

1. Install Rust and Cargo via rustup:

bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

2. Install wasm-pack:

bash
cargo install wasm-pack

Compiling with wasm-pack

Navigate to the Rust engine crate directory and trigger the Node.js target build:

bash
cd orcha-rust-engine
wasm-pack build --target nodejs

This generates WebAssembly binaries, JS loader shims, and TypeScript definitions inside orcha-rust-engine/pkg/.

Deploying the Binary to Next.js

Copy the compiled WASM package into lib/wasm-engine/:

bash
mkdir -p lib/wasm-engine
cp orcha-rust-engine/pkg/orcha_semantic_engine_bg.wasm lib/wasm-engine/
cp orcha-rust-engine/pkg/orcha_semantic_engine.js lib/wasm-engine/
cp orcha-rust-engine/pkg/orcha_semantic_engine.d.ts lib/wasm-engine/

Troubleshooting Windows GNU Linker Errors

Option A: Switch to MSVC Toolchain (Recommended)

If MinGW throws unable to find library -lgcc_eh, switch to the official Microsoft Visual C++ build tools:

powershell
rustup default stable-x86_64-pc-windows-msvc
cd orcha-rust-engine
cargo clean
wasm-pack build --target nodejs