[all-commits] [llvm/llvm-project] 17fdd9: [Option] Declare library command line options in T...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Wed Sep 30 19:44:07 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 17fdd96472a946ebc7ddf7bc19e1458c4aa8aaea
https://github.com/llvm/llvm-project/commit/17fdd96472a946ebc7ddf7bc19e1458c4aa8aaea
Author: Fangrui Song <i at maskray.me>
Date: 2026-09-30 (Wed, 30 Sep 2026)
Changed paths:
M llvm/docs/CommandLine.md
A llvm/include/llvm/Option/LibraryOptions.h
A llvm/include/llvm/Option/LibraryOptions.td
M llvm/include/llvm/Support/CommandLine.h
A llvm/lib/CGData/CGDataOptions.cpp
A llvm/lib/CGData/CGDataOptions.h
A llvm/lib/CGData/CGDataOptions.td
M llvm/lib/CGData/CMakeLists.txt
M llvm/lib/CGData/CodeGenData.cpp
M llvm/lib/CGData/CodeGenDataReader.cpp
M llvm/lib/CGData/StableFunctionMap.cpp
M llvm/lib/Option/CMakeLists.txt
A llvm/lib/Option/LibraryOptions.cpp
M llvm/lib/Support/CommandLine.cpp
M llvm/unittests/Option/CMakeLists.txt
A llvm/unittests/Option/LibraryOptionsTest.cpp
A llvm/unittests/Option/LibraryOpts.td
M llvm/unittests/Support/CommandLineTest.cpp
M llvm/utils/TableGen/OptionParserEmitter.cpp
M llvm/utils/gn/secondary/llvm/lib/CGData/BUILD.gn
M llvm/utils/gn/secondary/llvm/lib/Option/BUILD.gn
M llvm/utils/gn/secondary/llvm/unittests/Option/BUILD.gn
M utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
M utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel
Log Message:
-----------
[Option] Declare library command line options in TableGen (#226087)
Implement the first step of
https://discourse.llvm.org/t/rfc-declare-library-command-line-options-in-tablegen-one-struct-per-library/91877:
the TableGen backend, the cl:: dispatch, and LLVMCGData's 13 cl::opts as
the first migrated library.
A .td with an `OptionsStruct` def declares a library's options with
`BoolField` (`-x`, `-x=<bool>`) and `ValueField` (`-x=v`,
`-x v`). `-gen-opt-parser-defs` generates a struct with one member per
option, a `Global` instance, the option table, and `apply(const Arg &)`.
A member is named after its option (`-codegen-data-generate` sets
`codegen_data_generate`) unless the defm names it.
`cl::ParseCommandLineOptions` keeps owning argv: a static
`opt::RegisterLibraryOptions<T>` registers the struct as a
`cl::LibraryOptions`, and an argument naming none of cl::'s options is
dispatched to the library that declares it. `-help-hidden` lists library
options (`let Hidden = 0 in` also lists them in `-help`),
`ResetAllOptionOccurrences` restores their defaults, and a name shared
with a cl::opt or another library is a fatal error.
An options struct is private to its library; other libraries use getters
and setters instead of `extern cl::opt`. For example, LTO calls
`cgdata::thinLTOTwoRounds()`.
Aided by Opus 5.5
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list