[lld] bc8f3b4 - [LLD] [MinGW] Simplify handling of os/subsystem version
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 13:08:52 PDT 2020
Author: Martin Storsjö
Date: 2020-10-05T23:08:02+03:00
New Revision: bc8f3b424c7785754c1de8a2f5a1e2c16a997143
URL: https://github.com/llvm/llvm-project/commit/bc8f3b424c7785754c1de8a2f5a1e2c16a997143
DIFF: https://github.com/llvm/llvm-project/commit/bc8f3b424c7785754c1de8a2f5a1e2c16a997143.diff
LOG: [LLD] [MinGW] Simplify handling of os/subsystem version
As they can be set independently after D88802, we can get rid of a bit
of extra code - simplifying the logic here before adding more
complication to it later.
Differential Revision: https://reviews.llvm.org/D88803
Added:
Modified:
lld/COFF/Config.h
lld/MinGW/Driver.cpp
lld/test/MinGW/driver.test
Removed:
################################################################################
diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h
index f0a26c19e955..77a08c200da2 100644
--- a/lld/COFF/Config.h
+++ b/lld/COFF/Config.h
@@ -221,6 +221,8 @@ struct Configuration {
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;
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index af7ecb8801e9..d976e4cc75fb 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -214,25 +214,13 @@ bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
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
diff ering "
- "versions, not supported");
- if (minOSVer && minSubSysVer &&
- StringRef(minOSVer->getValue()) != StringRef(minSubSysVer->getValue()))
- warn("--minor-os-version and --minor-subsystem-version set to
diff ering "
- "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()));
}
diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index c9fa6ea9f97d..fdf5a29d6d0d 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -63,18 +63,21 @@ RUN: ld.lld -### foo.o -m i386pep -subsystem=console | FileCheck -check-prefix=S
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
More information about the llvm-commits
mailing list