Index: COFF/Config.h =================================================================== --- COFF/Config.h +++ COFF/Config.h @@ -130,7 +130,7 @@ std::map Section; // Options for manifest files. - ManifestKind Manifest = SideBySide; + ManifestKind Manifest = No; int ManifestID = 1; StringRef ManifestDependency; bool ManifestUAC = true; Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -899,18 +899,25 @@ for (auto *Arg : Args.filtered(OPT_section)) parseSection(Arg->getValue()); - // Handle /manifest - if (auto *Arg = Args.getLastArg(OPT_manifest_colon)) - parseManifest(Arg->getValue()); + // Handle /manifestdependency. This enables /manifest unless /manifest:no is + // also passed. + if (auto *Arg = Args.getLastArg(OPT_manifestdependency)) { + Config->ManifestDependency = Arg->getValue(); + Config->Manifest = Configuration::SideBySide; + } + + // Handle /manifest and /manifest: + if (auto *Arg = Args.getLastArg(OPT_manifest, OPT_manifest_colon)) { + if (Arg->getOption().getID() == OPT_manifest) + Config->Manifest = Configuration::SideBySide; + else + parseManifest(Arg->getValue()); + } // Handle /manifestuac if (auto *Arg = Args.getLastArg(OPT_manifestuac)) parseManifestUAC(Arg->getValue()); - // Handle /manifestdependency - if (auto *Arg = Args.getLastArg(OPT_manifestdependency)) - Config->ManifestDependency = Arg->getValue(); - // Handle /manifestfile if (auto *Arg = Args.getLastArg(OPT_manifestfile)) Config->ManifestFile = Arg->getValue(); @@ -919,6 +926,11 @@ for (auto *Arg : Args.filtered(OPT_manifestinput)) Config->ManifestInput.push_back(Arg->getValue()); + if (!Config->ManifestInput.empty() && + Config->Manifest != Configuration::Embed) { + fatal("/MANIFESTINPUT: requires /MANIFEST:EMBED"); + } + // Handle miscellaneous boolean flags. if (Args.hasArg(OPT_allowisolation_no)) Config->AllowIsolation = false; Index: test/COFF/manifest.test =================================================================== --- test/COFF/manifest.test +++ test/COFF/manifest.test @@ -1,6 +1,10 @@ # RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj +# RUN: rm -f %t.exe.manifest # RUN: lld-link /out:%t.exe /entry:main %t.obj +# RUN: test ! -e %t.exe.manifest + +# RUN: lld-link /manifest /out:%t.exe /entry:main %t.obj # RUN: FileCheck -check-prefix=MANIFEST %s < %t.exe.manifest MANIFEST: @@ -15,7 +19,7 @@ MANIFEST: MANIFEST: -# RUN: lld-link /out:%t.exe /entry:main \ +# RUN: lld-link /out:%t.exe /entry:main /manifest \ # RUN: /manifestuac:"level='requireAdministrator' uiAccess='true'" %t.obj # RUN: FileCheck -check-prefix=UAC %s < %t.exe.manifest @@ -31,6 +35,7 @@ UAC: UAC: +# /manifestdependency implies /manifest. (/manifestuac doesn't.) # RUN: lld-link /out:%t.exe /entry:main \ # RUN: /manifestdependency:"foo='bar'" %t.obj # RUN: FileCheck -check-prefix=DEPENDENCY %s < %t.exe.manifest @@ -52,7 +57,7 @@ DEPENDENCY: DEPENDENCY: -# RUN: lld-link /out:%t.exe /entry:main /manifestuac:no %t.obj +# RUN: lld-link /manifest /out:%t.exe /entry:main /manifestuac:no %t.obj # RUN: FileCheck -check-prefix=NOUAC %s < %t.exe.manifest NOUAC: Index: test/COFF/manifestinput.test =================================================================== --- test/COFF/manifestinput.test +++ test/COFF/manifestinput.test @@ -1,7 +1,7 @@ # REQUIRES: win_mt # RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj -# RUN: lld-link /out:%t.exe /entry:main \ +# RUN: lld-link /out:%t.exe /entry:main /manifest \ # RUN: /manifestuac:"level='requireAdministrator'" \ # RUN: /manifestinput:%p/Inputs/manifestinput.test %t.obj # RUN: FileCheck %s < %t.exe.manifest