Skip to content

--rust-target beta and nightly suffixes #3152

Open
@Kangie

Description

@Kangie

#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions