[lld] r363432 - [MinGW] Support the --{major, minor}-{os, subsystem}-version options
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 10:50:35 PDT 2019
Author: mstorsjo
Date: Fri Jun 14 10:50:35 2019
New Revision: 363432
URL: http://llvm.org/viewvc/llvm-project?rev=363432&view=rev
Log:
[MinGW] Support the --{major,minor}-{os,subsystem}-version options
This fixes PR42218.
Differential Revision: https://reviews.llvm.org/D63249
Modified:
lld/trunk/MinGW/Driver.cpp
lld/trunk/MinGW/Options.td
lld/trunk/test/MinGW/driver.test
Modified: lld/trunk/MinGW/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Driver.cpp?rev=363432&r1=363431&r2=363432&view=diff
==============================================================================
--- lld/trunk/MinGW/Driver.cpp (original)
+++ lld/trunk/MinGW/Driver.cpp Fri Jun 14 10:50:35 2019
@@ -181,8 +181,31 @@ bool mingw::link(ArrayRef<const char *>
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))
Modified: lld/trunk/MinGW/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Options.td?rev=363432&r1=363431&r2=363432&view=diff
==============================================================================
--- lld/trunk/MinGW/Options.td (original)
+++ lld/trunk/MinGW/Options.td Fri Jun 14 10:50:35 2019
@@ -25,8 +25,24 @@ def kill_at: F<"kill-at">, HelpText<"Rem
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">,
Modified: lld/trunk/test/MinGW/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/MinGW/driver.test?rev=363432&r1=363431&r2=363432&view=diff
==============================================================================
--- lld/trunk/test/MinGW/driver.test (original)
+++ lld/trunk/test/MinGW/driver.test Fri Jun 14 10:50:35 2019
@@ -59,6 +59,20 @@ RUN: ld.lld -### foo.o -m i386pep -subsy
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
More information about the llvm-commits
mailing list