Skip to content

clap_builder builds non-deterministically with Bazel #6151

@rejuvenile

Description

@rejuvenile

Please complete the following tasks

Rust Version

rustc 1.92.0-nightly (f6aa851db 2025-10-07)

Clap Version

HEAD, 4.5.49

Minimal reproducible code

cargo build

Steps to reproduce the bug with the above code

cd clap/cargo_builder && cargo build --release
cd ../../clap2/cargo_builder && cargo build --release
cd ../..
bcomp (or diff) clap/target/release/libclap_builder.rlib clap2/target/release/libclap_builder.rlib

Actual Behaviour

  • absolute paths to the source tree are embedded in the rlib, even in release mode
  • there are at least several hundred other hex differences (some look like padding, perhaps garbage or uninitialized)

Expected Behaviour

Two cargo builds in different source trees on the same host on the same version result in binary-identical rlibs.

Additional Context

This causes distributed build, cache, and test systems like Bazel to be less efficient. Because the clap_builder dependency in a binary may be different across hosts, the resulting binary will hash differently and expensive tests may be rerun. No other clap crate has this issue.

Debug Output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugE-help-wantedCall for participation: Help is requested to fix this issue.E-mediumCall for participation: Experience needed to fix: Medium / intermediate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions