Skip to content

Target and Safety Modes

Accepted

Accepted for V1 compiler target, build-profile, and safety-mode vocabulary.

V1 separates the semantic compilation context from user-facing build presets.

Target
The selected semantic compilation target. It describes the target facts that affect type checking, layout, comptime execution, lowering, and backend emission.
SafetyMode
The runtime safety-check policy used by lowering and comptime evaluation.
BuildProfile
A driver or build-system preset that chooses defaults such as safety mode, optimization level, and debug information.

Target

The public V1 target model is a small compiler target record, not a full target triple. The compiler may accept or derive from target triples, but comptime code and design docs should depend only on stable semantic facts.

V1 target facts include:

  • pointer width, which also defines usize and isize width;
  • endianness;
  • maximum object alignment accepted by layout finalization;
  • whether the backend supports bit-precise runtime integers for non-standard widths such as u1, i1, u7, or u65;
  • selected C ABI family for @callconv(.c), @export(.c), and @extern(.c);
  • target-selected layout behavior for Catalyst values.

Comptime execution uses target semantics, not host semantics. usize, isize, layout reflection, alignment, ABI checks, and pointer-sized integer behavior are evaluated for the selected target even when the compiler runs on a different host.

The bit-precise integer target fact affects runtime storage and code generation only. The type identities i1..i128 and u1..u128 remain valid source and comptime Type values, but using a non-standard width in runtime storage, parameters, returns, fields, arrays, or generated arithmetic requires backend support. The C backend may satisfy this fact with C23 _BitInt support from the selected C compiler and target.

Safety Mode

V1 has two semantic safety modes:

Checked
Required dynamic safety checks are emitted or interpreted. Checked safety failures trap in a deterministic panic-like way outside the ordinary error-return system.
Unchecked
Dynamic safety checks may be omitted. Programs must not rely on the behavior of signed overflow, out-of-bounds access, or other operations whose required check was omitted.

Safety mode is compilation-wide in V1.

Build Profiles

V1 keeps the familiar build-profile names as presets:

Build profile Default safety mode Notes
Debug Checked Development-oriented profile with deterministic safety checks.
ReleaseSafe Checked Optimized profile with deterministic safety checks.
ReleaseFast Unchecked Performance-oriented profile where dynamic safety checks may be omitted.

Language and compiler semantics should refer to Checked and Unchecked safety mode. Debug, ReleaseSafe, and ReleaseFast are build-profile defaults, not the canonical wording for language rules.

Comptime Context

Target and SafetyMode are stable comptime compiler context values. The V1 compiler context query names are:

Compiler.target() Target
Compiler.safety_mode() SafetyMode

Comptime code may use these values for conditional declarations, validation, and target-specific type construction. Required language safety checks do not depend on library cooperation: lowering still emits explicit IR checks or checked operations when the selected safety mode requires them.

Within one compilation, comptime evaluation results may be reused only when the evaluated semantic instance, comptime arguments, active target, active safety mode, captured scope context, and active semantic environment are the same. V1 does not define cross-run incremental comptime-cache validity. Cycles in comptime evaluation dependencies are deterministic compile errors.

Deferred

Deferred from V1:

  • detailed CPU features;
  • OS versioning and libc flavor;
  • linker behavior;
  • vector ABI and atomics;
  • package platform selection;
  • target-feature strings;
  • per-function, per-block, or region-local safety overrides;
  • explicit wrapping, checked-overflow, and saturating arithmetic APIs or operators.