[Windows] Add diagnostics about missing ComSpec environment variable while setting up an MSVC environment during linking. If ComSpec is not defined, assume "cmd.exe".

This commit is contained in:
Johan Engelen 2015-12-19 17:02:49 +01:00
parent 8e2f993117
commit 54e9a69b29

View file

@ -358,11 +358,16 @@ int executeMsvcToolAndWait(const std::string &tool,
* be parsed properly.
*/
std::string cmdPath = getenv("ComSpec");
auto comspecEnv = getenv("ComSpec");
if (!comspecEnv) {
warning(Loc(), "'ComSpec' environment variable is not set, assuming 'cmd.exe'.");
comspecEnv = "cmd.exe";
}
std::string cmdExecutable = comspecEnv;
std::string batchFile = exe_path::prependBinDir(
global.params.targetTriple.isArch64Bit() ? "amd64.bat" : "x86.bat");
commandLine.append(windows::quoteArg(cmdPath));
commandLine.append(windows::quoteArg(cmdExecutable));
commandLine.append(" /s /c \"");
commandLine.append(windows::quoteArg(batchFile));
commandLine.push_back(' ');