Native AOT Compiler x86-64 Direct Machine Code MIT License

HarbourRust

Harbour 4 Flash Edition — Technical Project Overview

Contrary to a common misconception, it is neither a Harbour-to-Rust transpiler nor a virtual machine. It is a native Ahead-Of-Time (AOT) compiler written in Rust that takes .prg source code and emits pure x86-64 machine code directly, packaging it via its own built-in binary writer.

Windows: PE32+
Linux: ELF
macOS Intel: Mach-O
1

Architecture & Dependency Elimination

Zero C, Zero MinGW & Zero Linker

The compiler (hbc.exe) requires no external assembler or linker (as/ld) and no MinGW import libraries to build console binaries. It emits PE32+ directly with entry point _start at 0x140000000, importing only 8 to 11 core functions from kernel32.dll (ExitProcess, HeapAlloc, HeapFree, WriteFile, VirtualAlloc, etc.)—without CRT, SEH, or relocations.

No HVM, Pcode, or Garbage Collector

It neither executes pcode nor carries the legacy Harbour runtime. Memory management is resolved at compile time via deterministic ownership (eliminating GC pauses) alongside bounded reference counting for persistent paths. By design, .hrb files are not supported.

Self-Contained Compiler

The compiler's own source code (src/hbc.rs) relies exclusively on the Rust standard library (zero external Cargo crates) and is distributed precompiled in the repository as bin/hbc.exe under the MIT license.

2

Performance & Binary Size (Measured Microbenchmarks)

By stripping out the HVM, garbage collector, and monolithic Harbour RTL, executable footprint and execution times drop dramatically across published benchmarks:
Metric HarbourRust (AOT) Harbour (pcode) Harbour (-gc3)
Executable size (b3_call, Linux ELF) 9 KB (9,032 B) 1.43 MB (1,431,608 B) 1.43 MB (1,431,560 B)
Execution time (b3_call) 33 ms 1,591 ms 972 ms
Execution time (b2_str) 520 ms 865 ms 745 ms
⚡
Classes & Objects: Across benchmarks running 2 million method calls, DATA accesses, and instantiation cycles, speedups between 14x and 34x were measured compared to traditional Harbour.
3

Real Compatibility Status & Technical Limits

Active development: Legacy binary releases (v0.1–v0.8) were retired on November 14, replaced by a recent snapshot at bin/hbc.exe accompanied by transparent metrics regarding current capabilities.
Language Coverage Strict Fail-Fast
Out of Harbour's 268 official tests under tests/ (1,041 in the full inventory), 32 compile. On its own Windows 11 x64 regression suite, 1,706 of 1,729 cases passed (23 skipped as Linux-only). Everything unsupported is explicitly rejected at compile time with zero silent failures.
OOP (CREATE CLASS) Linux Only
Implemented with single inheritance, flat virtual method tables, and fixed-offset scalar DATA access. Key limitation: currently works only on Linux (rejected by --target=windows) and does not support array/object members or multiple inheritance.
Threads & Mutexes Linux Only
Implemented directly on top of clone(2) + futex on Linux (also currently rejected on Windows).
Databases (DBF / NTX / CDX) Native Read-Only
Features a tightly scoped native read-only implementation (dBASE III, C/N/L/D fields, no memos, no shared locking, single-tag direct character key indexes). For real write access, memos, or multiple work areas, an optional --harbour-rdd flag on Windows links Harbour 3.2's VM and RDDs behind the same interface (requiring MinGW and placing the resulting binary under GPL with the Harbour exception).
C Extend API Bridge Scoped Subset
Includes a constrained bridge (hb_par* / hb_ret* / hb_eval*) enabling C function calls with scalars, read-only arrays, references, and codeblocks, but lacks support for dates, hashes, or array mutation from C.

Practical Takeaway

This is a compelling piece of compiler engineering: it proves that a strict subset of xBase can be compiled directly to x86-64 machine code with no VM or CRT, yielding executables just a few kilobytes in size.

However, it remains an experimental tool suited for isolated modules, CLI utilities, or proofs of concept—not a drop-in replacement for Harbour 3.2/3.4 in Win32/GUI desktop applications (such as FiveWin or HMG), as it still lacks Windows class support, native DBF writes, file-level STATIC variables, and full ABI compatibility with existing C libraries.