1 --- a/llvm-3.1/tools/clang/lib/Driver/Driver.cpp 2012-09-12 14:26:52.000000000 -0700 2 +++ b/llvm-3.1/tools/clang/lib/Driver/Driver.cpp 2012-09-18 01:07:22.957409591 -0700 3 @@ -1534,8 +1534,16 @@ 4 5 std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC, 6 bool WantFile) const { 7 + std::string N(Name); 8 +#ifdef __MINGW32__ 9 + // We expect callers never pass Name ends with uppercase ".EXE" 10 + std::string Suffix(".exe"); 11 + if (N.length() < Suffix.length() || 12 + (N.compare(N.length() - Suffix.length(), Suffix.length(), Suffix)) != 0) 13 + N += ".exe"; 14 +#endif 15 // FIXME: Needs a better variable than DefaultTargetTriple 16 - std::string TargetSpecificExecutable(DefaultTargetTriple + "-" + Name); 17 + std::string TargetSpecificExecutable(DefaultTargetTriple + "-" + N); 18 // Respect a limited subset of the '-Bprefix' functionality in GCC by 19 // attempting to use this prefix when lokup up program paths. 20 for (Driver::prefix_list::const_iterator it = PrefixDirs.begin(), 21 @@ -1544,7 +1552,7 @@ 22 P.appendComponent(TargetSpecificExecutable); 23 if (isPathExecutable(P, WantFile)) return P.str(); 24 P.eraseComponent(); 25 - P.appendComponent(Name); 26 + P.appendComponent(N); 27 if (isPathExecutable(P, WantFile)) return P.str(); 28 } 29 30 @@ -1555,7 +1563,7 @@ 31 P.appendComponent(TargetSpecificExecutable); 32 if (isPathExecutable(P, WantFile)) return P.str(); 33 P.eraseComponent(); 34 - P.appendComponent(Name); 35 + P.appendComponent(N); 36 if (isPathExecutable(P, WantFile)) return P.str(); 37 } 38 39 @@ -1565,10 +1573,11 @@ 40 if (!P.empty()) 41 return P.str(); 42 43 - P = llvm::sys::Path(llvm::sys::Program::FindProgramByName(Name)); 44 + P = llvm::sys::Path(llvm::sys::Program::FindProgramByName(N)); 45 if (!P.empty()) 46 return P.str(); 47 48 + // Return the original Name, not N 49 return Name; 50 } 51 52