Skip to content

Commit 4b81e9f

Browse files
committed
lld-link: Allow /? as option prefix, like -? is allowed
link.exe seems to allow `/?foo` and `-?foo` in addition to `/foo` and `-foo`. Since lld-link already supports the `-?foo` spelling, support `/?foo` as well. Differential Revision: https://reviews.llvm.org/D61375 llvm-svn: 360150
1 parent 07298c9 commit 4b81e9f

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lld/COFF/Options.td

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ include "llvm/Option/OptParser.td"
33
// link.exe accepts options starting with either a dash or a slash.
44

55
// Flag that takes no arguments.
6-
class F<string name> : Flag<["/", "-", "-?"], name>;
6+
class F<string name> : Flag<["/", "-", "/?", "-?"], name>;
77

88
// Flag that takes one argument after ":".
99
class P<string name, string help> :
10-
Joined<["/", "-", "-?"], name#":">, HelpText<help>;
10+
Joined<["/", "-", "/?", "-?"], name#":">, HelpText<help>;
1111

1212
// Boolean flag which can be suffixed by ":no". Using it unsuffixed turns the
1313
// flag on and using it suffixed by ":no" turns it off.
@@ -66,7 +66,8 @@ def timestamp : P<"timestamp", "Specify the PE header timestamp">;
6666
def version : P<"version", "Specify a version number in the PE header">;
6767
def wholearchive_file : P<"wholearchive", "Include all object files from this archive">;
6868

69-
def disallowlib : Joined<["/", "-", "-?"], "disallowlib:">, Alias<nodefaultlib>;
69+
def disallowlib : Joined<["/", "-", "/?", "-?"], "disallowlib:">,
70+
Alias<nodefaultlib>;
7071

7172
def manifest : F<"manifest">, HelpText<"Create .manifest file">;
7273
def manifest_colon : P<
@@ -84,11 +85,11 @@ def manifestinput : P<
8485
// We cannot use multiclass P because class name "incl" is different
8586
// from its command line option name. We do this because "include" is
8687
// a reserved keyword in tablegen.
87-
def incl : Joined<["/", "-"], "include:">,
88+
def incl : Joined<["/", "-", "/?", "-?"], "include:">,
8889
HelpText<"Force symbol to be added to symbol table as undefined one">;
8990

9091
// "def" is also a keyword.
91-
def deffile : Joined<["/", "-"], "def:">,
92+
def deffile : Joined<["/", "-", "/?", "-?"], "def:">,
9293
HelpText<"Use module-definition file">;
9394

9495
def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;
@@ -155,7 +156,9 @@ defm tsaware : B<"tsaware",
155156
"Create non-Terminal Server aware executable">;
156157

157158
def help : F<"help">;
158-
def help_q : Flag<["/?", "-?"], "">, Alias<help>;
159+
160+
// /?? and -?? must be before /? and -? to not confuse lib/Options.
161+
def help_q : Flag<["/??", "-??", "/?", "-?"], "">, Alias<help>;
159162

160163
// LLD extensions
161164
def exclude_all_symbols : F<"exclude-all-symbols">;
@@ -165,7 +168,7 @@ defm demangle : B<"demangle",
165168
"Do not demangle symbols in output">;
166169
def kill_at : F<"kill-at">;
167170
def lldmingw : F<"lldmingw">;
168-
def output_def : Joined<["/", "-"], "output-def:">;
171+
def output_def : Joined<["/", "-", "/?", "-?"], "output-def:">;
169172
def pdb_source_path : P<"pdbsourcepath",
170173
"Base path used to make relative source file path absolute in PDB">;
171174
def rsp_quoting : Joined<["--"], "rsp-quoting=">,
@@ -178,15 +181,15 @@ defm threads: B<"threads",
178181

179182
// Flags for debugging
180183
def lldmap : F<"lldmap">;
181-
def lldmap_file : Joined<["/", "-"], "lldmap:">;
184+
def lldmap_file : Joined<["/", "-", "/?", "-?"], "lldmap:">;
182185
def show_timing : F<"time">;
183186
def summary : F<"summary">;
184187

185188
//==============================================================================
186189
// The flags below do nothing. They are defined only for link.exe compatibility.
187190
//==============================================================================
188191

189-
class QF<string name> : Joined<["/", "-", "-?"], name#":">;
192+
class QF<string name> : Joined<["/", "-", "/?", "-?"], name#":">;
190193

191194
def ignoreidl : F<"ignoreidl">;
192195
def nologo : F<"nologo">;

0 commit comments

Comments
 (0)