Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix C: Command-line reference

All 110 options of the pinned compiler, from the table that also drives tiko --help.

Environment variables

VariableWhat it does
TIKO_CLANGFull path to clang. Without it tiko looks at C:\Program Files\LLVM\bin\clang.exe on Windows, /usr/bin/clang on Linux or Homebrew's /opt/homebrew/opt/llvm/bin/clang on macOS, and searches PATH only when that file is absent. llvm-ar and llvm-rc are taken from the same directory.
TIKO_INCLUDEReplaces the default include directory (<exe>/inc). -i paths are searched first either way.
TIKO_LIBPATHReplaces the bundled library directory (<exe>/lib/<target>). -p paths and #libpath are searched first either way.

Exit codes

CodeMeaning
0success
1errors in the program
2command-line error
3no usable toolchain (clang not found)
4internal compiler error
5clang or the linker failed

How arguments are parsed

  • An option matches exactly (-g), as --option=value, or with the value attached (-O2, -Wno-TKO0201).
  • An optional value must be attached with =: --dump-tokens=pp.
  • -- ends option parsing; everything after it is an input file.
  • Inputs are classified by extension: .o is an object, .rc is a resource script, anything else is source.
  • A #cmdline "..." line in the first source file restarts the compile with those options, and the source wins over the command line.

Subcommands

A subcommand is the first word on the command line. It builds a project from its tiko.toml, as Chapter 31 shows; every other command line is the compiler driver described by the rest of this appendix.

CommandWhat it does
tiko buildbuild the targets of tiko.toml, or the roots given -- cached
tiko cleanremove what 'tiko build' would write
tiko metadataprint the project as JSON: targets, profiles, modules
tiko runbuild one exe target, then run it with the arguments after --
tiko checkevery diagnostic a build would give, through lowering; nothing written
tiko testbuild the project's tests into one program and run them
tiko docwrite the API documentation of the project's modules into out/doc
tiko c2ttranslate a C header into a tiko header: tiko c2t <in.h> [-o <out.ti>|-]

General

OptionWhat it does
--help[=‹category›]show help; optionally for one category
--versionshow version and exit
-vecho every tool invocation
-restartaccepted and ignored; a '#cmdline' restarts by itself
--print-graphprint the modules the inputs import, in build order, and stop
--emit-tkiprint the interface of the module directory given, and stop
--emit-doc ‹dir›write the documentation of the module directory given into , and stop ('tiko doc')
--testcompile 'test' blocks and '*_test.tiko' files and register them with std/testing ('tiko test')
--frontend-onlyreport every diagnostic a build would, through lowering; write no object, link nothing ('tiko check')
--no-module-cachebuild imported modules without reading or writing the module cache
--clean-module-cacheempty the module cache and stop
-z ‹option›fbc extended option: 'nocmdline' ignores every #cmdline; any other is accepted and ignored
-maxinstdepth ‹n›how deep one generic instantiation may drive another (default 64)

Input

OptionWhat it does
-i ‹dir›add an include search path
--pkg-dir ‹dir›the package tree for #import std/... is found in (else TIKO_PKG, else /pkg)
--package-root ‹dir›the root of the package the inputs belong to when no tiko.toml names one
-d ‹name=val›define a preprocessor symbol
-p ‹dir›add a library search path
-l ‹name›link against a library

Output

