Skip to content

Compiler CLI

jiangc compiles Jiang source files. The current compiler can emit LLVM IR, object files, or link an executable through the host C compiler.

Terminal window
jiangc --version
jiangc --help

--version prints the Jiang compiler version, host target, and LLVM version.

Terminal window
jiangc --check tests/samples/minimal.jiang

This parses, resolves, and type checks the program without emitting LLVM IR, an object file, or an executable.

Terminal window
jiangc --emit-llvm tests/samples/minimal.jiang

By default, LLVM IR is written to standard output. Use -o to write it to a file:

Terminal window
jiangc --emit-llvm tests/samples/minimal.jiang -o minimal.ll
Terminal window
jiangc --emit-obj tests/samples/minimal.jiang -o minimal.o

This stops after object generation and does not link an executable.

Without an explicit --emit-* mode, jiangc creates a temporary object file and asks the host cc to link an executable:

Terminal window
jiangc tests/samples/minimal.jiang -o minimal

Then run:

Terminal window
./minimal
echo $?

jiangc defaults to debug mode:

Terminal window
jiangc --mode debug main.jiang -o main

Release mode enables LLVM optimization and uses package-level object organization when compiling a package directory:

Terminal window
jiangc --mode release . -o app

For single-file input, release mode still compiles that source file directly.

Use --linker to select the program used for final linking:

Terminal window
jiangc --linker /usr/bin/cc main.jiang -o main

Pass extra linker arguments with repeated --link-arg options:

Terminal window
jiangc main.jiang -o main --link-arg -lm

The current minimum runtime boundary still uses the host C runtime for low-level services, mainly:

  • malloc
  • free
  • printf
  • abort

This is expected during the current compiler development stage.