Repository navigation
bindgen: derive --rust-target from version_semver - #4353
Merged
Merged
Conversation
version is the plain MAJOR.MINOR.PATCH part of RUSTC_CFG_VERSION (1.101.0, not 1.101.0-nightly): the bindgen rule forwards version verbatim as --rust-target, and bindgen rejects pre-release suffixes; the channel is carried by the channel attribute, which keeps its default of nightly and matches the Crosstool compilers. The bindgen rule is additionally hardened to derive --rust-target from version_semver so a suffixed version can never break it again.
krasimirgg
self-requested a review
October 26, 2026 15:20
krasimirgg
enabled auto-merge
October 27, 2026 09:58
auto-merge was automatically disabled
October 27, 2026 14:46
Head branch was pushed to by a user without write access
krasimirgg
enabled auto-merge
October 27, 2026 14:47
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.
rust_bindgenpassesrust_toolchain.versionstraight through as bindgen's--rust-target, but bindgen only accepts1.NN,1.NN.Pornightly. A toolchain declaring a pre-release version like1.87.0-nightly(valid forrust_toolchain.version, and whatrustc -vVreports for a nightly build) therefore breaks everyrust_bindgentarget with:"1.87.0-nightly" is not a valid Rust target, the patch version number must be an unsigned 64-bit integer
Build the flag from the already-parsed
version_semver(major.minor.patch) instead. Behaviour is unchanged for plain versions, and channel labels / empty versions still emit no flag.Includes analysis tests in
extensions/bindgen/test/bindgen_test.bzlfor a pre-release version and for a channel-label version.