Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cease to modify bindgen output. #1456

Merged
merged 10 commits into from
Feb 26, 2025
Merged

Cease to modify bindgen output. #1456

merged 10 commits into from
Feb 26, 2025

Conversation

adetaylor
Copy link
Collaborator

@adetaylor adetaylor commented Feb 26, 2025

This is a major change to the function of autocxx. Previously, it ran bindgen, edited the output, appended cxx instructions, and packaged the results in a hierarchy of mods for the user.

With this change, we NO LONGER edit the bindgen output. That's passed onto the user as-is. We simply augment it with cxx wrappers.

This has pros and cons. Pros:

  • It makes the function of autocxx conceptually easier to understand.
  • We're more likely to be able to accommodate upstream bindgen changes without falling over. Similarly, as bindgen improves, we should automatically pass those improvements onto autocxx users.
  • With subsequent cleanups, it should reduce the complexity of autocxx.

Cons:

  • We're more sensitive to bugs within bindgen. Four tests have been disabled because of bindgen bugs (which have been reported upstream).
  • We are unable to hide some of the original bindgen methods attached to types; users should not normally call them.

This is a compatibility break in two known respects:

  • A wider selection of bindgen issues may be passed on, so this might break autocxx for some users.
  • For C++ functions that were Rust keywords (e.g. "async", "move") previously it was necessary to give their name with a _ in the generate!() directive, e.g. generate!("async_"). This is no longer the case (which is an improvement but nevertheless a compatibility break).

This code needs quite a bit of cleanup.

Fixes #1450.

@adetaylor adetaylor force-pushed the do-not-change-bindgen-mod branch 2 times, most recently from 1c0f99f to d66b768 Compare February 26, 2025 16:37
This is a major change to the function of autocxx. Previously, it ran bindgen,
edited the output, appended cxx instructions, and packaged the results in a
hierarchy of mods for the user.

With this change, we NO LONGER edit the bindgen output. That's passed onto
the user as-is. We simply augment it with cxx wrappers.

This has pros and cons. Pros:
* It makes the function of autocxx conceptually easier to understand.
* We're more likely to be able to accommodate upstream bindgen changes
  without falling over. Similarly, as bindgen improves, we should
  automatically pass those improvements onto autocxx users.
* With subsequent cleanups, it should reduce the complexity of autocxx.

Cons:
* We're more sensitive to bugs within bindgen. Four tests have been
  disabled because of bindgen bugs (which have been reported upstream).
* We are unable to hide some of the original bindgen methods attached
  to types; users should not normally call them.

This is a compatibility break in two known respects:
* A wider selection of bindgen issues may be passed on, so this might
  break autocxx for some users.
* For C++ functions that were Rust keywords (e.g. "async", "move")
  previously it was necessary to give their name with a _ in the
  `generate!()` directive, e.g. `generate!("async_")`. This is no
  longer the case (which is an improvement but nevertheless a
  compatibility break).

This code needs quite a bit of cleanup.

Fixes #1450.
This was no longer necessary or sensible.
@adetaylor adetaylor force-pushed the do-not-change-bindgen-mod branch from d66b768 to dd29343 Compare February 26, 2025 17:17
@adetaylor adetaylor marked this pull request as ready for review February 26, 2025 18:56
adetaylor added a commit to adetaylor/rust-bindgen that referenced this pull request Feb 26, 2025
Provide an option to add a line to every mod generated by bindgen.

Part of google/autocxx#124, though
this is only in fact necessary if we make the changes given in
google/autocxx#1456.
adetaylor added a commit to adetaylor/rust-bindgen that referenced this pull request Feb 26, 2025
This uses an existing callback to allow overriding of constructor name.

Part of google/autocxx#124, though only
necessary if we also do google/autocxx#1456.
Previously we put these in a sub-mod called 'output' but that turned out to be
annoying when looking at things in rustdoc. This puts them back in the top level
ffi namespace which we generate.
This helps when following our documentation's advice which is to use cargo doc
--document-private-items.
@adetaylor adetaylor merged commit b0a03ae into main Feb 26, 2025
21 checks passed
adetaylor added a commit that referenced this pull request Feb 27, 2025
These tests now appear to be passing, at least on some configurations,
since the major changes in #1456.
adetaylor added a commit that referenced this pull request Feb 27, 2025
These tests now appear to be passing, at least on some configurations,
since the major changes in #1456.
adetaylor added a commit that referenced this pull request Feb 28, 2025
Since #1456, users of autocxx have become much more sensitive to
bugs upstream in bindgen. This PR introduces an emergency option
that users can use to work around some of those bugs.
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.

Cease to alter bindgen mod
1 participant