Skip to content

Latest commit

 

History

History
66 lines (58 loc) · 1.87 KB

File metadata and controls

66 lines (58 loc) · 1.87 KB

dasLLVM

LLVM-C Bindings for daScript

This project provides LLVM-C bindings for daScript, generated for LLVM 16.0.6. These bindings allow you to interact with LLVM's compiler infrastructure directly from daScript.

Installation

Automatic Installation (Recommended)

During the CMake configuration process, the build system will:

Note that the filename is fixed and cannot be changed, regardless of your platform. The reason is bindings

Manual installation

Linux (Debian/Ubuntu)

sudo apt-get install -y libclang-16-dev clang-16

Darwin

brew install llvm@16

Windows

Note: The LLVM 16.0.6 release on the LLVM website does not ship developer headers. Consider building it from scratch.

JIT Usage

Take your project, for example:

[jit] // Not necessary, default behaviour
def foo() {
    print("Hello from JIT!")
}

[no_jit]
def bar() {
    print("Hello from interpreter!")
}

[export]
def main() {
    print("Hello from JIT!\n")
}

And run it:

./bin/daslang -jit main.das

This module will create binaries on-the-fly for the foo and main functions, and use them instead of the interpreter at runtime.

Caching System

When using daslang (./bin/daslang) and jit_use_dll_mode=true (default behaviour):

  • First Run: Compiles the code to LLVM IR, optimizes it, generates native code, and saves it as a dynamic (shared) library.
  • Subsequent Runs: Checks if the source code has changed. If unchanged, loads the cached DLL for instant execution.

DLL location

  • By default, the dll is stored in .jitted_scripts/.
  • This can be changed using jit_output_path.