v2.pref
fn comptime_flag_value #
fn comptime_flag_value(pref &Preferences, name string) bool
comptime_flag_value evaluates a plain comptime flag identifier, as it would appear in $if name { or @[if name]. Use comptime_optional_flag_value for the optional name ? form. Shared between the parser (struct field conditionals) and the transformer (statement / expression $if).
pref may be nil for early uses (some tests construct partial state); flags that depend on backend / user_defines then evaluate to false.
fn comptime_optional_define_value #
fn comptime_optional_define_value(name string, user_defines []string, explicit_user_defines []string) bool
fn comptime_optional_flag_value #
fn comptime_optional_flag_value(pref &Preferences, name string) bool
comptime_optional_flag_value evaluates the name ? form. Unlike a plain $if name, target OS and target-mode flags must not become true implicitly. Non-target compiler capability flags keep their normal value, because V's builtin/runtime code uses the optional form for guarded internal fallbacks.
fn comptime_pkgconfig_value #
fn comptime_pkgconfig_value(name string) bool
comptime_pkgconfig_value evaluates $pkgconfig('name') in compile-time conditions. Missing pkg-config packages are false, matching v1 behavior.
fn define_list_contains #
fn define_list_contains(defines []string, name string) bool
fn file_has_incompatible_os_suffix #
fn file_has_incompatible_os_suffix(file string, current_os string) bool
file_has_incompatible_os_suffix reports whether file is specialized for a different OS.
fn new_preferences #
fn new_preferences() Preferences
fn new_preferences_from_args #
fn new_preferences_from_args(args []string) Preferences
new_preferences_from_args parses full args list including option values
fn new_preferences_using_options #
fn new_preferences_using_options(options []string) Preferences
fn normalize_target_os_name #
fn normalize_target_os_name(target_os string) string
fn pkgconfig_result #
fn pkgconfig_result(args []string) ?string
pkgconfig_result runs pkg-config with args and returns stdout on success.
fn source_files_from_args #
fn source_files_from_args(args []string) []string
fn Arch.from #
fn Arch.from[W](input W) !Arch
fn Backend.from #
fn Backend.from[W](input W) !Backend
fn GarbageCollectionMode.from #
fn GarbageCollectionMode.from[W](input W) !GarbageCollectionMode
enum Arch #
enum Arch {
auto // Auto-detect based on OS
x64
arm64
}
enum Backend #
enum Backend {
v // V source output (default)
eval // AST interpreter
cleanc // Clean C backend (AST -> C)
c // SSA -> C backend
x64 // Native x64/AMD64 backend
arm64 // Native ARM64 backend
}
enum GarbageCollectionMode #
enum GarbageCollectionMode {
no_gc // no garbage collection
vgc // V GC: concurrent tri-color mark-and-sweep (translated from Go's runtime GC)
boehm // Boehm-Demers-Weiser conservative GC (legacy)
}
GarbageCollectionMode controls which garbage collector is used. Translated from Go's runtime GC, the vgc mode provides a concurrent tri-color mark-and-sweep collector written in pure V.
struct Preferences #
struct Preferences {
pub mut:
debug bool
verbose bool
ownership bool // -ownership: enable ownership checking for strings
skip_genv bool
skip_builtin bool
skip_imports bool
skip_type_check bool // Skip type checking phase (for backends that don't need it yet)
no_parallel bool // when true, run type check sequentially (default: parallel)
no_parallel_transform bool // when true, run transform sequentially (default: parallel)
no_cache bool // Disable build cache
no_markused bool // Disable markused stage and dead-function pruning
show_cc bool // Print C compiler command(s)
stats bool // Print extended statistics
print_parsed_files bool // Print all parsed files grouped by full/.vh parse mode
keep_c bool // Keep generated C file after compilation
use_context_allocator bool // Use context allocator for heap allocations (enables profiling)
is_shared_lib bool // Compile to shared library (.dylib/.so) for live reload
no_optimize bool = true // skip SSA optimization (mem2reg, phi elimination); cleared by -prod
is_prod bool // -prod: enable SSA optimization + -O3 -flto for C compiler
prealloc bool // -prealloc: use arena allocation (bump-pointer, not thread-safe)
gc_mode GarbageCollectionMode // Garbage collection mode (-gc flag)
backend Backend
arch Arch = .auto
target_os string = os.user_os()
output_cross_c bool // -os cross: keep generated C portable
freestanding bool // -freestanding: target a platform contract without an OS runtime
freestanding_hooks []string // -fhooks: explicit freestanding platform capabilities
macos_tiny bool = true // -no-mos-tiny: disable the automatic macOS x64 tiny object path
output_file string
printfn_list []string // List of function names whose generated C source should be printed
user_defines []string // All active comptime flags, including compiler-synthesized flags.
explicit_user_defines []string // User-defined comptime flags from explicit -d <name> only.
hot_fn string // Extract raw machine code for this function only (hot reload)
single_backend bool // Only include the selected backend (strip other backends from binary)
eval_runtime_args []string // Program argv exposed to the eval backend
ccompiler string // C compiler override (-cc flag)
pub:
vroot string = detect_vroot()
vmodules_path string = os.vmodules_dir()
}
fn (Preferences) can_compile_cleanc_locally #
fn (p &Preferences) can_compile_cleanc_locally() bool
fn (Preferences) can_run_target_binary_locally #
fn (p &Preferences) can_run_target_binary_locally() bool
fn (Preferences) freestanding_hook_list #
fn (p &Preferences) freestanding_hook_list() []string
fn (Preferences) get_effective_arch #
fn (p &Preferences) get_effective_arch() Arch
get_effective_arch returns the architecture to use based on preferences and OS
fn (Preferences) get_module_path #
fn (p &Preferences) get_module_path(mod string, importing_file_path string) string
check for relative and then vlib
fn (Preferences) get_vlib_module_path #
fn (p &Preferences) get_vlib_module_path(mod string) string
fn (Preferences) has_freestanding_hook #
fn (p &Preferences) has_freestanding_hook(name string) bool
fn (Preferences) has_freestanding_hooks #
fn (p &Preferences) has_freestanding_hooks() bool
fn (Preferences) is_cross_target #
fn (p &Preferences) is_cross_target() bool
fn (Preferences) is_freestanding #
fn (p &Preferences) is_freestanding() bool
fn (Preferences) normalized_target_os #
fn (p &Preferences) normalized_target_os() string
fn (Preferences) source_filter_target_os #
fn (p &Preferences) source_filter_target_os() string
fn (Preferences) target_os_or_host #
fn (p &Preferences) target_os_or_host() string
- fn comptime_flag_value
- fn comptime_optional_define_value
- fn comptime_optional_flag_value
- fn comptime_pkgconfig_value
- fn define_list_contains
- fn file_has_incompatible_os_suffix
- fn new_preferences
- fn new_preferences_from_args
- fn new_preferences_using_options
- fn normalize_target_os_name
- fn pkgconfig_result
- fn source_files_from_args
- fn Arch.from
- fn Backend.from
- fn GarbageCollectionMode.from
- enum Arch
- enum Backend
- enum GarbageCollectionMode
- struct Preferences
- fn can_compile_cleanc_locally
- fn can_run_target_binary_locally
- fn freestanding_hook_list
- fn get_effective_arch
- fn get_module_path
- fn get_vlib_module_path
- fn has_freestanding_hook
- fn has_freestanding_hooks
- fn is_cross_target
- fn is_freestanding
- fn normalized_target_os
- fn source_filter_target_os
- fn target_os_or_host