2021-01-13 13:50:35 +03:00
|
|
|
Usage: v [build flags] ['run'] <target.v|target_directory> [run options]
|
2020-03-13 22:52:49 +03:00
|
|
|
|
|
|
|
This command compiles the given target, along with their dependencies, into an executable.
|
|
|
|
|
2021-01-13 13:50:35 +03:00
|
|
|
Note that these build flags also work with `run` too, but you need to
|
|
|
|
pass them *before* `run` . The argument directly after `run` is assumed
|
|
|
|
to be a .v source file or folder containing .v source files.
|
|
|
|
Everything after that, is assumed to be flags, that V will ignore itself,
|
|
|
|
but will pass to the executable after it is compiled.
|
2020-03-13 22:52:49 +03:00
|
|
|
|
2021-01-13 13:50:35 +03:00
|
|
|
This enables you to do for example: `v -cc gcc -g myfile.v run -param1 abcde`
|
|
|
|
... which means for V: "compile using gcc, produce debugging information,
|
|
|
|
then run `./myfile -param1 abcde` and exit with its exit code".
|
|
|
|
|
|
|
|
When compiling packages, V ignores files that end in '_test.v'.
|
|
|
|
|
|
|
|
When compiling a single main package, V writes the resulting executable to an output file
|
2020-03-13 22:52:49 +03:00
|
|
|
named after the build target. ('v abc.v' and 'v abc/' both write either 'abc' or 'abc.exe')
|
2021-01-13 13:50:35 +03:00
|
|
|
The '.exe' suffix is added automatically, when writing a Windows executable.
|
2020-03-13 22:52:49 +03:00
|
|
|
By default, the executable is stored in the same directory as the compiled source code.
|
|
|
|
|
2021-01-13 13:50:35 +03:00
|
|
|
The -o flag forces V to write the resulting executable or object to the d output file or directory,
|
2020-03-13 22:52:49 +03:00
|
|
|
instead of the default behavior described in the last two paragraphs.
|
|
|
|
|
|
|
|
You can put common options inside an environment variable named VFLAGS, so that
|
|
|
|
you don't have to repeat them.
|
|
|
|
|
2021-01-13 13:50:35 +03:00
|
|
|
You can set it like this: `export VFLAGS="-cc clang -g"` on *nix,
|
2020-03-13 22:52:49 +03:00
|
|
|
`set VFLAGS=-cc msvc` on Windows.
|
|
|
|
|
|
|
|
V respects the TMPDIR environment variable, and will put .tmp.c files in TMPDIR/v/ .
|
|
|
|
If you have not set it, a suitable platform specific folder (like /tmp) will be used.
|
|
|
|
|
2021-01-13 13:50:35 +03:00
|
|
|
NB: the build flags are shared with the run command too:
|
2020-03-13 22:52:49 +03:00
|
|
|
|
|
|
|
-b <backend>, -backend <backend>
|
|
|
|
Specify the backend to use while building the executable.
|
|
|
|
Current list of supported backends:
|
|
|
|
* `c` (default) - V outputs C source code which is passed to a C compiler to be compiled.
|
|
|
|
* `js` - V outputs JS source code which can be passed to NodeJS to be ran.
|
2021-09-04 11:03:21 +03:00
|
|
|
* `js_browser` - V outputs JS source code ready for the browser.
|
|
|
|
* `js_node` - V outputs JS source code to run with nodejs.
|
|
|
|
* `js_freestanding` - V outputs JS source code with no hard runtime dependency.
|
2021-07-08 21:26:07 +03:00
|
|
|
* `native` - V outputs native executable (see -arch x64|arm64 and -os linux|macos) (EXPERIMENTAL).
|
2020-03-13 22:52:49 +03:00
|
|
|
|
|
|
|
-d <flag>[=<value>], -define <flag>[=<value>]
|
2020-03-14 16:20:44 +03:00
|
|
|
Define the provided flag.
|
2020-03-13 22:52:49 +03:00
|
|
|
If value is not provided, it is assumed to be set to `true`.
|
|
|
|
`value` should be `1` or `0` to indicate `true` and `false` respectively otherwise.
|
|
|
|
|
2021-01-13 13:50:35 +03:00
|
|
|
-g
|
2020-03-14 16:20:44 +03:00
|
|
|
Compile the executable in debug mode, allowing code to be debugged more easily.
|
2020-03-13 22:52:49 +03:00
|
|
|
|
|
|
|
-o <output>, -output <output>
|
2020-03-14 16:20:44 +03:00
|
|
|
Force V to output the executable in a specific location
|
|
|
|
(relative to the current working directory if not absolute).
|
2020-03-13 22:52:49 +03:00
|
|
|
|
|
|
|
-obf, -obfuscate
|
2020-03-14 16:20:44 +03:00
|
|
|
Turn on obfuscation for the code being built. Currently only renames symbols.
|
2020-03-13 22:52:49 +03:00
|
|
|
|
|
|
|
-path
|
2020-03-14 16:20:44 +03:00
|
|
|
Specify the order of path V looks up in while searching for imported dependencies,
|
2020-03-13 22:52:49 +03:00
|
|
|
separated by pipes (`|`). In addition to absolute paths, you can
|
|
|
|
also use these special strings too:
|
2020-03-14 16:20:44 +03:00
|
|
|
@vmodules - replaced with the location of the global ~/.vmodules/ folder
|
2021-01-13 13:50:35 +03:00
|
|
|
(modules installed with `v install` are there). You can change
|
2020-11-08 09:07:17 +03:00
|
|
|
its location by setting the environment variable VMODULES.
|
2020-03-13 22:52:49 +03:00
|
|
|
@vlib - replaced with the location of the v's vlib folder.
|
|
|
|
Using these, you can arrange for very flexible search orders for you project, for example:
|
|
|
|
-path "/v/my_project_private_modules|@vlib|@vmodules"
|
|
|
|
By default, -path is just "@vlib|@vmodules" .
|
|
|
|
|
|
|
|
-prod
|
2021-01-13 13:50:35 +03:00
|
|
|
Compile the executable in production mode, where most optimizations are enabled.
|
|
|
|
Note that most V warnings turn to errors, if you pass -prod, so you will have
|
|
|
|
to fix them first.
|
2020-03-13 22:52:49 +03:00
|
|
|
|
2020-04-25 13:41:49 +03:00
|
|
|
-prof, -profile <file.txt>
|
2020-03-14 16:20:44 +03:00
|
|
|
Compile the executable with all functions profiled.
|
2020-04-25 13:41:49 +03:00
|
|
|
The profile results will be stored in `file.txt`.
|
|
|
|
The format is 4 fields, separated by a space, for each v function:
|
|
|
|
a) how many times it was called
|
|
|
|
b) how much *nanoseconds in total* it took
|
|
|
|
c) an average for each function (i.e. (b) / (a) )
|
|
|
|
d) the function name
|
|
|
|
NB: if you want to output the profile info to stdout, use `-profile -`.
|
2020-06-01 21:15:44 +03:00
|
|
|
|
2021-08-15 13:46:50 +03:00
|
|
|
-message-limit <limit>
|
2021-08-15 13:41:51 +03:00
|
|
|
The maximum amount of warnings / errors / notices, that will be accumulated (defaults to 100).
|
|
|
|
The checker will abort prematurely once this limit has been reached.
|
|
|
|
Setting this to 0 or a negative value, will disable the limit.
|
2021-08-14 19:49:21 +03:00
|
|
|
|
2021-09-28 10:28:04 +03:00
|
|
|
-no-parallel
|
|
|
|
Do not run the compiler in parallel (currently only the cgen stage has parallelization).
|
|
|
|
|
2020-06-01 21:15:44 +03:00
|
|
|
-profile-no-inline
|
2020-05-08 14:59:48 +03:00
|
|
|
Skip [inline] functions when profiling.
|
2020-06-01 21:15:44 +03:00
|
|
|
|
2021-10-21 16:32:57 +03:00
|
|
|
-skip-unused
|
|
|
|
Skip generating C/JS code for functions, that are provably not used by your project.
|
|
|
|
This speeds up compilation, and reduces the generated output size.
|
|
|
|
It is still experimental, due to historical reasons, but please do try it,
|
|
|
|
and report issues, if compilation breaks with that option for your program.
|
|
|
|
|
2020-03-13 22:52:49 +03:00
|
|
|
-stats
|
|
|
|
Enable more detailed statistics reporting, while compiling test files.
|
|
|
|
You can use that with `v test` too, for example:
|
|
|
|
v -stats test vlib/
|
|
|
|
... will run test_ functions inside all _test.v files inside vlib/ ,
|
2020-03-14 16:20:44 +03:00
|
|
|
and will report detailed statistics about how much time each test_ function took, how many
|
2020-03-13 22:52:49 +03:00
|
|
|
assertions were made, how many tests passed/failed and so on.
|
|
|
|
|
|
|
|
-translated
|
2020-03-14 16:20:44 +03:00
|
|
|
Enable features that are discouraged in regular V code but required for translated V code.
|
2020-03-13 22:52:49 +03:00
|
|
|
|
2020-06-01 21:15:44 +03:00
|
|
|
-v
|
|
|
|
Enable verbosity in the V compiler while compiling
|
2020-03-13 22:52:49 +03:00
|
|
|
|
2021-03-04 15:38:05 +03:00
|
|
|
-print-v-files
|
2020-04-30 19:15:30 +03:00
|
|
|
Just print the list of all parsed .v files, then stop processing further.
|
|
|
|
This is useful for running external processing tools:
|
2021-03-04 15:38:05 +03:00
|
|
|
./v -print-v-files cmd/v | etags -L -
|
2020-04-30 19:15:30 +03:00
|
|
|
... will generate a TAGS file, that emacs can then use to jump
|
|
|
|
to the definition of functions used by v itself. For vim:
|
2021-03-04 15:38:05 +03:00
|
|
|
./v -print-v-files cmd/v | ctags -L -
|
2020-04-30 19:15:30 +03:00
|
|
|
... will generate a simillar tags file, that vi compatible editors can use.
|
|
|
|
NB: an useful, although not entirely accurate regexp based Universal Ctags options file
|
|
|
|
for V is located in `.ctags.d/v.ctags` . If you use https://ctags.io/ , it will be used
|
|
|
|
up automatically, or you can specify it explicitly with --options=.ctags.d/v.ctags .
|
2020-06-01 21:15:44 +03:00
|
|
|
|
2020-05-20 20:33:29 +03:00
|
|
|
-color, -nocolor
|
2021-01-13 13:50:35 +03:00
|
|
|
Force the use of ANSI colors for the V error/warning messages, or disable them completely.
|
|
|
|
By default, the V compiler tries to show its errors/warnings in ANSI color. The heuristic
|
|
|
|
that it uses to detect whether or not to use ANSI colors may not work in all cases.
|
2020-05-20 20:33:29 +03:00
|
|
|
These options allow you to override the default detection.
|
2020-04-30 19:15:30 +03:00
|
|
|
|
2021-09-07 07:17:53 +03:00
|
|
|
-check
|
|
|
|
Scans, parses, and checks the files without compiling the program.
|
|
|
|
|
2020-07-14 18:45:44 +03:00
|
|
|
-check-syntax
|
|
|
|
Only scan and parse the files, but then stop. Useful for very quick syntax checks.
|
2020-09-14 16:33:58 +03:00
|
|
|
|
2020-07-14 18:45:44 +03:00
|
|
|
-show-timings
|
|
|
|
Print a summary about how long each compiler stage took, for example:
|
|
|
|
PARSE: 152ms
|
|
|
|
CHECK: 62ms
|
|
|
|
C GEN: 103ms
|
|
|
|
C tcc: 95ms
|
2021-01-13 13:50:35 +03:00
|
|
|
|
|
|
|
Related to -show-timings, is the ability to compile a special instrumented
|
|
|
|
v compiler with this command:
|
2020-12-19 13:24:29 +03:00
|
|
|
`v -d time_parsing -d time_checking -d time_cgening -d time_v self`
|
|
|
|
The instrumented version will print detailed timing stats while processing
|
|
|
|
each .v file.
|
2020-09-14 16:33:58 +03:00
|
|
|
|
2020-11-29 16:11:12 +03:00
|
|
|
-w
|
|
|
|
Hide all warnings.
|
|
|
|
|
2020-10-24 20:29:24 +03:00
|
|
|
-W
|
2021-01-13 13:50:35 +03:00
|
|
|
Treat *all V warnings* as errors, even in development builds.
|
|
|
|
|
2020-12-04 21:34:05 +03:00
|
|
|
-Wfatal-errors
|
2021-01-13 13:50:35 +03:00
|
|
|
Unconditionally exit with exit(1) after the first error.
|
2020-12-08 19:52:24 +03:00
|
|
|
Useful for scripts/tooling that calls V.
|
|
|
|
|
|
|
|
-Wimpure-v
|
2021-01-13 13:50:35 +03:00
|
|
|
Warn about using C. or JS. symbols in plain .v files.
|
2020-12-08 19:52:24 +03:00
|
|
|
These should be moved in .c.v and .js.v .
|
2021-01-13 13:50:35 +03:00
|
|
|
NB: in the future, this will be turned ON by default,
|
|
|
|
and will become an error, after vlib modules are cleaned up.
|
|
|
|
|
2020-03-13 22:52:49 +03:00
|
|
|
For C-specific build flags, use `v help build-c`.
|
2021-05-23 05:54:28 +03:00
|
|
|
For JS-specific build flags, use `v help build-js`.
|
|
|
|
For Native-specific build flags, use `v help build-native`.
|
2020-03-13 22:52:49 +03:00
|
|
|
|
|
|
|
See also:
|
|
|
|
`v help run` for documentation regarding `v run`.
|