Repository navigation
Conversation
On aarch64-linux, clang defines `__builtin_va_list` as a typedef of an implicit `struct __va_list`. bindgen resolves that typedef to an opaque type that keeps its name, and the C serializer used by `--wrap-static-fns` rejected it with "Cannot serialize type kind Opaque". Refer to such named opaque types by their name in the generated C, and drop the aarch64-linux workarounds added for this issue in the tests. Fixes rust-lang#3234
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On aarch64-linux, clang defines
__builtin_va_listas a typedef of an implicitstruct __va_list. bindgen ends up turning that typedef into aTypeKind::Opaquethat still carries the name__builtin_va_list(this is also whyva_list_aarch64_linux.rsshows an opaque blob). The Rust side handles it, but the C serializer used by--wrap-static-fnshas no arm forOpaque, so any static function taking a__builtin_va_listfails withCannot serialize type kind Opaque.Fix
bindgen/codegen/serialize.rs: a named opaque type is now written by its name (withconstif needed), the same way theAliasarm does it. For the case above this prints__builtin_va_list, the same text the x86_64 path already emits. Unnamed opaque types still return the existing error. The generated Rust bindings do not change.With the bug fixed, this PR also removes the aarch64-linux workarounds that were marked "remove when #3234 is solved": the
DISABLE_VAguard inwrap-static-fns.h, thecfgblocks intest_wrap_static_fns,bindgen-integration/build.rsandbindgen-integration/src/lib.rs, andgenerated/wrap_static_fns_aarch64_linux.c. Those spots are restored to what they were before the workaround.Tests
New header test
wrap_static_fns_va_list_aarch64_linux.h(--wrap-static-fns -- --target=aarch64-unknown-linux-gnu, plus thewrap-as-variadic-fncallback), so it runs on every host:/* error generating bindings */. With the change it passes.--target=aarch64-unknown-linux-gnuintest_wrap_static_fns(not committed). Without the fix it fails withCannot serialize type kind Opaqueatwrap-static-fns.h:71:56. With the fix the output matchesgenerated/wrap_static_fns.cexactly, including the variadic wrappers.Run locally on aarch64-apple-darwin with stable Rust 1.93.0 and the libclang that clang-sys finds by default:
cargo test -p bindgen-tests --test tests: 641 passed, 3 failed. The failures areheader_issue_544_stylo_creduce_2_hpp,header_nsbasehashtable_hppandheader_objc_template_h, and the same three fail on unmodifiedmainin this environment (libclang version differences).cargo testinbindgen-tests/tests/expectations: passes, so the new expectation compiles.cargo testinbindgen-integration: 24 passed.cargo clippy --all-targets --workspace --exclude bindgen-integration --exclude tests_expectations -- -D warnings: clean.rustfmt --edition 2021 --checkreports nothing in the changed lines.Not tested on an aarch64-linux host. The removed workarounds in
test_wrap_static_fnsandbindgen-integrationonly change behaviour there, so theubuntu-24.04-armCI jobs are the real check for that part.Fixes #3234
AI disclosure: this pull request was prepared and opened by an AI coding agent (Claude Code) on behalf of the account owner. The agent wrote the change and ran the checks listed above; no human has reviewed or manually tested it yet. Follow-up commits may also come from the agent; replies posted here may be written and sent by the agent without the account owner reviewing them first.