[PATCH] D63249: [LLD] [MinGW] Support the --{major,minor}-{os,subsystem}-version options
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 03:48:06 PDT 2019
mstorsjo created this revision.
mstorsjo added reviewers: ruiu, rnk.
Herald added a project: LLVM.
This fixes PR42218.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D63249
Files:
MinGW/Driver.cpp
MinGW/Options.td
test/MinGW/driver.test
Index: test/MinGW/driver.test
===================================================================
--- test/MinGW/driver.test
+++ test/MinGW/driver.test
@@ -59,6 +59,20 @@
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-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 --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
+
+RUN: ld.lld -### foo.o -m i386pep --subsystem windows --major-os-version 7 --minor-os-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
RUN: ld.lld -### foo.o -m i386pep --stack 4194304,8192 | FileCheck -check-prefix=STACK %s
STACK: -stack:4194304,8192
Index: MinGW/Options.td
===================================================================
--- MinGW/Options.td
+++ MinGW/Options.td
@@ -25,8 +25,24 @@
def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
HelpText<"Root name of library to use">;
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
+def major_os_version: Separate<["--"], "major-os-version">,
+ HelpText<"Set the OS and subsystem major version">;
+def major_os_version_eq: Joined<["--"], "major-os-version=">,
+ Alias<major_os_version>;
+def major_subsystem_version: Separate<["--"], "major-subsystem-version">,
+ HelpText<"Set the OS and subsystem major version">;
+def major_subsystem_version_eq: Joined<["--"], "major-subsystem-version=">,
+ Alias<major_subsystem_version>;
def map: S<"Map">, HelpText<"Output a linker map">;
def map_eq: J<"Map=">, Alias<map>;
+def minor_os_version: Separate<["--"], "minor-os-version">,
+ HelpText<"Set the OS and subsystem minor version">;
+def minor_os_version_eq: Joined<["--"], "minor-os-version=">,
+ Alias<minor_os_version>;
+def minor_subsystem_version: Separate<["--"], "minor-subsystem-version">,
+ HelpText<"Set the OS and subsystem minor version">;
+def minor_subsystem_version_eq: Joined<["--"], "minor-subsystem-version=">,
+ Alias<minor_subsystem_version>;
def no_insert_timestamp: F<"no-insert-timestamp">,
HelpText<"Don't include PE header timestamp">;
def no_whole_archive: F<"no-whole-archive">,
Index: MinGW/Driver.cpp
===================================================================
--- MinGW/Driver.cpp
+++ MinGW/Driver.cpp
@@ -181,8 +181,30 @@
Add("-entry:" + S);
}
- if (auto *A = Args.getLastArg(OPT_subs))
+ 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 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);
+ } else if (auto *A = Args.getLastArg(OPT_subs))
Add("-subsystem:" + StringRef(A->getValue()));
+
if (auto *A = Args.getLastArg(OPT_out_implib))
Add("-implib:" + StringRef(A->getValue()));
if (auto *A = Args.getLastArg(OPT_stack))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63249.204477.patch
Type: text/x-patch
Size: 4817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190613/08a33425/attachment.bin>
More information about the llvm-commits
mailing list