Skip to content

Build subcommand

The build subcommand can be used to compile your Spice project to an executable file and save it to the current directory.

Usage

Use the build subcommand by executing:

Bash
$ spice build [options] <main-source-file>

Use the build command by executing:

Bash
$ spice b [options] <mail-source-file>

Options

You can apply following options to the build subcommand:

Option Short Description
--abort-after-dump - Abort the compilation process after dumping the first requested resource
--backend - Codegen backend.
Valid values: llvm (default), tpde (experimental — see how-to; requires opt-in build with -DSPICE_ENABLE_TPDE=ON).
--build-mode -m Controls the build mode.
Valid values: debug (default), release and test.
--build-var -b Add build variable to parametrize the compiled program (e.g. -v key=value)
--code-model - Code model.
Valid values: default (small), tiny (AArch64 ELF), small, kernel (x86_64), medium (x86_64), large
--coverage - Instrument code for coverage analysis (gcov-compatible .gcno/.gcda output). Implies --debug-info=line-only if no debug info level was requested explicitly, rejects an explicit --debug-info=none, and is incompatible with -lto.
--cpu-features - Comma-separated list of CPU features to enable (+) or disable (-) for the target, e.g. +avx2,-sse4.1
--debug-info -g Generate debug info to debug the executable in GDB, etc.
Valid values: full (default when the flag is given without a value), line-only (DWARF line tables only) and none.
A level can only be attached to the long form (e.g. --debug-info=line-only); -g is an alias for --debug-info=full.
--debug-output -d Print compiler output for debugging.
--disable-verifier - Disable LLVM module and function verification (only recommended for debugging the compiler)
--dump-assembly -s, -asm Dump Assembly code
--dump-ast -ast Dump AST as serialized string and SVG image
--dump-cache-stats - Dump stats for compiler-internal lookup caches
--dump-dependency-graph - Dump compile unit dependency graph
--dump-ir -ir Dump LLVM-IR
--dump-object-file - Dump object files
--dump-stats - Write compile statistics (stage times, peak memory usage, counters) as JSON to the given file.
--dump-symtab - Dump serialized symbol tables
--dump-to-files - Redirect all dumps to files instead of printing them to the screen
--dump-types - Dump all used types
--freestanding - Compile for an environment without hosted libc, crt0 and OS, e.g. a kernel or firmware. Implied by a target without OS, e.g. x86_64-unknown-none. See the freestanding how-to
--jobs <n> -j <n> Set number of jobs to parallelize compilation (default is auto)
--keep-frame-pointers - Set up a frame pointer in every function, so profilers can walk the stack
--linker-script - Pass a linker script to the linker, e.g. to place the code of a freestanding executable at a fixed address
- -lto Enable link-time-optimization
--native-features - Tune the output for the CPU of the compiling machine. The output might not run on other machines
--no-entry - Do not require or generate main function (useful for web assembly target)
--no-red-zone - Do not use the red zone below the stack pointer (x86_64), e.g. for kernel code
- -O<n> Set optimization level.
Valid options: -O0, -O1, -O2 (default), -O3, -Os, -Oz
--output -o Set path for the output file of the --output-container. The file extension is set automatically.
--output-container - Format of the compilation output container.
Valid values: exec (default), obj, lib, dylib)
--quiet -q Do not show the compile progress bar.
--relocation-model - Relocation model.
Valid values: default (pie, pic for shared libraries, static in freestanding mode, except for TPDE, Windows and Darwin), static, pic, pie
--sanitize - Enable instrumentation for sanitizer.
Valid values: none (default), address, thread, memory and type.
--static - Produce stand-alone executable by linking statically. On Linux, the executable is a static PIE, so all linked archives have to contain position-independent code.
--strip-symbols - Strip the symbol table from the executable. Makes it smaller, at the price of stack traces whose frames all print as <unknown>. Combined with --debug-info it removes the debug info too, same as gcc -g -s
--target -t Target triple for the emitted executable (for cross-compiling).
Format: <arch><sub>-<vendor>-<sys>-<abi>
--use-lifetime-markers - Generate lifetime markers to enhance optimizations
--use-tbaa-metadata - Generate metadata for type-based alias analysis to enhance optimizations