SkillAgentSearch skills...

Tiger

Tiger is a Delphi-hosted compiler infrastructure that lets you generate native x86-64 binaries for Windows and Linux — executables, shared libraries, static libraries, and object files — entirely from code. There is no source language to parse. Instead, you construct programs using a fluent Delphi API: define types, declare functions.

Install / Use

/learn @tinyBigGAMES/Tiger
About this skill

Quality Score

0/100

Category

Operations

Supported Platforms

Universal

README

<div align="center">

Tiger

Discord Follow on Bluesky

A compiler infrastructure for generating cross-platform native binaries.

</div>

What is Tiger?

Tiger is a Delphi-hosted compiler infrastructure that lets you programmatically generate native binaries for Windows (x86-64), Linux (x86-64), and macOS (Apple Silicon ARM64) — executables, shared libraries, static libraries, and object files — entirely from code. There is no source language to parse. Instead, you construct programs using a fluent Delphi API: define types, declare functions, emit statements and expressions, and call Build. Tiger handles SSA-based IR generation, optimization, machine code emission, PE/ELF linking, and resource embedding.

LTiger := TTiger.Create(tpWin64);
try
  LTiger.ImportDll('msvcrt.dll', 'printf', [vtPointer], vtInt32, True);

  LTiger.Func('main', vtVoid, True)
    .Call('printf', [LTiger.Str('Hello, World!'#10)])
    .Call('Tiger_Halt', [LTiger.Int64(0)])
  .EndFunc();

  LTiger.TargetExe('output\hello.exe', ssConsole);
  LTiger.Build(True, nil);
finally
  LTiger.Free();
end;

🎯 Who is Tiger For?

Tiger is designed for Delphi developers who need to generate native machine code at build time or runtime. If you're building any of the following, Tiger gives you a pure-Delphi path to native x86-64 binaries for Windows and Linux without external compilers, linkers, or toolchains:

  • Custom language compilers — Build your own programming language and target real native executables. Tiger handles the backend so you can focus on parsing and semantics.
  • Scripting engines with native compilation — Compile user scripts or DSLs down to machine code instead of interpreting them, getting native performance with no runtime overhead.
  • Game scripting systems — Let modders or designers write game logic in a custom language that compiles to native code through Tiger.
  • Rule engines and formula evaluators — Compile business rules, mathematical formulas, or filter expressions into native functions that execute at full CPU speed.
  • Plugin and extension systems — Generate native DLLs or shared objects programmatically so your application can produce its own loadable plugins.
  • Compiler education — Learn how compilers work in a language you already know. Tiger's source is pure Object Pascal — no C++ template metaprogramming or LLVM API to wrestle with.

Tiger requires only a single uses Tiger; clause. There are no external dependencies, no C/C++ toolchain, and no LLVM installation. Everything from IR construction through PE/ELF linking happens inside your Delphi process.

✨ Key Features

  • 🔧 Programmatic API — Build native binaries entirely from Delphi code, no parser needed
  • Fluent interface — Chainable method calls for clean, readable program construction
  • 🎯 Native binaries — Generates real machine code: x86-64 for Windows/Linux, ARM64 for macOS (Apple Silicon), not bytecode or interpreted output
  • 🌐 Cross-platform — Target Windows (PE/COFF), Linux (ELF), or macOS (Mach-O) from the same Delphi codebase
  • 🔗 External imports — Call Windows APIs, Linux libc, libSystem on macOS, or any shared library function directly
  • 📦 Static linking — Produce and consume .lib/.obj (Windows), .a/.o (Linux/macOS) files
  • 🎛️ Multiple outputs — Build executables, DLLs/shared objects, static libraries, or object files
  • 🧬 Rich type system — Records, unions, arrays, enums, sets, pointers, and function pointer types
  • 🔀 Record inheritance — Extend records with base type fields and correct ABI layout
  • 🔀 Union types — C-compatible unions with anonymous nesting inside records
  • 📊 Fixed and dynamic arrays — Compile-time sized arrays and runtime-managed dynamic arrays
  • 🔢 Set types — Pascal-style sets with membership, union, intersection, and difference operations
  • 🧠 SSA optimizer — Constant folding, copy propagation, common subexpression elimination, dead code elimination
  • ⚠️ Exception handling — try/except/finally with platform-native mechanisms (Windows SEH, Linux signals; macOS Unwind planned)
  • 🔌 Variadic functions — Native Tiger varargs with VaCount and VaArg intrinsics
  • 🔄 Function overloading — Multiple functions with the same name resolved by parameter signature
  • 🏷️ Version info — Embed metadata and icons in Windows executables
  • 📝 Managed strings — Reference-counted string types with concatenation and lifecycle management
  • 💾 Runtime memory — Built-in Tiger_GetMem/Tiger_FreeMem heap management

🚀 Getting Started

Every Tiger program follows the same workflow: create, configure, define, build. Here's a complete example that produces a working console executable:

uses
  Tiger;

procedure BuildMyProgram();
var
  LTiger: TTiger;
begin
  LTiger := TTiger.Create(tpWin64);
  try
    // 1. Configure: set optimization level and status output
    LTiger.SetOptimizationLevel(2);
    LTiger.SetStatusCallback(
      procedure(const AText: string; const AUserData: Pointer)
      begin
        WriteLn(AText);
      end, nil);

    // 2. Import external functions your program needs
    LTiger.ImportDll('msvcrt.dll', 'printf', [vtPointer], vtInt32, True);

    // 3. Define types (optional — only if you need records, arrays, etc.)
    LTiger.DefineRecord('TPoint')
         .Field('X', vtInt32)
         .Field('Y', vtInt32)
       .EndRecord();

    // 4. Write functions using the fluent API
    LTiger.Func('main', vtVoid, True)
       .Local('pt', 'TPoint')
       .AssignField('pt', 'X', LTiger.Int64(10))
       .AssignField('pt', 'Y', LTiger.Int64(20))
       .Call('printf', [LTiger.Str('Point: (%d, %d)'#10),
         LTiger.GetField(LTiger.Get('pt'), 'X'),
         LTiger.GetField(LTiger.Get('pt'), 'Y')])
       .Call('Tiger_Halt', [LTiger.Int64(0)])
    .EndFunc();

    // 5. Set the target and build
    LTiger.TargetExe('output\myprogram.exe', ssConsole);
    if not LTiger.Build(True, nil) then
      WriteLn(LTiger.GetErrorText());

  finally
    LTiger.Free();
  end;
end;

The src\testbed project contains extensive working examples covering every feature documented below. It is the best reference for learning the API.

IDE Documentation: The TTiger class in Tiger.pas includes comprehensive XML documentation on every public method. In the Delphi IDE, hover over any method or press Ctrl+Shift+D to see detailed parameter descriptions, usage notes, and cross-references.

🐧 Cross-Platform Development

Tiger supports both Windows (Win64) and Linux (Linux64) targets from a single Delphi codebase. The API is identical across platforms — only the external library names differ.

Platform Selection

Select the target platform when creating the Tiger instance:

// Target Windows (default)
LTiger := TTiger.Create(tpWin64);

// Target Linux
LTiger := TTiger.Create(tpLinux64);

// Target macOS (Apple Silicon ARM64)
LTiger := TTiger.Create(tpMacOS64);

Building for macOS (Apple Silicon)

Tiger can generate Mach-O executables for macOS on Apple Silicon (ARM64). Use tpMacOS64 when creating the compiler. The runtime uses libSystem.B.dylib for printf, exit, malloc, and free; no extra imports are needed for basic console programs. Build from Delphi (on Windows or Mac); the output is a Mach-O binary with no extension. Copy it to an Apple Silicon Mac and run it in Terminal (e.g. chmod +x hello && ./hello). Static linking against .a archives and dynamic linking via ImportDll (e.g. libSystem.B.dylib) are supported. Exception handling (Unwind) on macOS is planned for a future release.

Platform-Specific Imports

Use GetPlatform to conditionally import from the correct system library:

LTiger := TTiger.Create(tpLinux64);
try
  // Platform-specific setup: Windows uses msvcrt.dll, Linux uses libc.so.6
  if LTiger.GetPlatform = tpWin64 then
    LTiger.ImportDll('msvcrt.dll', 'printf', [vtPointer], vtInt32, True)
  else
    LTiger.ImportDll('libc.so.6', 'printf', [vtPointer], vtInt32, True);

  // The rest of the program is identical across platforms
  LTiger.Func('main', vtVoid, True)
    .Call('printf', [LTiger.Str('Hello from Tiger!'#10)])
    .Call('Tiger_Halt', [LTiger.Int64(0)])
  .EndFunc();

  LTiger.TargetExe(TPath.Combine(COutputPath, 'hello'), ssConsole);
  LTiger.Build(True, nil);
finally
  LTiger.Free();
end;

Setting Up WSL for Linux Development

Tiger leverages Windows Subsystem for Linux (WSL) to provide a seamless cross-platform development experience. You write and compile Tiger programs in Delphi on Windows, and Tiger automatically executes Linux binaries through WSL integration.

One-Time WSL Setup

  1. Install WSL2 with Ubuntu:

    wsl --install -d Ubuntu
    
  2. Complete Ubuntu setup — follow the prompts to create a username and password.

  3. Install required packages:

    sudo apt update
    sudo apt install build-essential
    

That's it. No additional configuration is required.

How It Works

When you call Build(True, ...) with AAutoRun = True on a Linux64 target, Tiger:

  1. Generates an ELF executable to your specified output path (on the Windows filesystem)
  2. Automatically converts the Windows path to a WSL path (e.g., C:\output\myapp/mnt/c/output/myapp)
  3. Runs wsl.exe chmod +x to make the binary executable
  4. Executes the binary via wsl.exe and captures the exit code

From your perspective, building and running a Linux program is identical to building a Windows program — just pass tpLinux64 to TTiger.Create().

Manual Execution

You

View on GitHub
GitHub Stars17
CategoryOperations
Updated18d ago
Forks3

Languages

Pascal

Security Score

80/100

Audited on Mar 18, 2026

No findings