diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 1561752481..3482cb48b0 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -611,6 +611,9 @@ fn (mut v Builder) cc() { v.show_c_compiler_output(res) } 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 ccompiler.contains('tcc.exe') { // a TCC problem? Retry with the system cc: @@ -621,9 +624,11 @@ fn (mut v Builder) cc() { } exit(101) } - v.pref.ccompiler = pref.default_c_compiler() - eprintln('Compilation with tcc failed. Retrying with $v.pref.ccompiler ...') - continue + if v.pref.retry_compilation { + v.pref.ccompiler = pref.default_c_compiler() + eprintln('Compilation with tcc failed. Retrying with $v.pref.ccompiler ...') + continue + } } if res.exit_code == 127 { verror('C compiler error, while attempting to run: \n' + diff --git a/vlib/v/pref/default.v b/vlib/v/pref/default.v index 96ef123f2c..623d61efb4 100644 --- a/vlib/v/pref/default.v +++ b/vlib/v/pref/default.v @@ -94,9 +94,18 @@ pub fn (mut p Preferences) fill_with_defaults() { '$p.lookup_path', ]) // eprintln('prefs.cache_manager: $p') - // - // enable use_cache by default - // p.use_cache = os.user_os() != 'windows' + // disable use_cache for specific cases: + if 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() { diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 6e22820ed3..4777c0994c 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -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). // use cached modules to speed up compilation. 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 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 @@ -220,6 +220,9 @@ pub fn parse_args(args []string) (&Preferences, string) { res.is_bare = true res.build_options << arg } + '-no-retry-compilation' { + res.retry_compilation = false + } '-no-preludes' { res.no_preludes = true res.build_options << arg @@ -276,7 +279,7 @@ pub fn parse_args(args []string) (&Preferences, string) { res.use_cache = true } '-nocache' { - res.no_cache = true + res.use_cache = false } '-prealloc' { res.prealloc = true