[llvm] [Option] Add Condition for build-conditional library options (PR #230898)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 11 10:15:49 PDT 2026


MaskRay wrote:

> I don't particularly like the generic condition, I think this just invites to do strange things with options. Maybe only NDEBUG as a special case? Maybe we have too many cases that need this (`__APPLE__`, HAVE_TFLITE, LLVM_GISEL_COV_PREFIX)...

Counted conditional cl::opt options:
```
┌───────────────────────────────────────────────┬───────┬───────────────────┐
│                   Condition                   │ Total │ Excluding Support │
├───────────────────────────────────────────────┼───────┼───────────────────┤
│ !defined(NDEBUG)                              │ 49    │ 43                │
├───────────────────────────────────────────────┼───────┼───────────────────┤
│ !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) │ 18    │ 18                │
├───────────────────────────────────────────────┼───────┼───────────────────┤
│ LLVM_HAVE_TFLITE                              │ 8     │ 8                 │
├───────────────────────────────────────────────┼───────┼───────────────────┤
│ __APPLE__                                     │ 2     │ 0                 │
├───────────────────────────────────────────────┼───────┼───────────────────┤
│ LLVM_GISEL_COV_PREFIX                         │ 1     │ 1                 │
├───────────────────────────────────────────────┼───────┼───────────────────┤
│ Total                                         │ 78    │ 70                │
└───────────────────────────────────────────────┴───────┴───────────────────┘
```

We can use ` let Condition = AssertsOnly ` and ` let Condition = DumpOnly` to port most options (and make the rest enabled but ignored in more builds). A user can use optional fields and reject conditional options when the condition is false. 

https://github.com/llvm/llvm-project/pull/230898


More information about the llvm-commits mailing list