v: add -cstrict for optionally turning on all ccoptions.wargs

pull/9756/head
Delyan Angelov 2021-04-15 14:55:36 +03:00
parent 5ae3b81337
commit d90be54850
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 16 additions and 5 deletions

View File

@ -17,6 +17,10 @@ see also `v help build`.
Can be specified multiple times to provide multiple flags. Can be specified multiple times to provide multiple flags.
Use quotes to wrap the flag argument if it contains spaces. Use quotes to wrap the flag argument if it contains spaces.
-cstrict
Turn on additional C warnings. This slows down compilation
slightly (~10-10% for gcc), but sometimes provides better diagnosis.
-showcc -showcc
Prints the C command that is used to build the program. Prints the C command that is used to build the program.

View File

@ -378,14 +378,17 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
} }
v.ccoptions = ccoptions v.ccoptions = ccoptions
// setup the cache too, so that different compilers/options do not interfere: // setup the cache too, so that different compilers/options do not interfere:
v.pref.cache_manager.set_temporary_options(ccoptions.thirdparty_object_args([ v.pref.cache_manager.set_temporary_options(v.thirdparty_object_args(v.ccoptions, [
ccoptions.guessed_compiler, ccoptions.guessed_compiler,
])) ]))
} }
fn (ccoptions CcompilerOptions) all_args() []string { fn (v &Builder) all_args(ccoptions CcompilerOptions) []string {
mut all := []string{} mut all := []string{}
all << ccoptions.env_cflags all << ccoptions.env_cflags
if v.pref.is_cstrict {
all << ccoptions.wargs
}
all << ccoptions.args all << ccoptions.args
all << ccoptions.o_args all << ccoptions.o_args
all << ccoptions.pre_args all << ccoptions.pre_args
@ -396,7 +399,7 @@ fn (ccoptions CcompilerOptions) all_args() []string {
return all return all
} }
fn (ccoptions CcompilerOptions) thirdparty_object_args(middle []string) []string { fn (v &Builder) thirdparty_object_args(ccoptions CcompilerOptions, middle []string) []string {
mut all := []string{} mut all := []string{}
all << ccoptions.env_cflags all << ccoptions.env_cflags
all << ccoptions.args all << ccoptions.args
@ -611,7 +614,7 @@ fn (mut v Builder) cc() {
} }
} }
// //
all_args := v.ccoptions.all_args() all_args := v.all_args(v.ccoptions)
v.dump_c_options(all_args) v.dump_c_options(all_args)
str_args := all_args.join(' ') str_args := all_args.join(' ')
// write args to response file // write args to response file
@ -953,7 +956,7 @@ fn (mut v Builder) build_thirdparty_obj_file(path string, moduleflags []cflag.CF
all_options << moduleflags.c_options_before_target() all_options << moduleflags.c_options_before_target()
all_options << '-o "$opath"' all_options << '-o "$opath"'
all_options << '-c "$cfile"' all_options << '-c "$cfile"'
cc_options := v.ccoptions.thirdparty_object_args(all_options).join(' ') cc_options := v.thirdparty_object_args(v.ccoptions, all_options).join(' ')
cmd := '$v.pref.ccompiler $cc_options' cmd := '$v.pref.ccompiler $cc_options'
$if trace_thirdparty_obj_files ? { $if trace_thirdparty_obj_files ? {
println('>>> build_thirdparty_obj_files cmd: $cmd') println('>>> build_thirdparty_obj_files cmd: $cmd')

View File

@ -166,6 +166,7 @@ pub mut:
cache_manager vcache.CacheManager cache_manager vcache.CacheManager
is_help bool // -h, -help or --help was passed 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
// checker settings: // checker settings:
checker_match_exhaustive_cutoff_limit int = 10 checker_match_exhaustive_cutoff_limit int = 10
} }
@ -227,6 +228,9 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
'-silent' { '-silent' {
res.output_mode = .silent res.output_mode = .silent
} }
'-cstrict' {
res.is_cstrict = true
}
'-gc' { '-gc' {
gc_mode := cmdline.option(current_args, '-gc', '') gc_mode := cmdline.option(current_args, '-gc', '')
match gc_mode { match gc_mode {