Skip to content
Michael Kutowski edited this page Nov 1, 2021 · 31 revisions

Running the odin executable without any arguments (or faulty input) will print the following help description:

odin is a tool for managing Odin source code
Usage:
	odin command [arguments]
Commands:
	build     compile .odin file, or directory of .odin files, as an executable.
	          one must contain the program's entry point, all must be in the same package.
	run       same as 'build', but also then runs the newly compiled executable.
	check     parse and type check .odin file
	query     parse, type check, and output a .json file containing information about the program
	doc       generate documentation .odin file, or directory of .odin files
	version   print version
	report    print information useful to reporting a bug

For more information of flags, apply the flag to see what is possible
	-help

As of right now, docs is disabled and reserved for generating docs in the future.

In addition, there are several hidden compiler flags. Most flags are of the form -foo:BAR.

  • -out=OUTPUT_FILE_OR_PATH: Explicitly specify the output file name or path. Cannot use backslashes or Windows-style drive names; must be /in/this/form, ./in/this/form, or in/this/form. The destination directory must already exist.
  • -resource: Specify a resource (.rc) file (Windows)
  • -opt:LEVEL: Specify the optimization level. Valid numbers are 0 through 3.
  • -o:minimal: Set the optimization mode for compilation. Valid strings are minimal, size, speed
  • -show-timings: Print detailed timings after the compilation stage.
  • -show-more-timings: like the above, but more detailed and verbose
  • -thread-count:COUNT: Specify number of threads available.
  • -keep-temp-files: Do not delete temporary files after compilation. Namely .ll, .bc and object files.
  • -collection:COLLECTION_NAME=PATH_TO_COLLECTION: Specifies collection directories. Can be specified multiple times. Can be imported with import "COLLECTION_NAME".
  • -define:NAME=VALUE: Defines a compile-time constant, as if by ::, which can be used like a normal constant can, such as with when statements. You can use #config(NAME, default_value) as the condition to check if it was passed, or declared by source code.
  • -build-mode:MODE: Specifies build mode. Can be dll or exe. dll will produce a shared object file in linux.
  • -debug: Compile in debug mode. Windows has better support than Linux at the moment, but neverless, does work somewhat on Linux. Produces a .pdb file on Windows.
  • -target:TARGET: For cross-compilation, where TARGET is of the form platform_arch.
  • -cross-lib-dir:
  • -no-bounds-check: globally disable bounds checks.
  • -disable-assert : globally disable asserts.
  • -vet: Log warnings for unused entities and variable shadowing
  • -lld: Use bin/lld-link.exe to link instead of msvc-link.exe (Requires the Windows SDK for system libs in the LIB env variable.)
  • -no-crt: Do not link to the CRT. (Warning: Static linked libraries that rely on the CRT will become unusable)
  • -subsystem:SUBSYSTEM: Pick the subsystem used for the application. Can be console or windows. (Windows)
  • -extra-linker-flags:FLAGS: Pass flags through to the linker. Surround multiple flags "with quotes".
  • -use-separate-modules: (EXPERIMENTAL) Generates object code in parallel for each of the referenced modules.
Clone this wiki locally