Skip to content

bindgen: derive --rust-target from version_semver - #4353

Merged
krasimirgg merged 5 commits into
bazelbuild:mainfrom
SergejSalnikov:main
Oct 27, 2026
Merged

krasimirgg merged 5 commits into
bazelbuild:mainfrom
SergejSalnikov:main

Conversation

@SergejSalnikov

@SergejSalnikov SergejSalnikov commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

rust_bindgen passes rust_toolchain.version straight through as bindgen's --rust-target, but bindgen only accepts 1.NN, 1.NN.P or nightly. A toolchain declaring a pre-release version like 1.87.0-nightly (valid for rust_toolchain.version, and what rustc -vV reports for a nightly build) therefore breaks every rust_bindgen target 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.bzl for a pre-release version and for a channel-label version.

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
krasimirgg self-requested a review October 26, 2026 15:20
@SergejSalnikov SergejSalnikov changed the title Add version support bindgen: derive --rust-target from version_semver Oct 26, 2026

@krasimirgg krasimirgg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@krasimirgg
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
krasimirgg enabled auto-merge October 27, 2026 14:47
@krasimirgg
krasimirgg added this pull request to the merge queue Oct 27, 2026
Merged via the queue into bazelbuild:main with commit 08719eb Oct 27, 2026
3 checks passed
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.

2 participants