[PATCH] D104363: [llvm] Mark more internal command line optins as cl::Hidden

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 23 10:48:36 PDT 2021


MaskRay accepted this revision.
MaskRay added a comment.

> This seems to only happen when the tools are linked against the shared llvm dylib.



In D104363#2823895 <https://reviews.llvm.org/D104363#2823895>, @jhenderson wrote:

> This isn't an issue for the static linking approach, so why does it happen for the dynamic library approach? It seems like fixing this aspect should be the way forward, as it will be more robust generally.

How many options are displayed depends on linker garbage collection.

With the default `-DLLVM_LINK_LLVM_DYLIB=off`, --gc-sections can garbage collection almost all code generation/middle-end optimization options, so `--help` looks clean.

With `-DLLVM_LINK_LLVM_DYLIB=on`, `cl::opt` (and its friends) options are all retained in `libLLVM-13git.so`, so a tool linking against `libLLVM-13git.so` may see many unrelated options.

Adding `cl::cat(ToolOptions)` annotations does solve the problem, so LGTM. For some tools like `llvm-mc`, they can use arbitrary MC layer `cl::opt` options.
Some tests may use some obscure options.
IIUC `cl::HideUnrelatedOptions(&ToolOptions);` will make the options `cl::ReallyHidden` which will disappear from `--help-all-hidden`. If any tool turns out to want the obscure options, we can think of other options or just dropping `HideUnrelatedOptions` for the particular tool.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104363/new/

https://reviews.llvm.org/D104363



More information about the llvm-commits mailing list