[RFC] Declare library command line options in TableGen, one struct per library

  1. When a plugin DSO loads, its dynamic initialization (RegisterLibraryOptions<T>) will run and cause the subsequent ParseCommandLineOptions to parse its registered options among the other registered options. If this out to matter, the DSO can move to an explicit RegisterLibraryoptions<T> call.
  2. This is an orthogonal “while we are at it” decision. While we can keep parsing -foo=false (while every other CLI library uses something like -no-foo), I suggest that we eventually reject this form. I’ve created [Support] Accept -no-<name> to negate cl::opt<bool> by MaskRay · Pull Request #224978 · llvm/llvm-project · GitHub to support -no-foo in the current, legacy cl:: . If this is accepted, I can request a release/23.x backport (a few rust-lang/rust tests use something like -Cllvm-args=-enable-global-merge=0). Anyway, internal options do not provide stability guarantee. This is for courtesy.
  3. We should remove the cl::callback feature. They will become plain field assignment and surround code should inspect the state and make transformation.
  4. They can stay cl::opt until the flag day, or we can move them from LLVMSupport to a different library. We can also hand write OptTable.
  5. Per “Why keep cl:: for now?” at the end of Q&A: cl:: shrinks as libraries and tools leave it; the end state has no cl::opt
1 Like