OptionWhat it does
-Wl ‹a,b,c›pass options to the linker, split at commas, as fbc's -Wl
-norpathno $ORIGIN run path when a Linux link takes a shared library
-nocopylibsdo not copy vendor libraries or modules' runtime files beside the output
-o ‹file›output path
-x ‹file›the linked output's path, as fbc's -x: over -o, the last one winning; ignored with -c
-ccompile only; do not link
-dllbuild a DLL rather than an executable
-dylibsame as -dll
-libbuild a static library
-appbuild an Android app (.apk) of an SDL3 program; android targets only
-appid ‹id›the app's application id (default org.tiko.)
-applabel ‹text›the app's label under its icon (default )
-appassets ‹dir›a directory whose files go into the app's assets
-appversion ‹name[,code]›the app's version name and code (default 1.0,1)
-appicon ‹png›the app's launcher icon, a PNG (default Android's)
-apppermission ‹name›an Android permission the app uses, repeatable (INTERNET means android.permission.INTERNET)
-appkey ‹keystore[,alias]›sign with this keystore; passwords from TIKO_ANDROID_KS_PASS / TIKO_ANDROID_KEY_PASS (default the debug key)
-appbundlewrite an Android App Bundle (.aab) for Play rather than an .apk
-eenable runtime error checking
-exas -e: RESUME, which fbc adds here, does not exist in the fb dialect
-exx-ex plus array bounds and null-pointer checking
-gemit debug information
-earraycheck array bounds (one part of -exx)
-enullptrcheck pointer dereferences for null (one part of -exx)
-elocationrecord the procedure and module an error happens in (one part of -exx)
-earraydimscheck that an array is dimensioned, and with the rank used (one part of -exx)
-eassertenable assert and assertwarn (one part of -g)
-edebugdefine FB_DEBUG as -1 (one part of -g)
-edebuginfoemit debug information alone (one part of -g)
-eunwindunwind information (one part of -e; always emitted)
-O‹level›optimisation level 0-3, or s for size
-mtlink the thread-safe runtime
-picposition-independent code, for a Unix shared library (Linux only)
-m ‹name›which module owns main; the others become module constructors
-fsanitize ‹address›instrument the program with AddressSanitizer (debugging builds; needs clang's runtime)

Target

OptionWhat it does
-target ‹name›windows-x86_64 (the Windows default), linux-x86_64, linux-arm64, macos-arm64, android-x86_64 or android-arm64
-m6464-bit target (the only supported width)
-m32rejected: 32-bit is not supported (x86-64 only)
`-s ‹consolegui›`
-t ‹kbytes›stack reserve and commit of a Windows executable or DLL, in KB (default 2048, minimum 64)

Diagnostics

OptionWhat it does
-Werrortreat warnings as errors
-Wno-‹id›suppress one diagnostic id
-w ‹level›fbc's -w: all, pedantic, none, error, or n -- hide fbc's warnings below level n
-fmax-errors ‹n›stop after n errors
--color ‹when›always, never or auto
--diagnostics-format ‹fmt›fbc or gnu
--diagnostics-file ‹path›also write every diagnostic to as tab-separated records
--allow-unloweredwarn (TKO0995) instead of failing when a statement could not be compiled

C header import (#cinclude and -cimport)

OptionWhat it does
-cinclude ‹dir›add a C include directory (clang's -I) for #cinclude
-cimport ‹header›import a C header as a FreeBASIC binding; needs -cimport-out
-cimport-out ‹file›where -cimport writes the binding; - for standard output
-cimport-manifest ‹file›write clang's layout of every imported record
-cdefine ‹name[=value]›define a C macro (clang's -D)
-csysroot ‹dir›the C sysroot (clang's --sysroot)
-copt ‹arg›pass an argument to clang verbatim
-cnomacrosdo not import object-like macros as constants
-cnoverifydo not check tiko's layout of each imported record against clang's
-cnocache#cinclude neither reads nor writes the binding cache
-ccachedir ‹dir›where #cinclude keeps its bindings (default: the user's cache directory)
--print-cincludesimport each #cinclude the inputs reach, print where its binding is as JSON, and stop

Developer and compiler introspection

OptionWhat it does
--dump-sourcelist loaded source files and stop
`--dump-tokens[=‹rawpp›]`
--lex-onlylex every input and report counts; no dump
--pp-onlypreprocess every input and report counts; no dump
--dump-astdump the syntax tree
--dump-typesdump the type table and its layout
--dump-symbolscollect declarations and dump the symbol table
--dump-scanrun the front end for an editor and dump its symbol records
--scan-overlay ‹src=text›with --dump-scan: file 'text' holds the unsaved contents of source 'src'
--scan-module-rootwith --dump-scan: a file starting '#module' is scanned as its whole module
--resolvecollect and resolve; report reference binding
--dump-mangleprint the emitted symbol name of each procedure
--checktype expressions; report the type of each PRINT argument
--dump-decisionstype expressions; list the overload Check chose for each node that implies one
--dump-udtprint each UDT's size, alignment and field offsets
--cimport-probe ‹header›load libclang, parse one C header, print what clang saw
--dump-vtableprint each UDT's virtual method table
--dump-itableprint each interface's flattened members (docs/tiko-interfaces)
--dump-rtlprint the runtime inventory and stop
--parse-exprparse each line as one expression and dump it
--parse-onlyparse every input and report counts; the corpus gate
--dump-irdump MIR
--dump-ir-pre-abidump MIR as the frontend made it, before the ABI pass
--verify-selftestrun the MIR verifier over modules built to fail it
--emit-irwrite LLVM IR and stop
--emit-asmwrite assembly and stop
--keep-tempsretain intermediate files
--statsreport counts and memory use
--time-passesreport wall time per phase
--build-only-unit ‹n›internal to 'tiko build': compile root n alone into the cache, and link nothing
--bootstrap-subset-checkreject constructs outside the self-hosting subset