[clang] ead7c3c - [clang] [MinGW] Add an implicit .exe suffix even when crosscompiling
Martin Storsjö via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 13:43:21 PDT 2020
Author: Martin Storsjö
Date: 2020-09-21T23:42:59+03:00
New Revision: ead7c3cdc34c63d8df78d8e333b7cc64d03236ea
URL: https://github.com/llvm/llvm-project/commit/ead7c3cdc34c63d8df78d8e333b7cc64d03236ea
DIFF: https://github.com/llvm/llvm-project/commit/ead7c3cdc34c63d8df78d8e333b7cc64d03236ea.diff
LOG: [clang] [MinGW] Add an implicit .exe suffix even when crosscompiling
GCC 8 changed behaviour wrt this, and made it consistent for cross
compilation cases. While it's a change, it's a more sensible behaviour
going forward.
Differential Revision: https://reviews.llvm.org/D88005
Added:
Modified:
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw-implicit-extension-windows.c
Removed:
clang/test/Driver/mingw-implicit-extension-cross.c
################################################################################
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index a1a1b413fb6c..ea9d29a1f831 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -164,17 +164,13 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-o");
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
+ // that lacks an extension.
+ // GCC used to do this only when the compiler itself runs on windows, but
+ // since GCC 8 it does the same when cross compiling as well.
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
diff --git a/clang/test/Driver/mingw-implicit-extension-cross.c b/clang/test/Driver/mingw-implicit-extension-cross.c
deleted file mode 100644
index 2cf24dcb8a57..000000000000
--- a/clang/test/Driver/mingw-implicit-extension-cross.c
+++ /dev/null
@@ -1,9 +0,0 @@
-// 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"
diff --git a/clang/test/Driver/mingw-implicit-extension-windows.c b/clang/test/Driver/mingw-implicit-extension-windows.c
index 9c60308b142e..bc15f6abb266 100644
--- a/clang/test/Driver/mingw-implicit-extension-windows.c
+++ b/clang/test/Driver/mingw-implicit-extension-windows.c
@@ -1,8 +1,4 @@
-// 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
+// Test how an implicit .exe extension is added.
// 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
More information about the cfe-commits
mailing list