Compiler Flags (v0.2.1)
Core compilation, backend, target, JIT, ABI, std, and debug flags.
Overview
These flags shape the compilation pipeline itself: targets, emitted representations, JIT execution, ABI decisions, standard library resolution, and debug information.
Reference source: thrustc/thrustc_cli/src/help.rs
-build-dir
Set the directory used for generated compiler artifacts.
Accepts value: yes
Value syntax: path/to/build
Details
Use this when you want emitted files, intermediates, and temporary build outputs to live outside the default location.
Examples
thrustc main.thrust -build-dir build/
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-tools-dir
Set the compiler tools directory used to find external helper tools.
Accepts value: yes
Value syntax: path/to/tools
Details
This points the compiler at a tools root that expands what it can discover automatically during the pipeline.
Examples
thrustc main.thrust -tools-dir ./tools
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-target
Set the target architecture.
Accepts value: yes
Value syntax: architecture name
Allowed values: x86_64
Details
Use this when the desired architecture is enough and you do not need to spell a full target triple.
Examples
thrustc main.thrust -target x86_64
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-target-triple
Set the full target triple used for code generation and linking decisions.
Accepts value: yes
Value syntax: target triple
Allowed values: x86_64-pc-linux-gnu, x86_64-pc-windows-msvc
Details
The target triple controls operating system, architecture, vendor, and ABI assumptions in one place.
Prefer this over `-target` when cross-compiling or when the platform details matter.
Examples
thrustc main.thrust -target-triple x86_64-pc-linux-gnu
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-cpu
Select the CPU model used for optimization and code generation tuning.
Accepts value: yes
Value syntax: cpu name
Allowed values: haswell, alderlake, ivybridge, pentium, pantherlake
Details
This helps the backend emit code for a specific processor family rather than a generic architecture.
Examples
thrustc main.thrust -cpu haswell
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-cpu-enable-features
Enable specific CPU features in addition to the CPU baseline.
Accepts value: yes
Value syntax: feature;feature
Allowed values: sse2, cx16, sahf, tbm
Details
Use this when you want to turn on a small set of backend features without replacing the whole feature list.
Examples
thrustc main.thrust -cpu-enable-features sse2;cx16
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-cpu-disable-features
Disable specific CPU features from the active configuration.
Accepts value: yes
Value syntax: feature;feature
Allowed values: sse2, cx16, sahf, tbm
Details
This is useful when the selected CPU baseline is too aggressive for the actual deployment environment.
Examples
thrustc main.thrust -cpu-disable-features tbm
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-cpu-features
Replace the CPU feature set with an explicit signed list.
Accepts value: yes
Value syntax: +feature,-feature
Allowed values: +sse2, +cx16, +sahf, -tbm
Details
This gives direct low-level control over the backend feature string.
Use it when you want an explicit allow and deny list rather than incremental enable or disable flags.
Examples
thrustc main.thrust -cpu-features +sse2,+cx16,-tbm
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-emit
Emit one selected compilation artifact instead of performing only the default end-to-end flow.
Accepts value: yes
Value syntax: artifact kind
Allowed values: llvm-bc, llvm-ir, asm, unopt-llvm-ir, unopt-llvm-bc, unopt-asm, obj, unchecked-pretty-ast, unchecked-ast, pretty-ast, ast, pretty-tokens, tokens
Details
Use emission when you want a file output such as LLVM IR, assembler, object code, tokens, or AST snapshots.
Examples
thrustc main.thrust -emit llvm-ir
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-print
Print one selected compilation representation to standard output.
Accepts value: yes
Value syntax: printable unit
Allowed values: llvm-ir, unopt-llvm-ir, asm, unopt-asm, unchecked-pretty-ast, unchecked-ast, pretty-ast, ast, pretty-tokens, tokens
Details
This is the text-output twin of `-emit`.
Use it for inspection, debugging, or piping compiler output into another tool.
Examples
thrustc main.thrust -print tokens
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-opt
Choose the optimization level.
Accepts value: yes
Value syntax: optimization level
Allowed values: O0, O1, O2, O3, Os, Oz
Details
Higher levels generally trade compilation time for more aggressive optimization.
Use size-oriented levels when output size matters more than raw performance.
Examples
thrustc main.thrust -opt O2
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-stop-at
Stop the pipeline after a selected compiler stage.
Accepts value: yes
Value syntax: pipeline stage
Allowed values: lexing, parsing, scope-analysis, ast-verification, type-checking, general-analysis, attribute-checking, linter, compiler-intrinsic-checking, compiler-callconventions-checking, codegen
Details
This is useful for debugging the compiler pipeline and inspecting partial outputs.
Examples
thrustc main.thrust -stop-at parsing
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-reloc-model
Select how the backend handles relocations and external symbol references.
Accepts value: yes
Value syntax: relocation model
Allowed values: static, pic, dynamic
Details
This affects generated machine code and the way addresses are represented.
Use PIC-related modes when the output must be position independent.
Examples
thrustc main.thrust -reloc-model pic
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-code-model
Choose the backend code model.
Accepts value: yes
Value syntax: code model
Allowed values: small, medium, large, kernel
Details
The code model influences assumptions about code and data placement in the address space.
Examples
thrustc main.thrust -code-model small
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-macos-version
Set the macOS SDK or deployment version used for Apple targets.
Accepts value: yes
Value syntax: version
Allowed values: 15.0.0
Details
Use this when you need the generated output to match a specific macOS deployment baseline.
Examples
thrustc main.thrust -macos-version 15.0.0
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-ios-version
Set the iOS SDK or deployment version used for Apple mobile targets.
Accepts value: yes
Value syntax: version
Allowed values: 17.4.0
Details
This matters when targeting Apple mobile environments and their deployment constraints.
Examples
thrustc main.thrust -ios-version 17.4.0
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-cuda-version
Set the NVIDIA CUDA version used for CUDA-oriented compilation flows.
Accepts value: yes
Value syntax: version
Allowed values: 2.0
Details
This lets the compiler adapt CUDA-related ABI or backend expectations for a particular CUDA release.
Examples
thrustc kernel.thrust -cuda-version 2.0
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-jit
Enable the JIT execution mode.
Accepts value: no
Details
With JIT enabled, the compiler prepares the program for in-process execution instead of only generating files.
Examples
thrustc main.thrust -jit
Notes
- Some other JIT flags only make sense when this flag is already active.
-jit-libc
Set the C runtime used by the JIT execution flow.
Accepts value: yes
Value syntax: path/to/libc.so
Details
Use this when the JIT runtime must link against a specific C runtime library.
Examples
thrustc main.thrust -jit -jit-libc /usr/lib/libc.so
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-jit-link
Add an extra shared library for JIT execution.
Accepts value: yes
Value syntax: path/to/library.so
Details
This lets the JIT loader resolve external symbols from additional libraries.
Examples
thrustc main.thrust -jit -jit-link /usr/lib/libraylib.so
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-jit-entry
Set the entry point symbol used by JIT execution.
Accepts value: yes
Value syntax: symbol name
Details
Use this when the executed function is not the default `main`.
Examples
thrustc main.thrust -jit -jit-entry run
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-jit-args
Pass arguments to the program executed through the JIT runtime.
Accepts value: yes
Value syntax: "--foo;bar"
Details
Arguments are passed through the JIT configuration rather than through the host shell after compilation.
Examples
thrustc main.thrust -jit -jit-args "--name;demo"
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-abi
Select the ABI used for code generation.
Accepts value: yes
Value syntax: ABI name
Allowed values: system-v, nvidia-cuda, webassembly
Details
The ABI affects calling conventions, data passing rules, and interoperability with external code.
In v0.2.1, the public help also lists `webassembly` as an available ABI option.
Examples
thrustc main.thrust -abi system-v
thrustc main.thrust -abi webassembly
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-mode
Select the compiler features mode.
Accepts value: yes
Value syntax: feature mode
Allowed values: stable, unstable
Details
Stable mode limits the language surface to stable features.
Unstable mode enables experimental or incomplete features.
Examples
thrustc main.thrust -mode stable
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-std
Set the standard library root path.
Accepts value: yes
Value syntax: path/to/std
Details
Use this when the compiler should resolve the standard library from a non-default location.
Examples
thrustc main.thrust -std ./std
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-std-version
Set the standard library version to use.
Accepts value: yes
Value syntax: x.x.x
Details
This helps the compiler resolve the expected versioned standard library snapshot.
Examples
thrustc main.thrust -std-version 0.2.0
Notes
- This flag accepts a value separated by a space, `=` or `:`.
-dbg
Enable generation of debug information.
Accepts value: no
Details
This turns on backend debug info emission such as DWARF data where supported.
Examples
thrustc main.thrust -dbg
Notes
No extra notes for this flag.
-dbg-for-inlining
Emit debug information optimized for inlined functions.
Accepts value: no
Details
Use this when debugging optimized builds where inlining would otherwise hide useful location information.
Examples
thrustc main.thrust -dbg -dbg-for-inlining
Notes
No extra notes for this flag.
-dbg-for-profiling
Emit extra debug information for source-level profiling tools.
Accepts value: no
Details
This helps profilers map optimized machine code back to the original source more accurately.
Examples
thrustc main.thrust -dbg-for-profiling
Notes
No extra notes for this flag.
-dbg-dwarf-version
Set the DWARF version used for debug information.
Accepts value: yes
Value syntax: DWARF version
Allowed values: v4, v5
Details
Use this when your debugger or platform requires a specific DWARF generation.
Examples
thrustc main.thrust -dbg-dwarf-version v5
Notes
- This flag accepts a value separated by a space, `=` or `:`.
--disable-abi
Disable ABI detection and ABI-specific code generation behavior.
Accepts value: no
Details
This can be useful for debugging or for niche targets where automatic ABI handling gets in the way.
Examples
thrustc main.thrust --disable-abi
Notes
No extra notes for this flag.
--denormal-floating-point-behavior
Control how denormal floating-point values are handled for general floating-point operations.
Accepts value: yes
Value syntax: mode list
Allowed values: IEEE, preserve-sign-signature, transform-to-positive-zero, dynamic
Details
This affects how the backend treats denormal values and therefore can change numerical edge-case behavior.
Examples
thrustc main.thrust --denormal-floating-point-behavior IEEE
Notes
- This flag accepts a value separated by a space, `=` or `:`.
--denormal-floating-point-32-bits-behavior
Control how denormal 32-bit floating-point values are handled.
Accepts value: yes
Value syntax: mode list
Allowed values: IEEE, preserve-sign-signature, transform-to-positive-zero, dynamic
Details
This is the 32-bit specific counterpart of the general denormal floating-point behavior flag.
Examples
thrustc main.thrust --denormal-floating-point-32-bits-behavior IEEE
Notes
- This flag accepts a value separated by a space, `=` or `:`.
--symbol-linkage-strategy
Choose the strategy used when symbol linkages need to be merged or reconciled.
Accepts value: yes
Value syntax: strategy
Allowed values: any, exact, large, samesize, noduplicates
Details
This matters when the backend has to reason about multiple declarations of the same symbol.
Examples
thrustc main.thrust --symbol-linkage-strategy exact
Notes
- This flag accepts a value separated by a space, `=` or `:`.
--stack-protector
Enable stack protection instrumentation.
Accepts value: no
Details
This inserts stack state protection intended to make some classes of memory corruption harder to exploit.
Examples
thrustc main.thrust --stack-protector
Notes
No extra notes for this flag.
--sanitizer
Enable one selected sanitizer runtime and its instrumentation.
Accepts value: yes
Value syntax: sanitizer
Allowed values: address, hwaddress, memory, thread, memtag
Details
Sanitizers add runtime checks and diagnostics for memory issues, threading bugs, or related classes of problems.
Examples
thrustc main.thrust --sanitizer address
Notes
- This flag accepts a value separated by a space, `=` or `:`.
--no-sanitize
Disable specific sanitizer subfeatures or code emission details.
Accepts value: yes
Value syntax: setting;setting
Allowed values: bounds, coverage
Details
Use this to narrow or tune the effect of an active sanitizer configuration.
Examples
thrustc main.thrust --sanitizer address --no-sanitize bounds
Notes
- This flag accepts a value separated by a space, `=` or `:`.
--opt-passes
Pass a custom LLVM optimization pass list.
Accepts value: yes
Value syntax: -p{passname,passname}
Details
Use this when the default optimization pipeline is not enough and you want to control LLVM pass selection directly.
Examples
thrustc main.thrust --opt-passes -p{instcombine,sroa}
Notes
- This flag accepts a value separated by a space, `=` or `:`.
--modificator-passes
Pass a custom modificator optimization pass list.
Accepts value: yes
Value syntax: pass;pass
Allowed values: loopvectorization, loopunroll, loopinterleaving, loopsimplifyvectorization, mergefunctions, callgraphprofile
Details
This lets you tune the pass set used by the compiler-specific modificator stage.
Examples
thrustc main.thrust --modificator-passes loopvectorization;loopunroll
Notes
- This flag accepts a value separated by a space, `=` or `:`.
--target-triple-darwin-variant
Set the Darwin target variant triple.
Accepts value: yes
Value syntax: variant triple
Allowed values: arm64-apple-ios15.0-macabi
Details
Use this when a Darwin target needs its variant triple spelled out separately from the main target triple.
Examples
thrustc main.thrust --target-triple-darwin-variant arm64-apple-ios15.0-macabi
Notes
- This flag accepts a value separated by a space, `=` or `:`.
--enable-ansi-color
Enable ANSI color formatting in diagnostics output.
Accepts value: no
Details
This is useful when the compiler runs in terminals or logs that preserve ANSI escape sequences.
Examples
thrustc main.thrust --enable-ansi-color
Notes
No extra notes for this flag.