diff --git a/llvm/docs/CommandGuide/llvm-addr2line.rst b/llvm/docs/CommandGuide/llvm-addr2line.rst --- a/llvm/docs/CommandGuide/llvm-addr2line.rst +++ b/llvm/docs/CommandGuide/llvm-addr2line.rst @@ -27,6 +27,8 @@ - Uses `--output-style=GNU`_ by default. +- Parses options from the environment variable ``LLVM_ADDR2LINE_OPTS``. + SEE ALSO -------- diff --git a/llvm/docs/CommandGuide/llvm-symbolizer.rst b/llvm/docs/CommandGuide/llvm-symbolizer.rst --- a/llvm/docs/CommandGuide/llvm-symbolizer.rst +++ b/llvm/docs/CommandGuide/llvm-symbolizer.rst @@ -28,6 +28,12 @@ input or as positional arguments on the command-line, following any "DATA" or "CODE" prefix. +:program:`llvm-symbolizer` parses options from the environment variable +``LLVM_SYMBOLIZER_OPTS`` after parsing options from the command line. +``LLVM_SYMBOLIZER_OPTS`` is primarily useful for supplementing the command-line +options when :program:`llvm-symbolizer` is invoked by another program or +runtime. + EXAMPLES -------- diff --git a/llvm/test/tools/llvm-symbolizer/options-from-env.test b/llvm/test/tools/llvm-symbolizer/options-from-env.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-symbolizer/options-from-env.test @@ -0,0 +1,6 @@ +REQUIRES: shell + +RUN: LLVM_SYMBOLIZER_OPTS=--print-address llvm-symbolizer 0x20112f | FileCheck %s +RUN: LLVM_ADDR2LINE_OPTS=--print-address llvm-addr2line 0x20112f | FileCheck %s + +CHECK: 0x20112f diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp --- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -289,8 +289,10 @@ } llvm::sys::InitializeCOMRAII COM(llvm::sys::COMThreadingMode::MultiThreaded); - cl::ParseCommandLineOptions(argc, argv, IsAddr2Line ? "llvm-addr2line\n" - : "llvm-symbolizer\n"); + cl::ParseCommandLineOptions( + argc, argv, IsAddr2Line ? "llvm-addr2line\n" : "llvm-symbolizer\n", + /*Errs=*/nullptr, + IsAddr2Line ? "LLVM_ADDR2LINE_OPTS" : "LLVM_SYMBOLIZER_OPTS"); // If both --demangle and --no-demangle are specified then pick the last one. if (ClNoDemangle.getPosition() > ClDemangle.getPosition())