|
|
@ -99,25 +99,35 @@ pub mut:
|
|
|
|
// verbosity VerboseLevel
|
|
|
|
// verbosity VerboseLevel
|
|
|
|
is_verbose bool
|
|
|
|
is_verbose bool
|
|
|
|
// nofmt bool // disable vfmt
|
|
|
|
// nofmt bool // disable vfmt
|
|
|
|
is_test bool // `v test string_test.v`
|
|
|
|
is_glibc bool // if GLIBC will be linked
|
|
|
|
is_script bool // single file mode (`v program.v`), main function can be skipped
|
|
|
|
is_musl bool // if MUSL will be linked
|
|
|
|
is_vsh bool // v script (`file.vsh`) file, the `os` module should be made global
|
|
|
|
is_test bool // `v test string_test.v`
|
|
|
|
is_livemain bool // main program that contains live/hot code
|
|
|
|
is_script bool // single file mode (`v program.v`), main function can be skipped
|
|
|
|
is_liveshared bool // a shared library, that will be used in a -live main program
|
|
|
|
is_vsh bool // v script (`file.vsh`) file, the `os` module should be made global
|
|
|
|
is_shared bool // an ordinary shared library, -shared, no matter if it is live or not
|
|
|
|
is_livemain bool // main program that contains live/hot code
|
|
|
|
is_o bool // building an .o file
|
|
|
|
is_liveshared bool // a shared library, that will be used in a -live main program
|
|
|
|
is_prof bool // benchmark every function
|
|
|
|
is_shared bool // an ordinary shared library, -shared, no matter if it is live or not
|
|
|
|
|
|
|
|
is_o bool // building an .o file
|
|
|
|
|
|
|
|
is_prof bool // benchmark every function
|
|
|
|
|
|
|
|
is_prod bool // use "-O2"
|
|
|
|
|
|
|
|
is_repl bool
|
|
|
|
|
|
|
|
is_run bool
|
|
|
|
|
|
|
|
is_debug bool // turned on by -g or -cg, it tells v to pass -g to the C backend compiler.
|
|
|
|
|
|
|
|
is_vlines bool // turned on by -g (it slows down .tmp.c generation slightly).
|
|
|
|
|
|
|
|
is_stats bool // `v -stats file_test.v` will produce more detailed statistics for the tests that were run
|
|
|
|
|
|
|
|
is_fmt bool
|
|
|
|
|
|
|
|
is_vet bool
|
|
|
|
|
|
|
|
is_vweb bool // skip _ var warning in templates
|
|
|
|
|
|
|
|
is_ios_simulator bool
|
|
|
|
|
|
|
|
is_apk bool // build as Android .apk format
|
|
|
|
|
|
|
|
is_help bool // -h, -help or --help was passed
|
|
|
|
|
|
|
|
is_cstrict bool // turn on more C warnings; slightly slower
|
|
|
|
test_runner string // can be 'simple' (fastest, but much less detailed), 'tap', 'normal'
|
|
|
|
test_runner string // can be 'simple' (fastest, but much less detailed), 'tap', 'normal'
|
|
|
|
profile_file string // the profile results will be stored inside profile_file
|
|
|
|
profile_file string // the profile results will be stored inside profile_file
|
|
|
|
profile_no_inline bool // when true, [inline] functions would not be profiled
|
|
|
|
profile_no_inline bool // when true, [inline] functions would not be profiled
|
|
|
|
profile_fns []string // when set, profiling will be off by default, but inside these functions (and what they call) it will be on.
|
|
|
|
profile_fns []string // when set, profiling will be off by default, but inside these functions (and what they call) it will be on.
|
|
|
|
translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
|
|
|
|
translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
|
|
|
|
is_prod bool // use "-O2"
|
|
|
|
|
|
|
|
obfuscate bool // `v -obf program.v`, renames functions to "f_XXX"
|
|
|
|
obfuscate bool // `v -obf program.v`, renames functions to "f_XXX"
|
|
|
|
is_repl bool
|
|
|
|
|
|
|
|
is_run bool
|
|
|
|
|
|
|
|
is_debug bool // turned on by -g or -cg, it tells v to pass -g to the C backend compiler.
|
|
|
|
|
|
|
|
is_vlines bool // turned on by -g (it slows down .tmp.c generation slightly).
|
|
|
|
|
|
|
|
// Note: passing -cg instead of -g will set is_vlines to false and is_debug to true, thus making v generate cleaner C files,
|
|
|
|
// Note: passing -cg instead of -g will set is_vlines to false and is_debug to true, thus making v generate cleaner C files,
|
|
|
|
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
|
|
|
|
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
|
|
|
|
sanitize bool // use Clang's new "-fsanitize" option
|
|
|
|
sanitize bool // use Clang's new "-fsanitize" option
|
|
|
@ -131,7 +141,6 @@ pub mut:
|
|
|
|
dump_c_flags string // `-dump-c-flags file.txt` - let V store all C flags, passed to the backend C compiler in `file.txt`, one C flag/value per line.
|
|
|
|
dump_c_flags string // `-dump-c-flags file.txt` - let V store all C flags, passed to the backend C compiler in `file.txt`, one C flag/value per line.
|
|
|
|
use_cache bool // when set, use cached modules to speed up subsequent compilations, at the cost of slower initial ones (while the modules are cached)
|
|
|
|
use_cache bool // when set, use cached modules to speed up subsequent compilations, at the cost of slower initial ones (while the modules are cached)
|
|
|
|
retry_compilation bool = true // retry the compilation with another C compiler, if tcc fails.
|
|
|
|
retry_compilation bool = true // retry the compilation with another C compiler, if tcc fails.
|
|
|
|
is_stats bool // `v -stats file_test.v` will produce more detailed statistics for the tests that were run
|
|
|
|
|
|
|
|
// TODO Convert this into a []string
|
|
|
|
// TODO Convert this into a []string
|
|
|
|
cflags string // Additional options which will be passed to the C compiler.
|
|
|
|
cflags string // Additional options which will be passed to the C compiler.
|
|
|
|
// For example, passing -cflags -Os will cause the C compiler to optimize the generated binaries for size.
|
|
|
|
// For example, passing -cflags -Os will cause the C compiler to optimize the generated binaries for size.
|
|
|
@ -146,10 +155,8 @@ pub mut:
|
|
|
|
// Disabling `free()` insertion results in better performance in some applications (e.g. compilers)
|
|
|
|
// Disabling `free()` insertion results in better performance in some applications (e.g. compilers)
|
|
|
|
compress bool // when set, use `upx` to compress the generated executable
|
|
|
|
compress bool // when set, use `upx` to compress the generated executable
|
|
|
|
// generating_vh bool
|
|
|
|
// generating_vh bool
|
|
|
|
no_builtin bool // Skip adding the `builtin` module implicitly. The generated C code may not compile.
|
|
|
|
no_builtin bool // Skip adding the `builtin` module implicitly. The generated C code may not compile.
|
|
|
|
enable_globals bool // allow __global for low level code
|
|
|
|
enable_globals bool // allow __global for low level code
|
|
|
|
is_fmt bool
|
|
|
|
|
|
|
|
is_vet bool
|
|
|
|
|
|
|
|
is_bare bool // set by -freestanding
|
|
|
|
is_bare bool // set by -freestanding
|
|
|
|
bare_builtin_dir string // Set by -bare-builtin-dir xyz/ . The xyz/ module should contain implementations of malloc, memset, etc, that are used by the rest of V's `builtin` module. That option is only useful with -freestanding (i.e. when is_bare is true).
|
|
|
|
bare_builtin_dir string // Set by -bare-builtin-dir xyz/ . The xyz/ module should contain implementations of malloc, memset, etc, that are used by the rest of V's `builtin` module. That option is only useful with -freestanding (i.e. when is_bare is true).
|
|
|
|
no_preludes bool // Prevents V from generating preludes in resulting .c files
|
|
|
|
no_preludes bool // Prevents V from generating preludes in resulting .c files
|
|
|
@ -162,41 +169,41 @@ pub mut:
|
|
|
|
out_name_c string // full os.real_path to the generated .tmp.c file; set by builder.
|
|
|
|
out_name_c string // full os.real_path to the generated .tmp.c file; set by builder.
|
|
|
|
out_name string
|
|
|
|
out_name string
|
|
|
|
path string // Path to file/folder to compile
|
|
|
|
path string // Path to file/folder to compile
|
|
|
|
// -d vfmt and -d another=0 for `$if vfmt { will execute }` and `$if another ? { will NOT get here }`
|
|
|
|
//
|
|
|
|
run_only []string // VTEST_ONLY_FN and -run-only accept comma separated glob patterns.
|
|
|
|
run_only []string // VTEST_ONLY_FN and -run-only accept comma separated glob patterns.
|
|
|
|
// Only test_ functions that match these patterns will be run. -run-only is valid only for _test.v files.
|
|
|
|
// Only test_ functions that match these patterns will be run. -run-only is valid only for _test.v files.
|
|
|
|
compile_defines []string // just ['vfmt']
|
|
|
|
//
|
|
|
|
compile_defines_all []string // contains both: ['vfmt','another']
|
|
|
|
// -d vfmt and -d another=0 for `$if vfmt { will execute }` and `$if another ? { will NOT get here }`
|
|
|
|
run_args []string // `v run x.v 1 2 3` => `1 2 3`
|
|
|
|
compile_defines []string // just ['vfmt']
|
|
|
|
printfn_list []string // a list of generated function names, whose source should be shown, for debugging
|
|
|
|
compile_defines_all []string // contains both: ['vfmt','another']
|
|
|
|
print_v_files bool // when true, just print the list of all parsed .v files then stop.
|
|
|
|
//
|
|
|
|
skip_running bool // when true, do no try to run the produced file (set by b.cc(), when -o x.c or -o x.js)
|
|
|
|
run_args []string // `v run x.v 1 2 3` => `1 2 3`
|
|
|
|
skip_warnings bool // like C's "-w", forces warnings to be ignored.
|
|
|
|
printfn_list []string // a list of generated function names, whose source should be shown, for debugging
|
|
|
|
warn_impure_v bool // -Wimpure-v, force a warning for JS.fn()/C.fn(), outside of .js.v/.c.v files. TODO: turn to an error by default
|
|
|
|
print_v_files bool // when true, just print the list of all parsed .v files then stop.
|
|
|
|
warns_are_errors bool // -W, like C's "-Werror", treat *every* warning is an error
|
|
|
|
skip_running bool // when true, do no try to run the produced file (set by b.cc(), when -o x.c or -o x.js)
|
|
|
|
fatal_errors bool // unconditionally exit after the first error with exit(1)
|
|
|
|
skip_warnings bool // like C's "-w", forces warnings to be ignored.
|
|
|
|
reuse_tmpc bool // do not use random names for .tmp.c and .tmp.c.rsp files, and do not remove them
|
|
|
|
warn_impure_v bool // -Wimpure-v, force a warning for JS.fn()/C.fn(), outside of .js.v/.c.v files. TODO: turn to an error by default
|
|
|
|
no_rsp bool // when true, pass C backend options directly on the CLI (do not use `.rsp` files for them, some older C compilers do not support them)
|
|
|
|
warns_are_errors bool // -W, like C's "-Werror", treat *every* warning is an error
|
|
|
|
no_std bool // when true, do not pass -std=gnu99(linux)/-std=c99 to the C backend
|
|
|
|
fatal_errors bool // unconditionally exit after the first error with exit(1)
|
|
|
|
|
|
|
|
reuse_tmpc bool // do not use random names for .tmp.c and .tmp.c.rsp files, and do not remove them
|
|
|
|
|
|
|
|
no_rsp bool // when true, pass C backend options directly on the CLI (do not use `.rsp` files for them, some older C compilers do not support them)
|
|
|
|
|
|
|
|
no_std bool // when true, do not pass -std=gnu99(linux)/-std=c99 to the C backend
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
no_parallel bool // do not use threads when compiling; slower, but more portable and sometimes less buggy
|
|
|
|
|
|
|
|
only_check_syntax bool // when true, just parse the files, then stop, before running checker
|
|
|
|
|
|
|
|
check_only bool // same as only_check_syntax, but also runs the checker
|
|
|
|
|
|
|
|
experimental bool // enable experimental features
|
|
|
|
|
|
|
|
skip_unused bool // skip generating C code for functions, that are not used
|
|
|
|
|
|
|
|
show_timings bool // show how much time each compiler stage took
|
|
|
|
|
|
|
|
//
|
|
|
|
use_color ColorOutput // whether the warnings/errors should use ANSI color escapes.
|
|
|
|
use_color ColorOutput // whether the warnings/errors should use ANSI color escapes.
|
|
|
|
no_parallel bool
|
|
|
|
cleanup_files []string // list of temporary *.tmp.c and *.tmp.c.rsp files. Cleaned up on successfull builds.
|
|
|
|
is_vweb bool // skip _ var warning in templates
|
|
|
|
build_options []string // list of options, that should be passed down to `build-module`, if needed for -usecache
|
|
|
|
only_check_syntax bool // when true, just parse the files, then stop, before running checker
|
|
|
|
|
|
|
|
check_only bool // same as only_check_syntax, but also runs the checker
|
|
|
|
|
|
|
|
experimental bool // enable experimental features
|
|
|
|
|
|
|
|
skip_unused bool // skip generating C code for functions, that are not used
|
|
|
|
|
|
|
|
show_timings bool // show how much time each compiler stage took
|
|
|
|
|
|
|
|
is_ios_simulator bool
|
|
|
|
|
|
|
|
is_apk bool // build as Android .apk format
|
|
|
|
|
|
|
|
cleanup_files []string // list of temporary *.tmp.c and *.tmp.c.rsp files. Cleaned up on successfull builds.
|
|
|
|
|
|
|
|
build_options []string // list of options, that should be passed down to `build-module`, if needed for -usecache
|
|
|
|
|
|
|
|
cache_manager vcache.CacheManager
|
|
|
|
cache_manager vcache.CacheManager
|
|
|
|
is_help bool // -h, -help or --help was passed
|
|
|
|
|
|
|
|
gc_mode GarbageCollectionMode = .no_gc // .no_gc, .boehm, .boehm_leak, ...
|
|
|
|
gc_mode GarbageCollectionMode = .no_gc // .no_gc, .boehm, .boehm_leak, ...
|
|
|
|
is_cstrict bool // turn on more C warnings; slightly slower
|
|
|
|
assert_failure_mode AssertFailureMode // whether to call abort() or print_backtrace() after an assertion failure
|
|
|
|
assert_failure_mode AssertFailureMode // whether to call abort() or print_backtrace() after an assertion failure
|
|
|
|
|
|
|
|
message_limit int = 100 // the maximum amount of warnings/errors/notices that will be accumulated
|
|
|
|
message_limit int = 100 // the maximum amount of warnings/errors/notices that will be accumulated
|
|
|
|
nofloat bool // for low level code, like kernels: replaces f32 with u32 and f64 with u64
|
|
|
|
nofloat bool // for low level code, like kernels: replaces f32 with u32 and f64 with u64
|
|
|
|
// checker settings:
|
|
|
|
// checker settings:
|
|
|
|
checker_match_exhaustive_cutoff_limit int = 12
|
|
|
|
checker_match_exhaustive_cutoff_limit int = 12
|
|
|
|
thread_stack_size int = 8388608 // Change with `-thread-stack-size 4194304`. Note: on macos it was 524288, which is too small for more complex programs with many nested callexprs.
|
|
|
|
thread_stack_size int = 8388608 // Change with `-thread-stack-size 4194304`. Note: on macos it was 524288, which is too small for more complex programs with many nested callexprs.
|
|
|
@ -206,8 +213,25 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
|
|
|
|
return parse_args_and_show_errors(known_external_commands, args, false)
|
|
|
|
return parse_args_and_show_errors(known_external_commands, args, false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[if linux]
|
|
|
|
|
|
|
|
fn detect_musl(mut res Preferences) {
|
|
|
|
|
|
|
|
res.is_glibc = true
|
|
|
|
|
|
|
|
res.is_musl = false
|
|
|
|
|
|
|
|
if os.exists('/etc/alpine-release') {
|
|
|
|
|
|
|
|
res.is_musl = true
|
|
|
|
|
|
|
|
res.is_glibc = false
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
my_libs := os.walk_ext('/proc/self/map_files/', '').map(os.real_path(it))
|
|
|
|
|
|
|
|
if my_libs.any(it.contains('musl')) {
|
|
|
|
|
|
|
|
res.is_musl = true
|
|
|
|
|
|
|
|
res.is_glibc = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn parse_args_and_show_errors(known_external_commands []string, args []string, show_output bool) (&Preferences, string) {
|
|
|
|
pub fn parse_args_and_show_errors(known_external_commands []string, args []string, show_output bool) (&Preferences, string) {
|
|
|
|
mut res := &Preferences{}
|
|
|
|
mut res := &Preferences{}
|
|
|
|
|
|
|
|
detect_musl(mut res)
|
|
|
|
$if x64 {
|
|
|
|
$if x64 {
|
|
|
|
res.m64 = true // follow V model by default
|
|
|
|
res.m64 = true // follow V model by default
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -412,6 +436,16 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
|
|
|
'-no-retry-compilation' {
|
|
|
|
'-no-retry-compilation' {
|
|
|
|
res.retry_compilation = false
|
|
|
|
res.retry_compilation = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
'-musl' {
|
|
|
|
|
|
|
|
res.is_musl = true
|
|
|
|
|
|
|
|
res.is_glibc = false
|
|
|
|
|
|
|
|
res.build_options << arg
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
'-glibc' {
|
|
|
|
|
|
|
|
res.is_musl = false
|
|
|
|
|
|
|
|
res.is_glibc = true
|
|
|
|
|
|
|
|
res.build_options << arg
|
|
|
|
|
|
|
|
}
|
|
|
|
'-no-builtin' {
|
|
|
|
'-no-builtin' {
|
|
|
|
res.no_builtin = true
|
|
|
|
res.no_builtin = true
|
|
|
|
res.build_options << arg
|
|
|
|
res.build_options << arg
|
|
|
@ -579,6 +613,10 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
|
|
|
'-cc' {
|
|
|
|
'-cc' {
|
|
|
|
res.ccompiler = cmdline.option(current_args, '-cc', 'cc')
|
|
|
|
res.ccompiler = cmdline.option(current_args, '-cc', 'cc')
|
|
|
|
res.build_options << '$arg "$res.ccompiler"'
|
|
|
|
res.build_options << '$arg "$res.ccompiler"'
|
|
|
|
|
|
|
|
if res.ccompiler == 'musl-gcc' {
|
|
|
|
|
|
|
|
res.is_musl = true
|
|
|
|
|
|
|
|
res.is_glibc = false
|
|
|
|
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'-checker-match-exhaustive-cutoff-limit' {
|
|
|
|
'-checker-match-exhaustive-cutoff-limit' {
|
|
|
|