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

--rust-target beta and nightly suffixes #3152

Open
Kangie opened this issue Feb 25, 2025 · 1 comment
Open

--rust-target beta and nightly suffixes #3152

Kangie opened this issue Feb 25, 2025 · 1 comment

Comments

@Kangie
Copy link

Kangie commented Feb 25, 2025

#2993 loosened --rust-target parsing to accept "any*" Rust version output.

Unfortunately, this does not include all of the possible rustc --version output varieties. The following apparently-valid version strings result in error: invalid value '...' for '--rust-target <RUST_TARGET>': "..." is not a valid Rust target:

rustc --version        
rustc 1.86.0-beta.1 (f0cb41030 2025-02-17) (gentoo)
rustc --version   
rustc 1.87.0-nightly (gentoo)

Some consumers of Rust / bindgen (e.g. Meson via the Rust module and rust.bindgen()) pass this version info into bindgen as a --rust-target: e.g. as --rust-target=1.87.0-nightly.

How should this be handled?

I see two options:

  • If a version has a suffix, drop the suffix and parse it as just the version (e.g. 1.86.0-beta* as 1.86.0
  • The above, but a -nightly suffix is special-cased to be the same as passing nightly

I'm not sure which option (if either) is desirable, however:

  • it seems better to address this at the source
  • it seems like a sane assumption that version strings as output by Rust itself should pass validation
  • not accepting Rust version strings is obviously breaking user expectations.

I'll already need to update Meson's Rust module to handle the #2993-changed "invalid Rust target" output; if you have any suggestions on how a build system should use the --rust-target option please let me know.

Downstream bug: https://bugs.gentoo.org/949593

Kangie added a commit to Kangie/meson that referenced this issue Feb 25, 2025
In 0.71.0 the bindgen output for invalid rust targets was changed to
"«version» is not a valid Rust target". This breaks the existing
detection.

Further investigation revealed that from 0.71.0 we probably don't
need to do this check; "all*" Rust versions will be accepted as valid
and converted internally to an appropriate target.

Bindgen does not like `-beta` or `-nightly` suffixes, we'll have
to address that separately depending on the outcome of
rust-lang/rust-bindgen#3152.

See-also: rust-lang/rust-bindgen#2993
Signed-off-by: Matt Jolly <kangie@gentoo.zip>
Kangie added a commit to Kangie/meson that referenced this issue Feb 25, 2025
In 0.71.0 the bindgen output for invalid rust targets was changed to
"«version» is not a valid Rust target". This breaks the existing
detection.

Further investigation revealed that from 0.71.0 we probably don't
need to do this check; "all*" Rust versions will be accepted as valid
and converted internally to an appropriate target.

Bindgen does not like `-beta` or `-nightly` suffixes, we'll have
to address that separately depending on the outcome of
rust-lang/rust-bindgen#3152.

See-also: rust-lang/rust-bindgen#2993
Signed-off-by: Matt Jolly <kangie@gentoo.zip>
@dcbaker
Copy link

dcbaker commented Feb 26, 2025

Meson dev here, I think this is actually our bug. We should be stripping the -nightly and -beta* suffix from the version for the check here, but we don't correctly strip that for rustc.

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

No branches or pull requests

2 participants