Silex v0.47.1 / Docs Canonical source ↗

Run, interpret, or compile a program

Use silex run during ordinary development. The command compiles the source for the host machine, launches the resulting executable, and forwards its exit code to the terminal.

silex run Project

The directory must directly contain one .sx file that declares a top-level main function. The filename is free: Main.sx is only a convention. From inside the application directory, omit the path:

cd Project
silex run

You can still select any .sx file explicitly:

silex run Project/Main.sx

This explicit form remains available when several files in the same directory declare main. Directory discovery does not search subdirectories and fails rather than choosing arbitrarily between multiple entries.

Choose between the three commands

Intent Command
Compile, then run on the current machine silex run [Source.sx|Directory]
Execute with the reference interpreter silex interpret Source.sx
Produce an executable at a chosen location silex compile Source.sx -o Application

silex interpret executes portable IR without producing a native executable. It is useful for comparing reference behavior with the backend, but cannot call most system boundaries provided by packages. In that case, use silex run.

silex compile only writes the requested program. It does not launch it:

silex compile Project/Main.sx --output Application
./Application

On Windows, normally choose a name ending in .exe:

silex compile Project/Main.sx --output Application.exe
.\Application.exe

Choose the compilation backend

run, compile, and test use the native backend by default on every supported host. This choice does not require LLVM.

Prepare the verified supporting tools once after installing or updating Silex:

silex setup

You can make the native choice explicit:

silex run Project/Main.sx --backend native
silex compile Project/Main.sx --backend native -o Application

Use --backend llvm to request LLVM explicitly. LLVM 21.1.8 is currently qualified only on the macos-arm64 host running macOS 14 or later. On the other distributed hosts, an LLVM request fails without silently falling back.

Both backends receive the same Silex program and portable IR. The choice affects executable production, not language syntax or semantics. silex interpret remains a separate reference path and does not accept --backend.

Compile in Release or Debug mode

run uses Debug mode by default; compile uses Release. Release mode applies compiler optimizations without changing the language's safety rules.

Explicitly select Release to run an optimized program, or Debug to diagnose code produced by compile:

silex run Project/Main.sx --release
silex compile Project/Main.sx --debug -o Application

The short forms are -d for Debug and -r for Release. Both modes cannot be requested in the same command.

When a compiled program is interrupted by a signal, Silex preserves the faulty executable and prints a Debug reproduction command along with the command for the debugger available on the host.

Choose a compilation target

Without --target, silex compile selects the current machine. Display the targets recognized by the installed version with:

silex targets

Silex 0.44 recognizes macos-arm64, macos-x64, linux-arm64, linux-x64, windows-arm64, and windows-x64. Pass the desired name for cross-compilation:

silex compile Project/Main.sx \
    --target linux-x64 \
    --output Application-linux-x64

All six names have a native distribution, but that does not guarantee that each host can produce the other five formats. See the Silex 0.44 limits before distributing an executable built for another system.

Inspect IR or ignore the cache

run and interpret accept --emit-ir to print textual IR before program output. test also has this option. This representation is intended for compiler diagnostics; its format is not a stable API.

Compilation commands normally use the cache stored under .silex. Add --nocache, or its short form -n, only to force a compilation independent of the cache:

silex run Project/Main.sx --nocache

The first program explains where this folder is created and how to avoid scattering it.

Back to the tools · Write and run tests · Read the CLI reference