Compiler Usage

SLangCC accepts one .sl source file, runs the complete compiler pipeline, and writes a native executable.

slangcc <source.sl> [-o output] [dump-options]

When working from the source tree, invoke ./slangcc.

Compile and run

./slangcc examples/hello.sl
./examples/hello

When -o is omitted, the output is placed beside the source and uses its filename without .sl. Use -o to select another path:

./slangcc examples/hello.sl -o build/hello

-o may occur before or after the input filename. Its parent directory must already exist.

Compilation pipeline

For a successful input, the driver:

  1. parses the source into an AST;
  2. runs semantic and type checks;
  3. lowers the checked AST to SLangIR;
  4. emits x86-64 assembly;
  5. invokes GCC, or Clang when GCC is unavailable;
  6. links the generated code with codegen/runtime.c.

Compilation stops at the first stage that records errors. A failed compilation returns a nonzero status and does not produce the requested executable.

Toolchain and target

The generated assembly currently targets x86-64 Linux using the System V ABI. The compiler searches PATH for gcc first and then clang. Compilation fails if neither is executable.

The driver locates codegen/runtime.c relative to the slangcc executable, then falls back to codegen/runtime.c under the current working directory.

Successful output

Compiled "hello.sl" to "hello".

With dump flags enabled, the driver also reports each written intermediate file.