diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -198,7 +198,7 @@ /// Normalize the program name from argv[0] by stripping the file extension if /// present and lower-casing the string on Windows. static std::string normalizeProgramName(llvm::StringRef Argv0) { - std::string ProgName = std::string(llvm::sys::path::stem(Argv0)); + std::string ProgName = std::string(llvm::sys::path::filename(Argv0)); if (is_style_windows(llvm::sys::path::Style::native)) { // Transform to lowercase for case insensitive file systems. std::transform(ProgName.begin(), ProgName.end(), ProgName.begin(), @@ -217,6 +217,13 @@ // added via -target as implicit first argument. const DriverSuffix *DS = FindDriverSuffix(ProgName, Pos); + if (!DS && ProgName.endswith(".exe")) { + // Try again after stripping the executable suffix: + // clang++.exe -> clang++ + ProgName = ProgName.drop_back(StringRef(".exe").size()); + DS = FindDriverSuffix(ProgName, Pos); + } + if (!DS) { // Try again after stripping any trailing version number: // clang++3.5 -> clang++