diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h --- a/lld/COFF/Config.h +++ b/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; diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp --- a/lld/MinGW/Driver.cpp +++ b/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())); } diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test --- 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=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