v.pref, v.builder: support `-no-std` (skips passing `-std=c99` to the C backend)

pull/11187/head
Delyan Angelov 2021-08-15 11:05:06 +03:00
parent b1186cca3f
commit eef7eea7bc
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 25 additions and 11 deletions

View File

@ -237,6 +237,13 @@ see also `v help build`.
you use -no-rsp, V will pass the C compiler options directly to the C
compiler, on the command line, without writing an .rsp file first.
-no-std
By default, V passes -std=c99 to the C backend, but some compilers do
not support that, even though they may be able to compile the produced
code, or have other options that can be tuned to allow it.
Passing -no-std will remove that flag, and you can then use -cflags ''
to pass the other options for your specific C compiler.
-assert aborts
Call abort() after an assertion failure. Debuggers usually
install signal handlers for SIGABRT, so your program will stop and you

View File

@ -186,7 +186,10 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
mut debug_options := ['-g']
mut optimization_options := ['-O2']
// arguments for the C compiler
ccoptions.args = [v.pref.cflags, '-std=gnu99']
ccoptions.args = [v.pref.cflags]
if !v.pref.no_std {
ccoptions.args << '-std=c99'
}
ccoptions.wargs = [
'-Wall',
'-Wextra',

View File

@ -173,6 +173,7 @@ pub mut:
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=c99 to the C backend
use_color ColorOutput // whether the warnings/errors should use ANSI color escapes.
is_parallel bool
error_limit int
@ -478,6 +479,9 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
'-no-rsp' {
res.no_rsp = true
}
'-no-std' {
res.no_std = true
}
'-keepc' {
res.reuse_tmpc = true
}