From 7b41ef358c411deee8864f6f0533e31c904af6b6 Mon Sep 17 00:00:00 2001 From: Enzo Date: Sun, 10 Jan 2021 15:27:17 +0100 Subject: [PATCH] doc: document the custom compiler instrumentation flags in CONTRIBUTING.md (#7963) --- CONTRIBUTING.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 962cbc7ae3..46f0ef0573 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -165,3 +165,35 @@ which tests have failed and then fix them by making more changes. Just use `git push pullrequest` to publish your changes. The CI tests will run with your updated code. Use `hub ci-status --verbose` to monitor their status. + +## Flags + +V allows you to pass custom flags using `-d my_flag` that can then be checked +at compile time (see the documentation about +[compile-time if](https://github.com/vlang/v/blob/master/doc/docs.md#compile-time-if)). +There are numerous flags that can be passed when building the compiler +with `v self` or when creating a copy of the compiler, that will help +you when debugging. + +Beware that the flags must be passed when building the compiler, +not the program, so do for example: `v -d time_parsing cmd/v` or +`v -d trace_checker self`. +Some flags can make the compiler very verbose, so it is recommended +to create a copy of the compiler rather than replacing it with `v self`. + +| Flag | Usage | +|------|-------| +| `debugautostr` | Prints informations about `.str()` method auto-generated by the compiler during C generation | +| `debugscanner` | Prints debug information during the scanning phase | +| `debug_codegen` | Prints automatically generated V code during the scanning phase | +| `debug_interface_table` | Prints generated interfaces during C generation | +| `debug_interface_type_implements` | Prints debug information when checking that a type implements in interface | +| `print_vweb_template_expansions` | Prints vweb compiled HTML files | +| `time_checking` | Prints the time spent checking files and other related informations | +| `time_parsing` | Prints the time spent parsing files and other related informations | +| `trace_ccoptions` | Prints options passed down to the C compiler | +| `trace_checker` | Prints informations about the statements being checked | +| `trace_gen` | Prints strings written to the generated C file. Beware, this flag is very verbose | +| `trace_parser` | Prints informations about parsed statements and expressions | +| `trace_thirdparty_obj_files` | Prints informations about built thirdparty obj files | +| `trace_use_cache` | Prints informations about cache use |