[PATCH] D71400: [RFC] [MinGW] Implicitly add .exe suffix if not provided
Martin Storsjö via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 17 00:09:47 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee0a3b5c776c: [MinGW] Implicitly add .exe suffix if not provided (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71400/new/
https://reviews.llvm.org/D71400
Files:
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw-implicit-extension-cross.c
clang/test/Driver/mingw-implicit-extension-windows.c
Index: clang/test/Driver/mingw-implicit-extension-windows.c
===================================================================
--- /dev/null
+++ clang/test/Driver/mingw-implicit-extension-windows.c
@@ -0,0 +1,14 @@
+// Test how an implicit .exe extension is added. If running the compiler
+// on windows, an implicit extension is added if none is provided in the
+// given name. (Therefore, this test is skipped when not running on windows.)
+
+// REQUIRES: system-windows
+
+// RUN: %clang -target i686-windows-gnu -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -o outputname 2>&1 | FileCheck %s --check-prefix=CHECK-OUTPUTNAME-EXE
+
+// RUN: %clang -target i686-windows-gnu -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -o outputname.exe 2>&1 | FileCheck %s --check-prefix=CHECK-OUTPUTNAME-EXE
+
+// RUN: %clang -target i686-windows-gnu -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -o outputname.q 2>&1 | FileCheck %s --check-prefix=CHECK-OUTPUTNAME-Q
+
+// CHECK-OUTPUTNAME-EXE: "-o" "outputname.exe"
+// CHECK-OUTPUTNAME-Q: "-o" "outputname.q"
Index: clang/test/Driver/mingw-implicit-extension-cross.c
===================================================================
--- /dev/null
+++ clang/test/Driver/mingw-implicit-extension-cross.c
@@ -0,0 +1,9 @@
+// Test how an implicit .exe extension is added. If not running the compiler
+// on windows, no implicit extension is added. (Therefore, this test is skipped
+// when running on windows.)
+
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -target i686-windows-gnu -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -o outputname 2>&1 | FileCheck %s
+
+// CHECK: "-o" "outputname"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===================================================================
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -160,7 +160,19 @@
}
CmdArgs.push_back("-o");
- CmdArgs.push_back(Output.getFilename());
+ const char *OutputFile = Output.getFilename();
+ // GCC implicitly adds an .exe extension if it is given an output file name
+ // that lacks an extension. However, GCC only does this when actually
+ // running on windows, not when operating as a cross compiler. As some users
+ // have come to rely on this behaviour, try to replicate it.
+#ifdef _WIN32
+ if (!llvm::sys::path::has_extension(OutputFile))
+ 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71400.234226.patch
Type: text/x-patch
Size: 2617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191217/598aa70a/attachment.bin>
More information about the cfe-commits
mailing list