Index: llvm/docs/CommandGuide/llvm-addr2line.rst =================================================================== --- llvm/docs/CommandGuide/llvm-addr2line.rst +++ llvm/docs/CommandGuide/llvm-addr2line.rst @@ -27,6 +27,8 @@ - Uses `--output-style=GNU`_ by default. +- Parses options from the environment variable ``LLVM_ADDR2LINE_OPTIONS``. + SEE ALSO -------- Index: llvm/docs/CommandGuide/llvm-symbolizer.rst =================================================================== --- llvm/docs/CommandGuide/llvm-symbolizer.rst +++ 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_OPTIONS`` after parsing options from the command line. +``LLVM_SYMBOLIZER_OPTIONS`` is primarily useful for supplementing the +command-line options when :program:`llvm-symbolizer` is invoked by another +program or runtime. + EXAMPLES -------- Index: llvm/test/tools/llvm-symbolizer/options-from-env.test =================================================================== --- /dev/null +++ llvm/test/tools/llvm-symbolizer/options-from-env.test @@ -0,0 +1,5 @@ +REQUIRES: shell + +RUN: LLVM_SYMBOLIZER_OPTIONS=--print-address llvm-symbolizer 0x20112f | FileCheck %s + +CHECK: 0x20112f Index: llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp =================================================================== --- llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ 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_OPTIONS" : "LLVM_SYMBOLIZER_OPTIONS"); // If both --demangle and --no-demangle are specified then pick the last one. if (ClNoDemangle.getPosition() > ClDemangle.getPosition())