From cc57f3a59ed7e19d663ed77654de2a5e16e16875 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 Oct 2019 12:13:05 +0200 Subject: Add %VCINSTALLDIR%\Tools\Llvm\bin as fallback search directory for Clang --- libbuild2/cc/guess.cxx | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'libbuild2/cc/guess.cxx') diff --git a/libbuild2/cc/guess.cxx b/libbuild2/cc/guess.cxx index b5b791c..40fb14f 100644 --- a/libbuild2/cc/guess.cxx +++ b/libbuild2/cc/guess.cxx @@ -351,6 +351,9 @@ namespace build2 assert (!xi || xi->type == pre); + using type = compiler_type; + const type invalid = invalid_compiler_type; + guess_result r; process_path xp; @@ -361,18 +364,37 @@ namespace build2 dr << info << "use config." << xm << " to override"; }); + // If we are running in the Visual Studio command prompt, add the + // potentially bundled Clang directory as a fallback (for some reason + // the Visual Studio prompts don't add it to PATH themselves). + // + dir_path fallback; + +#ifdef _WIN32 + if (pre == type::clang) + { + if (optional v = getenv ("VCINSTALLDIR")) + { + try + { + fallback = ((dir_path (move (*v)) /= "Tools") /= "Llvm") /= "bin"; + } + catch (const invalid_path&) + { + // Ignore it. + } + } + } +#endif // Only search in PATH (specifically, omitting the current // executable's directory on Windows). // xp = run_search (xc, - false /* init */, // Note: result is cached. - dir_path () /* fallback */, - true /* path_only */); + false /* init (note: result is cached) */, + fallback, + true /* path_only */); } - using type = compiler_type; - const type invalid = invalid_compiler_type; - // Start with -v. This will cover gcc and clang. // // While icc also writes what may seem like something we can use to -- cgit v1.1