mstorsjo created this revision. mstorsjo added a reviewer: rnk. Herald added a project: clang.
GCC implicitly adds an .exe suffix if it is given an output file name, but the file name doesn't contain a suffix, and there are certain users of GCC that rely on this behaviour (and run into issues when trying to use Clang instead of GCC). And MSVC's cl.exe also does the same (but not link.exe). However, GCC only does this when actually running on windows, not when operating as a cross compiler. This was reported to me at https://github.com/mstorsjo/llvm-mingw/issues/60. As GCC doesn't have this behaviour when cross compiling, we definitely shouldn't introduce the behaviour in such cases (as it would break at least as many cases as this fixes). Is it worth adding such inconsistent behaviour (with two separate tests, one for running on windows and one elsewhere)? Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D71400 Files: clang/lib/Driver/ToolChains/MinGW.cpp Index: clang/lib/Driver/ToolChains/MinGW.cpp =================================================================== --- clang/lib/Driver/ToolChains/MinGW.cpp +++ clang/lib/Driver/ToolChains/MinGW.cpp @@ -160,7 +160,15 @@ } CmdArgs.push_back("-o"); - CmdArgs.push_back(Output.getFilename()); + const char *OutputFile = Output.getFilename(); +#ifdef _WIN32 + if (!llvm::sys::path::filename(OutputFile).contains('.')) + CmdArgs.push_back(Args.MakeArgString(Twine(OutputFile) + ".exe")); + else + CmdArgs.push_back(OutputFile); +#else + CmdArgs.push_back(OutputFile); +#endif Args.AddAllArgs(CmdArgs, options::OPT_e); // FIXME: add -N, -n flags
Index: clang/lib/Driver/ToolChains/MinGW.cpp =================================================================== --- clang/lib/Driver/ToolChains/MinGW.cpp +++ clang/lib/Driver/ToolChains/MinGW.cpp @@ -160,7 +160,15 @@ } CmdArgs.push_back("-o"); - CmdArgs.push_back(Output.getFilename()); + const char *OutputFile = Output.getFilename(); +#ifdef _WIN32 + if (!llvm::sys::path::filename(OutputFile).contains('.')) + CmdArgs.push_back(Args.MakeArgString(Twine(OutputFile) + ".exe")); + else + CmdArgs.push_back(OutputFile); +#else + CmdArgs.push_back(OutputFile); +#endif Args.AddAllArgs(CmdArgs, options::OPT_e); // FIXME: add -N, -n flags
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits