[PATCH] D88804: [LLD] [MinGW] Support setting the subsystem version via the subsystem argument
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 13:09:02 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61e2f9fa2e51: [LLD] [MinGW] Support setting the subsystem version via the subsystem argument (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88804/new/
https://reviews.llvm.org/D88804
Files:
lld/MinGW/Driver.cpp
lld/test/MinGW/driver.test
Index: lld/test/MinGW/driver.test
===================================================================
--- lld/test/MinGW/driver.test
+++ lld/test/MinGW/driver.test
@@ -78,6 +78,12 @@
SUBSYSTEM_DEFAULT_MINOR: -subsystem:default,7.0
RUN: ld.lld -### foo.o -m i386pep --subsystem windows --major-subsystem-version 7 --minor-subsystem-version 8 | FileCheck -check-prefix=SUBSYSTEM_WINDOWS %s
+RUN: ld.lld -### foo.o -m i386pep --major-subsystem-version 7 --minor-subsystem-version 8 --subsystem windows | FileCheck -check-prefix=SUBSYSTEM_WINDOWS %s
+RUN: ld.lld -### foo.o -m i386pep --subsystem windows:7.8 | FileCheck -check-prefix=SUBSYSTEM_WINDOWS %s
+RUN: ld.lld -### foo.o -m i386pep --subsystem windows:2.3 --major-subsystem-version 7 --minor-subsystem-version 8 | FileCheck -check-prefix=SUBSYSTEM_WINDOWS %s
+RUN: ld.lld -### foo.o -m i386pep --subsystem windows:7.8 | FileCheck -check-prefix=SUBSYSTEM_WINDOWS %s
+RUN: ld.lld -### foo.o -m i386pep --major-subsystem-version 2 --minor-subsystem-version 3 --subsystem windows:7.8 | FileCheck -check-prefix=SUBSYSTEM_WINDOWS %s
+RUN: ld.lld -### foo.o -m i386pep --major-subsystem-version 2 --minor-subsystem-version 8 --subsystem windows:7 | FileCheck -check-prefix=SUBSYSTEM_WINDOWS %s
SUBSYSTEM_WINDOWS: -subsystem:windows,7.8
RUN: ld.lld -### foo.o -m i386pep -stack 4194304,8192 | FileCheck -check-prefix=STACK %s
Index: lld/MinGW/Driver.cpp
===================================================================
--- lld/MinGW/Driver.cpp
+++ lld/MinGW/Driver.cpp
@@ -216,13 +216,41 @@
OPT_major_subsystem_version, OPT_minor_subsystem_version)) {
StringRef majOSVer = args.getLastArgValue(OPT_major_os_version, "6");
StringRef minOSVer = args.getLastArgValue(OPT_minor_os_version, "0");
- StringRef majSubSysVer = args.getLastArgValue(OPT_major_subsystem_version, "6");
- StringRef minSubSysVer = args.getLastArgValue(OPT_minor_subsystem_version, "0");
- StringRef subSys = args.getLastArgValue(OPT_subs, "default");
+ StringRef majSubSysVer = "6";
+ StringRef minSubSysVer = "0";
+ StringRef subSysName = "default";
+ StringRef subSysVer;
+ // Iterate over --{major,minor}-subsystem-version and --subsystem, and pick
+ // the version number components from the last one of them that specifies
+ // a version.
+ for (auto *a : args.filtered(OPT_major_subsystem_version,
+ OPT_minor_subsystem_version, OPT_subs)) {
+ switch (a->getOption().getID()) {
+ case OPT_major_subsystem_version:
+ majSubSysVer = a->getValue();
+ break;
+ case OPT_minor_subsystem_version:
+ minSubSysVer = a->getValue();
+ break;
+ case OPT_subs:
+ std::tie(subSysName, subSysVer) = StringRef(a->getValue()).split(':');
+ if (!subSysVer.empty()) {
+ if (subSysVer.contains('.'))
+ std::tie(majSubSysVer, minSubSysVer) = subSysVer.split('.');
+ else
+ majSubSysVer = subSysVer;
+ }
+ break;
+ }
+ }
add("-osversion:" + majOSVer + "." + minOSVer);
- add("-subsystem:" + subSys + "," + majSubSysVer + "." + minSubSysVer);
- } else if (auto *a = args.getLastArg(OPT_subs)) {
- add("-subsystem:" + StringRef(a->getValue()));
+ add("-subsystem:" + subSysName + "," + majSubSysVer + "." + minSubSysVer);
+ } else if (args.hasArg(OPT_subs)) {
+ StringRef subSys = args.getLastArgValue(OPT_subs, "default");
+ StringRef subSysName, subSysVer;
+ std::tie(subSysName, subSysVer) = subSys.split(':');
+ StringRef sep = subSysVer.empty() ? "" : ",";
+ add("-subsystem:" + subSysName + sep + subSysVer);
}
if (auto *a = args.getLastArg(OPT_out_implib))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88804.296277.patch
Type: text/x-patch
Size: 3733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201005/45002feb/attachment.bin>
More information about the llvm-commits
mailing list