[llvm-branch-commits] [clang] 58811fd - [clang] [MinGW] Let the last of -mconsole/-mwindows have effect
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Aug 9 23:23:37 PDT 2021
Author: Martin Storsjö
Date: 2021-08-09T23:23:11-07:00
New Revision: 58811fd0f7312b5f6dffd6a252bc1d68e25cfa01
URL: https://github.com/llvm/llvm-project/commit/58811fd0f7312b5f6dffd6a252bc1d68e25cfa01
DIFF: https://github.com/llvm/llvm-project/commit/58811fd0f7312b5f6dffd6a252bc1d68e25cfa01.diff
LOG: [clang] [MinGW] Let the last of -mconsole/-mwindows have effect
Don't just check for the existence of one, but check which one was
specified last, if any.
This fixes https://llvm.org/PR51296.
Differential Revision: https://reviews.llvm.org/D107261
(cherry picked from commit ce49fd024b43bd76b149f984b8f0d16e92b9bb06)
Added:
Modified:
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index 20efbdc237a84..7ba729f36bd87 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -136,10 +136,13 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
llvm_unreachable("Unsupported target architecture.");
}
- if (Args.hasArg(options::OPT_mwindows)) {
+ Arg *SubsysArg =
+ Args.getLastArg(options::OPT_mwindows, options::OPT_mconsole);
+ if (SubsysArg && SubsysArg->getOption().matches(options::OPT_mwindows)) {
CmdArgs.push_back("--subsystem");
CmdArgs.push_back("windows");
- } else if (Args.hasArg(options::OPT_mconsole)) {
+ } else if (SubsysArg &&
+ SubsysArg->getOption().matches(options::OPT_mconsole)) {
CmdArgs.push_back("--subsystem");
CmdArgs.push_back("console");
}
diff --git a/clang/test/Driver/mingw.cpp b/clang/test/Driver/mingw.cpp
index 796bde8eebe4c..83b61ba7d33f0 100644
--- a/clang/test/Driver/mingw.cpp
+++ b/clang/test/Driver/mingw.cpp
@@ -61,3 +61,10 @@
// RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck -check-prefix=CHECK_MINGW_UNICODE %s
// CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
// CHECK_MINGW_UNICODE: "-DUNICODE"
+
+// RUN: %clang -target i686-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_NO_SUBSYS %s
+// RUN: %clang -target i686-windows-gnu -### %s -mwindows -mconsole 2>&1 | FileCheck -check-prefix=CHECK_SUBSYS_CONSOLE %s
+// RUN: %clang -target i686-windows-gnu -### %s -mconsole -mwindows 2>&1 | FileCheck -check-prefix=CHECK_SUBSYS_WINDOWS %s
+// CHECK_NO_SUBSYS-NOT: "--subsystem"
+// CHECK_SUBSYS_CONSOLE: "--subsystem" "console"
+// CHECK_SUBSYS_WINDOWS: "--subsystem" "windows"
More information about the llvm-branch-commits
mailing list