Skip to content

Commit

Permalink
[binutils] Add response file option to help and docs
Browse files Browse the repository at this point in the history
Many LLVM-based tools already support response files (i.e. files
containing a list of options, specified with '@'). This change simply
updates the documentation and help text for some of these tools to
include it. I haven't attempted to fix all tools, just a selection that
I am interested in.

I've taken the opportunity to add some tests for --help behaviour, where
they were missing. We could expand these tests, but I don't think that's
within scope of this patch.

This fixes https://bugs.llvm.org/show_bug.cgi?id=42233 and
https://bugs.llvm.org/show_bug.cgi?id=42236.

Reviewed by: grimar, MaskRay, jkorous

Differential Revision: https://reviews.llvm.org/D63597

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364036 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
jh7370 committed Jun 21, 2019
1 parent 7b04de6 commit b7bdff9
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/CommandGuide/llvm-nm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ OPTIONS
Specify the radix of the symbol address(es). Values accepted d(decimal),
x(hexadecimal) and o(octal).

.. option:: @<FILE>

Read command-line options from response file `<FILE>`.

BUGS
----

Expand Down
4 changes: 4 additions & 0 deletions docs/CommandGuide/llvm-objdump.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ MACH-O ONLY OPTIONS AND COMMANDS

Display weak binding information.

.. option:: @<FILE>

Read command-line options and commands from response file `<FILE>`.

BUGS
----

Expand Down
4 changes: 4 additions & 0 deletions docs/CommandGuide/llvm-readobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ input. Otherwise, it will read from the specified ``filenames``.

Print demangled symbol names in the output.

.. option:: @<FILE>

Read command-line options from response file `<FILE>`.

EXIT STATUS
-----------

Expand Down
4 changes: 4 additions & 0 deletions docs/CommandGuide/llvm-symbolizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ OPTIONS
inc at /tmp/x.c:3
main at /tmp/x.c:14
.. option:: @<FILE>

Read command-line options from response file `<FILE>`.

EXIT STATUS
-----------

Expand Down
7 changes: 7 additions & 0 deletions test/tools/llvm-cxxfilt/help.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RUN: llvm-cxxfilt -h | FileCheck %s
RUN: llvm-cxxfilt --help | FileCheck %s

CHECK: OVERVIEW: llvm symbol undecoration tool
CHECK: USAGE: llvm-cxxfilt{{(.exe)?}} [options] <mangled>{{$}}
CHECK: OPTIONS:
CHECK: @FILE
1 change: 1 addition & 0 deletions test/tools/llvm-dwarfdump/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ HELP: -show-form
HELP: -show-parents
HELP: -statistics
HELP: -summarize-types
HELP: @FILE

RUN: llvm-dwarfdump --version 2>&1 | FileCheck --check-prefix=VERSION %s
VERSION: {{ version }}
Expand Down
6 changes: 6 additions & 0 deletions test/tools/llvm-objdump/help.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
RUN: llvm-objdump --help | FileCheck %s

CHECK: OVERVIEW: llvm object file dumper
CHECK: USAGE: llvm-objdump{{(.exe)?}} [options] <input object files>{{$}}
CHECK: OPTIONS:
CHECK: @FILE
14 changes: 10 additions & 4 deletions test/tools/llvm-readobj/basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ RUN: llvm-readelf --version | FileCheck %s --check-prefix=VERSION
VERSION: version

# Test help switch.
RUN: llvm-readobj --help | FileCheck %s --check-prefixes=HELP,USAGE-OBJ
RUN: llvm-readelf --help | FileCheck %s --check-prefixes=HELP,USAGE-ELF
RUN: llvm-readobj --help | FileCheck %s --check-prefixes=HELP,OBJ
RUN: llvm-readelf --help | FileCheck %s --check-prefixes=HELP,ELF
HELP: OVERVIEW: LLVM Object Reader
USAGE-OBJ: llvm-readobj{{.*}} [options] <input object files>
USAGE-ELF: llvm-readelf{{.*}} [options] <input object files>
OBJ: llvm-readobj{{.*}} [options] <input object files>
ELF: llvm-readelf{{.*}} [options] <input object files>
HELP: OPTIONS:
OBJ: -s - Alias for --section-headers
OBJ: -t - Alias for --symbols
ELF: -s - Alias for --symbols
ELF-NOT: {{ }}-t{{ }}
HELP: @FILE
7 changes: 7 additions & 0 deletions test/tools/llvm-size/help.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RUN: llvm-size -h | FileCheck %s
RUN: llvm-size --help | FileCheck %s

