You're looking at the documentation for the "main" branch, click here to view the documentation for the latest stable release.

Using the compiler

Inko's compiler is available through the inko command.

Compiling and running

To compile and then run a file, use the inko run command:

inko run hello.inko

This command is useful when running simple scripts or during the development of your project. If your program defines any command line flags, specify them after the file to run:

inko run hello.inko --foo=bar

Any flags specified before the file to run are treated as flags for the run command.

Compiling without running

The inko run command requires your source code to be available, and compiles it from scratch every time. To avoid this, we can build a standalone executable using the inko build command:

inko build hello.inko

The resulting executable is located at ./build/hello. By default the compiler uses a set of optimizations similar to the optimizations enabled by using clang -O2. You can either disable optimisations entirely, or enable more aggressive optimisations at the cost of compile times increasing:

inko build --opt none hello.inko       # No optimisations
inko build --opt aggressive hello.inko # Aggressive optimisations

For --opt none the executable is placed in ./build/none/hello, and ./build/aggressive/hello for --opt aggressive.

In most cases --opt=aggressive won't make a difference in runtime performance, as the differences in optimizations between balanced and aggressive are minor. This may change in the future.

You can specify an alternative output path using the -o option:

inko build -o /tmp/hello hello.inko

When compiling for the host/native target, build output is placed in ./build directly, but when building for a different architecture the output is scoped to a directory named after that architecture. For example, when compiling for arm64-linux-gnu on an amd64-linux-gnu host, build files are placed in ./build/arm64-linux-gnu.

For more information, run inko --help.