Index: lld/trunk/COFF/DriverUtils.cpp =================================================================== --- lld/trunk/COFF/DriverUtils.cpp +++ lld/trunk/COFF/DriverUtils.cpp @@ -114,9 +114,11 @@ uint32_t *Minor) { StringRef SysStr, Ver; std::tie(SysStr, Ver) = Arg.split(','); - *Sys = StringSwitch(SysStr.lower()) + std::string SysStrLower = SysStr.lower(); + *Sys = StringSwitch(SysStrLower) .Case("boot_application", IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION) .Case("console", IMAGE_SUBSYSTEM_WINDOWS_CUI) + .Case("default", IMAGE_SUBSYSTEM_UNKNOWN) .Case("efi_application", IMAGE_SUBSYSTEM_EFI_APPLICATION) .Case("efi_boot_service_driver", IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) .Case("efi_rom", IMAGE_SUBSYSTEM_EFI_ROM) @@ -125,7 +127,7 @@ .Case("posix", IMAGE_SUBSYSTEM_POSIX_CUI) .Case("windows", IMAGE_SUBSYSTEM_WINDOWS_GUI) .Default(IMAGE_SUBSYSTEM_UNKNOWN); - if (*Sys == IMAGE_SUBSYSTEM_UNKNOWN) + if (*Sys == IMAGE_SUBSYSTEM_UNKNOWN && SysStrLower != "default") fatal("unknown subsystem: " + SysStr); if (!Ver.empty()) parseVersion(Ver, Major, Minor); Index: lld/trunk/test/COFF/subsystem-inference.test =================================================================== --- lld/trunk/test/COFF/subsystem-inference.test +++ lld/trunk/test/COFF/subsystem-inference.test @@ -1,6 +1,8 @@ # RUN: sed -e s/ENTRYNAME/main/ %s | yaml2obj > %t.obj # RUN: lld-link /out:%t.exe %t.obj # RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=MAIN %s +# RUN: lld-link /out:%t.exe %t.obj /subsystem:default,6.0 +# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=MAIN %s # RUN: sed s/ENTRYNAME/wmain/ %s | yaml2obj > %t.obj # RUN: lld-link /out:%t.exe %t.obj @@ -9,6 +11,8 @@ # RUN: sed s/ENTRYNAME/WinMain/ %s | yaml2obj > %t.obj # RUN: lld-link /out:%t.exe %t.obj # RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=WINMAIN %s +# RUN: lld-link /out:%t.exe %t.obj /subsystem:default,6.0 +# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=WINMAIN %s # RUN: sed s/ENTRYNAME/wWinMain/ %s | yaml2obj > %t.obj # RUN: lld-link /out:%t.exe %t.obj Index: lld/trunk/test/COFF/subsystem.test =================================================================== --- lld/trunk/test/COFF/subsystem.test +++ lld/trunk/test/COFF/subsystem.test @@ -17,3 +17,12 @@ CHECK2: MajorSubsystemVersion: 8 CHECK2: MinorSubsystemVersion: 9 CHECK2: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI + +# RUN: lld-link /entry:main /out:%t.exe /subsystem:default,8.9 \ +# RUN: %p/Inputs/ret42.obj +# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=CHECK3 %s + +CHECK3: MajorOperatingSystemVersion: 8 +CHECK3: MinorOperatingSystemVersion: 9 +CHECK3: MajorSubsystemVersion: 8 +CHECK3: MinorSubsystemVersion: 9