[PATCH] D137837: [Support] Move Target/CPU Printing out of CommandLine

Sam Elliott via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 11 06:39:57 PST 2022


lenary created this revision.
Herald added subscribers: ormris, cmtice, steven_wu, gbedwell, hiraditya.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: andreadb.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: All.
lenary requested review of this revision.
Herald added subscribers: llvm-commits, StephenFan.
Herald added a project: LLVM.

This change is rather more invasive than intended. The main intention
here is to make CommandLine.cpp not rely on llvm/Support/Host.h. Right
now, this reliance is only in 3 superficial places:

- Choosing how to expand response files (in two places)
- Printing the default triple and current CPU in `--version` output.

The built in version system has a method for adding "extra version
printers", commonly used by several tools (such as llc) to report the
registered targets in the built version of LLVM. It was reasonably easy
to move the logic for printing the default triple and current CPU into
a similar function, and register it with any relevant binaries.

However, `dsymutil.cpp` showed that this version printing logic is used
from places that don't use cl's built-in version flag, which made the
changes more invasive. Before this patch, these cases used
`cl::PrintVersionMessage()` which skipped the "extra version printers",
but now this method does not skip the extra version printers, as the
std::function objects are now kept inside the VersionPrinter.

The incompatible change here is that now, even if
LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO is defined, some binaries do
not print out the default target triple and cpu when provided with
`--version`, for instance llvm-as and llvm-dis. This breakage is
intended for `llvm-tblgen`, but other tools may want to keep displaying
this info, which is now explicitly opt-in.

The change to expanding response files may also be controversial, but I
believe that these macros should correspond exactly to the host triple
introspection used before.

Depends on D137836 <https://reviews.llvm.org/D137836>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137837

Files:
  llvm/include/llvm/Support/Host.h
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Support/Host.cpp
  llvm/tools/bugpoint/bugpoint.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
  llvm/tools/llvm-exegesis/llvm-exegesis.cpp
  llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc-disassemble-fuzzer/llvm-mc-disassemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-nm/llvm-nm.cpp
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/llvm-profgen.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/llvm-size/llvm-size.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/sancov/sancov.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137837.474747.patch
Type: text/x-patch
Size: 26341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221111/ce3da019/attachment.bin>


More information about the llvm-commits mailing list