[PATCH] D94610: [LLD][COFF] Print a warning message for ignored options in lld-link
Axel Y. Rivera via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 13 09:13:31 PST 2021
ayrivera created this revision.
ayrivera added reviewers: ruiu, andrew.w.kaylor.
Herald added a subscriber: dang.
ayrivera requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This change set adds a new group of linker options (lldWarnMessageGroup) for LLD COFF driver to handle those flags that aren't supported by lld-link but can be ignore due to compatibility with MS-LINK. LLD will print a warning message saying that the option will be ignored.
Also, the change set adds the option /ASSEMBLYDEBUG.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94610
Files:
lld/COFF/Driver.cpp
lld/COFF/Options.td
lld/test/COFF/ignore-option-message.ll
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
+}
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<string name> : F<name> {
+ OptionGroup Group = lldWarnMessageGroup;
+}
+
+// Class for options that require an extra argument
+class lldWarnMessageArgs<string name> : QF<name> {
+ OptionGroup Group = lldWarnMessageGroup;
+}
+
+def assemblydebug : lldWarnMessage<"assemblydebug">;
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1739,6 +1739,21 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94610.316422.patch
Type: text/x-patch
Size: 3295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210113/35561bdb/attachment.bin>
More information about the llvm-commits
mailing list