Skip to content

Add support for limiting which macros use clang fallback - #3513

Open
DanielEScherzer wants to merge 1 commit into
rust-lang:mainfrom
DanielEScherzer:limit-clang-macro-fallback
Open

DanielEScherzer wants to merge 1 commit into
rust-lang:mainfrom
DanielEScherzer:limit-clang-macro-fallback

Conversation

@DanielEScherzer

Copy link
Copy Markdown
Contributor

Change the Builder::clang_macro_fallback() method and the --clang-macro-fallback command line option to update a RegexSet rather than using a boolean flag. This is a breaking change - both the method and the CLI option now require an argument. To match the previous behavior of using the fallback for all macros, use .* as the pattern.

Closes #3511

@DanielEScherzer
DanielEScherzer force-pushed the limit-clang-macro-fallback branch from 80a4322 to 8999ece Compare October 9, 2026 20:50
@DanielEScherzer

Copy link
Copy Markdown
Contributor Author

Clippy errors are unrelated and I sent #3514 to fix them

@rustbot

This comment has been minimized.

@emilio emilio left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good after a rebase to me.

View changes since this review

Comment thread bindgen/options/cli.rs
#[arg(long)]
clang_macro_fallback: bool,
/// Enable fallback for clang macro parsing for macros matching REGEX.
#[arg(long, value_name = "REGEX")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's not easy to make the non-value version work with .*? That's a bit unfortunate. I guess #3518 bitrotted this a bit but we should probably not auto-enable macro fallback there.

@DanielEScherzer
DanielEScherzer force-pushed the limit-clang-macro-fallback branch from 8999ece to 0251317 Compare October 19, 2026 22:15
@rustbot

rustbot commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@DanielEScherzer

Copy link
Copy Markdown
Contributor Author

Rebased and also updated the logic from #3518 to use a regex set too

Change the `Builder::clang_macro_fallback()` method and the
`--clang-macro-fallback` command line option to update a `RegexSet` rather than
using a boolean flag. This is a breaking change - both the method and the CLI
option now require an argument. To match the previous behavior of using the
fallback for all macros, use `.*` as the pattern.

Apply the same changes to `Builder::macro_const_use_ctypes()` and the
`--macro-const-use-ctypes` command line option.

Closes rust-lang#3511
@DanielEScherzer
DanielEScherzer force-pushed the limit-clang-macro-fallback branch from 0251317 to 99c0a52 Compare October 19, 2026 22:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clang_macro_fallback() - allow specifying which macros

3 participants