diff --git a/vlib/v/builder/cc_windows.v b/vlib/v/builder/cc_windows.v index 64475873137ae9..ea05a33bcc4ad3 100644 --- a/vlib/v/builder/cc_windows.v +++ b/vlib/v/builder/cc_windows.v @@ -17,25 +17,27 @@ pub fn (mut v Builder) find_win_cc() ! { println('failed command: `${cmd_version}`') println('${v.pref.ccompiler} not found, looking for msvc...') } - msvc := find_msvc(v.pref.m64) or { - if v.pref.is_verbose { - println('msvc not found, looking for thirdparty/tcc...') - } - thirdparty_tcc := os.join_path(v.pref.vroot, 'thirdparty', 'tcc', 'tcc.exe') - tcc_version_res := os.execute('${os.quoted_path(thirdparty_tcc)} -v') - if tcc_version_res.exit_code != 0 { + if !v.cached_msvc.valid { + msvc := find_msvc(v.pref.m64) or { if v.pref.is_verbose { - println('tcc not found') + println('msvc not found, looking for thirdparty/tcc...') + } + thirdparty_tcc := os.join_path(v.pref.vroot, 'thirdparty', 'tcc', 'tcc.exe') + tcc_version_res := os.execute('${os.quoted_path(thirdparty_tcc)} -v') + if tcc_version_res.exit_code != 0 { + if v.pref.is_verbose { + println('tcc not found') + } + return error('tcc not found') } - return error('tcc not found') + v.pref.ccompiler = thirdparty_tcc + v.pref.ccompiler_type = .tinyc + return } - v.pref.ccompiler = thirdparty_tcc - v.pref.ccompiler_type = .tinyc - return + v.cached_msvc = msvc } v.pref.ccompiler = 'msvc' v.pref.ccompiler_type = .msvc - v.cached_msvc = msvc return } v.pref.ccompiler_type = pref.cc_from_string(v.pref.ccompiler)