[PATCH] D107261: [clang] [MinGW] Let the last of -mconsole/-mwindows have effect
Martin Storsjö via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 2 03:55:27 PDT 2021
mstorsjo created this revision.
mstorsjo added reviewers: rnk, mati865, jeremyd2019.
mstorsjo requested review of this revision.
Herald added a project: clang.
Don't just check for the existence of one, but check which one was
specified last, if any.
This fixes https://llvm.org/PR51296.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D107261
Files:
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw.cpp
Index: clang/test/Driver/mingw.cpp
===================================================================
--- clang/test/Driver/mingw.cpp
+++ 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"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===================================================================
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -136,10 +136,13 @@
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");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107261.363431.patch
Type: text/x-patch
Size: 1671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210802/68438e03/attachment-0001.bin>
More information about the cfe-commits
mailing list