1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/cmd/v/help/build-c.txt
2020-05-04 14:21:32 +02:00

65 lines
2.6 KiB
Plaintext

Usage: v [build flags] ['build'] <file.v|directory>
This command compiles the given target, along with their dependencies, into an executable.
This help topic explores C-backend specific build flags.
For help regarding building an executable, see `v help build`.
These build flags are enabled on `build` and `run` as long as the backend is set to `c`:
-arch <architecture>
Change the architecture that V will tell the C compiler to build.
List of supported architectures: `x86` and `x64` (default).
-cc <compiler>
Change the C compiler V invokes to the specified compiler.
The C compiler is required to support C99.
Officially supported/tested C compilers include: `clang`, `gcc`, `tcc`, `mingw-w64` and `msvc`.
-cflags <flag>
Pass the provided flag as is to the C compiler.
Can be specified multiple times to provide multiple flags.
Use quotes to wrap the flag argument if it contains spaces.
-printfn <fn_name>
Prints the content of the generated C function named fn_name. You can repeat that many times.
This is useful when you just want to quickly tweak the generated C code,
without opening the generated .c file in an text editor.
-cg
Enable generating more debug information in the compiled executable.
This makes program backtraces more useful.
Using debuggers like gdb/lldb with such executables is easier too.
-compress
Strip the compiled executable to compress it.
-keepc
Specify that you want V to not delete the intermediate generated C source code.
Use with -cg for best debugging experience.
-freestanding
Build the executable without dependency on libc.
Supported only on `linux` targets currently.
-live
Build the executable with live capabilities (`[live]`).
-manual-free
Enable manually freeing on all V code. This will cause memory leaks in vlib.
Currently enabled until a stable auto-free system is in place.
-os <os>, -target-os <os>
Change the target OS that V tries to compile for.
By default, the target OS is the host system.
When OS is `cross`, V will attempt to output cross-platform C code.
List of OS supported by V: `linux`, `windows`, `mac`, `freebsd`, `openbsd`, `netbsd`,
`dragonfly`, `solaris`, `android` and `haiku`.
-sanitize
Pass flags related to sanitization to the C compiler.
-shared
Tell V to compile a shared object instead of an executable.
The resulting file extension will be `.dll` on Windows and `.so` on Unix systems