Index: lld/COFF/Driver.cpp =================================================================== --- lld/COFF/Driver.cpp +++ lld/COFF/Driver.cpp @@ -1739,6 +1739,20 @@ config->incremental = false; } + // Print a warning message for those flags that aren't supported by LLD + // but can be ignored due to MS-LINK + for (auto *arg : args) { + + auto argOption = arg->getOption(); + if (!argOption.isValid()) + continue; + + auto argOptionGroup = argOption.getGroup(); + if (argOptionGroup.isValid() && + argOptionGroup.getID() == OPT_lldWarnMessageGroup) + warn("ignoring unknown argument \'" + argOption.getPrefixedName() + "\'"); + } + if (errorCount()) return; Index: lld/COFF/Options.td =================================================================== --- lld/COFF/Options.td +++ lld/COFF/Options.td @@ -285,3 +285,33 @@ def tlbout : QF<"tlbout">; def verbose_all : QF<"verbose">; def guardsym : QF<"guardsym">; + +//============================================================================= +// Using the flags below will cause a warning to be printed saying that they +// will be ignored. This is for compatibility with MS LINK. +// +// If the flag doesn't need an extra arguments +// def NAME_OF_OPTION : lldWarnMessage<"NAME_OF_OPTION"> +// +// If the flag does need an extra argument +// def NAME_OF_OPTION : lldWarnMessageArgs<"NAME_OF_OPTION"> +// +// If the flag has both options (with and without extra arguments) then both +// forms need to be added. +//============================================================================= + +// Define the lldWarnMessageGroup group. This group is used to identify +// all the flags that we want to print the warning message. +def lldWarnMessageGroup : OptionGroup<"lldWarnMessageGroup">; + +// Class for options that won't require extra arguments +class lldWarnMessage : F { + OptionGroup Group = lldWarnMessageGroup; +} + +// Class for options that require an extra argument +class lldWarnMessageArgs : QF { + OptionGroup Group = lldWarnMessageGroup; +} + +def assemblydebug : lldWarnMessage<"assemblydebug">; Index: lld/test/COFF/ignore-option-message.ll =================================================================== --- /dev/null +++ lld/test/COFF/ignore-option-message.ll @@ -0,0 +1,23 @@ +; This test checks that the option /ASSEMBLYDEBUG causes a warning to be +; printed and is then ignored. + +; RUN: llc %s -o %t.obj -filetype=obj + +; Check that the /ASSEMBLYDEBUG flag is ignored +; RUN: not lld-link /subsystem:console /ASSEMBLYDEBUG %t.obj 2>&1 | FileCheck -check-prefix=CHECKAD -allow-empty %s +; CHECKAD: warning: ignoring unknown argument '/assemblydebug' +; CHECKAD-NOT: could not open '/ASSEMBLYDEBUG' + +; Check that the /assemblydebug flag is ignored +; RUN: not lld-link /subsystem:console /assemblydebug %t.obj 2>&1 | FileCheck -check-prefix=CHECKAD2 -allow-empty %s +; CHECKAD2: warning: ignoring unknown argument '/assemblydebug' +; CHECKAD2-NOT: could not open '/assemblydebug' + +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc" + +define internal i32 @add(i32 %a) { +entry: + %add = add nsw i32 %a, 2 + ret i32 %add +}