v.pref: fix `-nocache`, add `-no-retry-compilation`, add `-d trace_use_cache`

pull/7699/head
Delyan Angelov 2020-12-28 09:39:21 +02:00
parent b7a5dbf7b4
commit 100b3704cd
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 25 additions and 8 deletions

View File

@ -611,6 +611,9 @@ fn (mut v Builder) cc() {
v.show_c_compiler_output(res) v.show_c_compiler_output(res)
} }
os.chdir(original_pwd) os.chdir(original_pwd)
$if trace_use_cache ? {
eprintln('>>>> v.pref.use_cache: $v.pref.use_cache | v.pref.retry_compilation: $v.pref.retry_compilation | cmd res.exit_code: $res.exit_code | cmd: $cmd')
}
if res.exit_code != 0 { if res.exit_code != 0 {
if ccompiler.contains('tcc.exe') { if ccompiler.contains('tcc.exe') {
// a TCC problem? Retry with the system cc: // a TCC problem? Retry with the system cc:
@ -621,10 +624,12 @@ fn (mut v Builder) cc() {
} }
exit(101) exit(101)
} }
if v.pref.retry_compilation {
v.pref.ccompiler = pref.default_c_compiler() v.pref.ccompiler = pref.default_c_compiler()
eprintln('Compilation with tcc failed. Retrying with $v.pref.ccompiler ...') eprintln('Compilation with tcc failed. Retrying with $v.pref.ccompiler ...')
continue continue
} }
}
if res.exit_code == 127 { if res.exit_code == 127 {
verror('C compiler error, while attempting to run: \n' + verror('C compiler error, while attempting to run: \n' +
'-----------------------------------------------------------\n' + '$cmd\n' + '-----------------------------------------------------------\n' + '$cmd\n' +

View File

@ -94,9 +94,18 @@ pub fn (mut p Preferences) fill_with_defaults() {
'$p.lookup_path', '$p.lookup_path',
]) ])
// eprintln('prefs.cache_manager: $p') // eprintln('prefs.cache_manager: $p')
// // disable use_cache for specific cases:
// enable use_cache by default if os.user_os() == 'windows' {
// p.use_cache = os.user_os() != 'windows' p.use_cache = false
}
if p.build_mode == .build_module {
// eprintln('-usecache and build-module flags are not compatible')
p.use_cache = false
}
if p.is_shared {
// eprintln('-usecache and -shared flags are not compatible')
p.use_cache = false
}
} }
fn (mut p Preferences) find_cc_if_cross_compiling() { fn (mut p Preferences) find_cc_if_cross_compiling() {

View File

@ -79,7 +79,7 @@ pub mut:
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks). // which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
// use cached modules to speed up compilation. // use cached modules to speed up compilation.
use_cache bool // = true use_cache bool // = true
no_cache bool retry_compilation bool = true
is_stats bool // `v -stats file_test.v` will produce more detailed statistics for the tests that were run is_stats bool // `v -stats file_test.v` will produce more detailed statistics for the tests that were run
no_auto_free bool // `v -nofree` disable automatic `free()` insertion for better performance in some applications (e.g. compilers) no_auto_free bool // `v -nofree` disable automatic `free()` insertion for better performance in some applications (e.g. compilers)
// TODO Convert this into a []string // TODO Convert this into a []string
@ -220,6 +220,9 @@ pub fn parse_args(args []string) (&Preferences, string) {
res.is_bare = true res.is_bare = true
res.build_options << arg res.build_options << arg
} }
'-no-retry-compilation' {
res.retry_compilation = false
}
'-no-preludes' { '-no-preludes' {
res.no_preludes = true res.no_preludes = true
res.build_options << arg res.build_options << arg
@ -276,7 +279,7 @@ pub fn parse_args(args []string) (&Preferences, string) {
res.use_cache = true res.use_cache = true
} }
'-nocache' { '-nocache' {
res.no_cache = true res.use_cache = false
} }
'-prealloc' { '-prealloc' {
res.prealloc = true res.prealloc = true