From 7c7cd5c27bd92e5b837c33edb97fa3f0a0d9ad79 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 21 Aug 2018 10:39:22 +0200 Subject: Unset CL and _CL_ environment variables when detecting MSVC --- build2/cc/guess.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'build2/cc') diff --git a/build2/cc/guess.cxx b/build2/cc/guess.cxx index 89030b5..e9b102f 100644 --- a/build2/cc/guess.cxx +++ b/build2/cc/guess.cxx @@ -451,7 +451,16 @@ namespace build2 return guess_result (); }; - r = run (3, xp, f, false); + // One can pass extra options/arguments to cl.exe with the CL and _CL_ + // environment variables. However, if such extra options are passed + // without anything to compile, then cl.exe no longer prints usage and + // exits successfully but instead issues an error and fails. So we are + // going to unset these variables for our test (interestingly, only CL + // seem to cause the problem but let's unset both, for good measure). + // + const char* env[] = {"CL=", "_CL_=", nullptr}; + + r = run (3, process_env (xp, env), f, false); } if (!r.empty ()) -- cgit v1.1