[PATCH] D88803: [LLD] [MinGW] Simplify handling of os/subsystem version
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 4 13:04:33 PDT 2020
mstorsjo created this revision.
mstorsjo added reviewers: rnk, ruiu.
Herald added a project: LLVM.
mstorsjo requested review of this revision.
As they can be set independently after D88802 <https://reviews.llvm.org/D88802>, we can get rid of a bit of extra code - simplifying the logic here before adding more complication to it later.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88803
Files:
lld/COFF/Config.h
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
@@ -63,18 +63,21 @@
RUN: ld.lld -### foo.o -m i386pep --subsystem=console | FileCheck -check-prefix=SUBSYSTEM %s
SUBSYSTEM: -subsystem:console
-RUN: ld.lld -### foo.o -m i386pep --major-os-version 7 --minor-os-version 8 | FileCheck -check-prefix=SUBSYSTEM_VERSION %s
+RUN: ld.lld -### foo.o -m i386pep --major-os-version 7 --minor-os-version 8 | FileCheck -check-prefix=OS_VERSION %s
+RUN: ld.lld -### foo.o -m i386pep --major-os-version=7 --minor-os-version=8 | FileCheck -check-prefix=OS_VERSION %s
+OS_VERSION: -osversion:7.8 -subsystem:default,6.0
+
RUN: ld.lld -### foo.o -m i386pep --major-subsystem-version 7 --minor-subsystem-version 8 | FileCheck -check-prefix=SUBSYSTEM_VERSION %s
-RUN: ld.lld -### foo.o -m i386pep --major-os-version=7 --minor-os-version=8 --major-subsystem-version=7 --minor-subsystem-version=8 | FileCheck -check-prefix=SUBSYSTEM_VERSION %s
-SUBSYSTEM_VERSION: -subsystem:default,7.8
+RUN: ld.lld -### foo.o -m i386pep --major-subsystem-version=7 --minor-subsystem-version=8 | FileCheck -check-prefix=SUBSYSTEM_VERSION %s
+SUBSYSTEM_VERSION: -osversion:6.0 -subsystem:default,7.8
RUN: ld.lld -### foo.o -m i386pep --minor-subsystem-version 8 | FileCheck -check-prefix=SUBSYSTEM_DEFAULT_MAJOR %s
SUBSYSTEM_DEFAULT_MAJOR: -subsystem:default,6.8
RUN: ld.lld -### foo.o -m i386pep --major-subsystem-version 7 | FileCheck -check-prefix=SUBSYSTEM_DEFAULT_MINOR %s
-SUBSYSTEM_DEFAULT_MINOR: -subsystem:default,7
+SUBSYSTEM_DEFAULT_MINOR: -subsystem:default,7.0
-RUN: ld.lld -### foo.o -m i386pep --subsystem windows --major-os-version 7 --minor-os-version 8 | FileCheck -check-prefix=SUBSYSTEM_WINDOWS %s
+RUN: ld.lld -### foo.o -m i386pep --subsystem windows --major-subsystem-version 7 --minor-subsystem-version 8 | 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
@@ -214,25 +214,13 @@
if (args.hasArg(OPT_major_os_version, OPT_minor_os_version,
OPT_major_subsystem_version, OPT_minor_subsystem_version)) {
- auto *majOSVer = args.getLastArg(OPT_major_os_version);
- auto *minOSVer = args.getLastArg(OPT_minor_os_version);
- auto *majSubSysVer = args.getLastArg(OPT_major_subsystem_version);
- auto *minSubSysVer = args.getLastArg(OPT_minor_subsystem_version);
- if (majOSVer && majSubSysVer &&
- StringRef(majOSVer->getValue()) != StringRef(majSubSysVer->getValue()))
- warn("--major-os-version and --major-subsystem-version set to differing "
- "versions, not supported");
- if (minOSVer && minSubSysVer &&
- StringRef(minOSVer->getValue()) != StringRef(minSubSysVer->getValue()))
- warn("--minor-os-version and --minor-subsystem-version set to differing "
- "versions, not supported");
+ 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 major = majOSVer ? majOSVer->getValue()
- : majSubSysVer ? majSubSysVer->getValue() : "6";
- StringRef minor = minOSVer ? minOSVer->getValue()
- : minSubSysVer ? minSubSysVer->getValue() : "";
- StringRef sep = minor.empty() ? "" : ".";
- add("-subsystem:" + subSys + "," + major + sep + minor);
+ add("-osversion:" + majOSVer + "." + minOSVer);
+ add("-subsystem:" + subSys + "," + majSubSysVer + "." + minSubSysVer);
} else if (auto *a = args.getLastArg(OPT_subs)) {
add("-subsystem:" + StringRef(a->getValue()));
}
Index: lld/COFF/Config.h
===================================================================
--- lld/COFF/Config.h
+++ lld/COFF/Config.h
@@ -221,6 +221,8 @@
uint64_t heapCommit = 4096;
uint32_t majorImageVersion = 0;
uint32_t minorImageVersion = 0;
+ // If changing the default os/subsys version here, update the default in
+ // the MinGW driver accordingly.
uint32_t majorOSVersion = 6;
uint32_t minorOSVersion = 0;
uint32_t majorSubsystemVersion = 6;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88803.296073.patch
Type: text/x-patch
Size: 4637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201004/e955e17b/attachment.bin>
More information about the llvm-commits
mailing list