Index: lld/trunk/MinGW/Driver.cpp =================================================================== --- lld/trunk/MinGW/Driver.cpp +++ lld/trunk/MinGW/Driver.cpp @@ -181,8 +181,31 @@ 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)) Index: lld/trunk/MinGW/Options.td =================================================================== --- lld/trunk/MinGW/Options.td +++ lld/trunk/MinGW/Options.td @@ -25,8 +25,24 @@ def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"">, 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; +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; def map: S<"Map">, HelpText<"Output a linker map">; def map_eq: J<"Map=">, Alias; +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; +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; def no_insert_timestamp: F<"no-insert-timestamp">, HelpText<"Don't include PE header timestamp">; def no_whole_archive: F<"no-whole-archive">, Index: lld/trunk/test/MinGW/driver.test =================================================================== --- lld/trunk/test/MinGW/driver.test +++ lld/trunk/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