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

Building

Every program so far was built the same way: one command, one source file, one executable. The tiko command does much more than that. Its options choose checks, optimisation and debug information; it compiles files separately and builds libraries; and for a project with a tiko.toml it builds everything the project declares, remembering what it built before.

A program can see how it was built. With no options at all:

'' Built with no options: tiko defaults.tiko -o defaults
'' Each option defines a symbol the source can test.

print "this build:"
print "runtime error checks: "; cbool( __FB_ERR__ <> 0 )
print "thread-safe runtime:  "; cbool( __FB_MT__ )
print "debug build:          "; cbool( __FB_DEBUG__ )
print "optimisation level:   "; __FB_OPTIMIZE__

Output

this build:
runtime error checks: false
thread-safe runtime:  false
debug build:          false
optimisation level:    0

That is the default build: no runtime checks, no debug information, no optimisation, and the ordinary runtime. Each option below changes one of those, and defines a symbol the program can test.

OptionDoes
-o filenames the output file, exactly as written; without it, the program is named after the first source file (app.exe on Windows, app on Linux)
-ccompiles to an object file and does not link
-libbuilds a static library, libname.a
-eruntime error checks
-exx-e, plus array-bounds and null-pointer checks, and where each error happened
-gdebug information for a debugger; also turns assert on
-O0 … -O3how hard the optimiser works; -O0, none, is the default
-mtthe thread-safe runtime; std/tasks requires it, and a threadcreate call turns it on by itself
-target namewindows-x86_64 or linux-x86_64; the platform you are on is the default
-d NAME=valuedefines a preprocessor symbol
-vshows every tool tiko runs

tiko --help lists every option, by category.

The pages that follow put options in the source, show what a checked build catches, compile files separately and into a library, build projects with profiles, and look at the two targets.

Activities

  1. Build defaults.tiko with -exx -O2 on the command line and compare the output.
  2. Build it with -g and check which lines change.