CHECK: OVERVIEW: llvm object size dumper
CHECK: USAGE: llvm-size{{(.exe)?}} [options] <input files>{{$}}
CHECK: OPTIONS:
CHECK: @FILE
7 changes: 7 additions & 0 deletions test/tools/llvm-strings/help.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RUN: llvm-strings -h | FileCheck %s
RUN: llvm-strings --help | FileCheck %s

CHECK: OVERVIEW: llvm string dumper
CHECK: USAGE: llvm-strings{{(.exe)?}} [options] <input object files>{{$}}
CHECK: OPTIONS:
CHECK: @FILE
8 changes: 6 additions & 2 deletions test/tools/llvm-symbolizer/help.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
RUN: llvm-symbolizer -help | FileCheck %s --check-prefix=SYMBOLIZER
RUN: llvm-addr2line -help | FileCheck %s --check-prefix=ADDR2LINE
RUN: llvm-symbolizer -h | FileCheck %s --check-prefix=SYMBOLIZER
RUN: llvm-symbolizer --help | FileCheck %s --check-prefix=SYMBOLIZER
RUN: llvm-addr2line -h | FileCheck %s --check-prefix=ADDR2LINE
RUN: llvm-addr2line --help | FileCheck %s --check-prefix=ADDR2LINE

SYMBOLIZER: OVERVIEW: llvm-symbolizer
SYMBOLIZER: USAGE: llvm-symbolizer{{(.exe)?}} [options] <input addresses>...
SYMBOLIZER: @FILE

ADDR2LINE: OVERVIEW: llvm-addr2line
ADDR2LINE: USAGE: llvm-addr2line{{(.exe)?}} [options] <input addresses>...
ADDR2LINE: @FILE
3 changes: 3 additions & 0 deletions tools/llvm-cxxfilt/llvm-cxxfilt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ static cl::alias TypesShort("t", cl::desc("alias for --types"),
static cl::list<std::string>
Decorated(cl::Positional, cl::desc("<mangled>"), cl::ZeroOrMore);

static cl::extrahelp
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");

static std::string demangle(llvm::raw_ostream &OS, const std::string &Mangled) {
int Status;

Expand Down
2 changes: 2 additions & 0 deletions tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ static opt<bool> Verbose("verbose",
cat(DwarfDumpCategory));
static alias VerboseAlias("v", desc("Alias for -verbose."), aliasopt(Verbose),
cat(DwarfDumpCategory));
static cl::extrahelp
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");
} // namespace
/// @}
//===----------------------------------------------------------------------===//
Expand Down
3 changes: 3 additions & 0 deletions tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ static cl::opt<bool>
cl::cat(ObjdumpCat));
static cl::alias WideShort("w", cl::Grouping, cl::aliasopt(Wide));

static cl::extrahelp
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");

static StringSet<> DisasmFuncsSet;
static StringRef ToolName;

Expand Down
3 changes: 3 additions & 0 deletions tools/llvm-readobj/llvm-readobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ namespace opts {
cl::values(clEnumVal(LLVM, "LLVM default style"),
clEnumVal(GNU, "GNU readelf style")),
cl::init(LLVM));

cl::extrahelp
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");
} // namespace opts

namespace llvm {
Expand Down
3 changes: 3 additions & 0 deletions tools/llvm-size/llvm-size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ static cl::alias TotalSizesShort("t", cl::desc("Short for --totals"),
static cl::list<std::string>
InputFilenames(cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore);

static cl::extrahelp
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");

static bool HadError = false;

static std::string ToolName;
Expand Down
3 changes: 3 additions & 0 deletions tools/llvm-strings/llvm-strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ static cl::opt<radix>
cl::init(none));
static cl::alias RadixShort("t", cl::desc(""), cl::aliasopt(Radix));

static cl::extrahelp
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");

static void strings(raw_ostream &OS, StringRef FileName, StringRef Contents) {
auto print = [&OS, FileName](unsigned Offset, StringRef L) {
if (L.size() < static_cast<size_t>(MinLength))
Expand Down
3 changes: 3 additions & 0 deletions tools/llvm-symbolizer/llvm-symbolizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ static cl::opt<DIPrinter::OutputStyle>
clEnumValN(DIPrinter::OutputStyle::GNU, "GNU",
"GNU addr2line style")));

static cl::extrahelp
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");

template<typename T>
static bool error(Expected<T> &ResOrErr) {
if (ResOrErr)
Expand Down

0 comments on commit b7bdff9

Please sign in to comment.