Skip to content

rust libs are not reproducible from 1.75 #120825

@sundeep-kokkonda

Description

@sundeep-kokkonda
Contributor

Hello,

We're building rust in Yocto framework for a custom target, and there we are facing a reproducible issue with the libs generated during the build. When the rust is build in two different paths the generated libs are not identical, those are getting differed in .rustc section. This is observed from the rust 1.75.0 onwards.
(We've enabled remap-debuginfo option but still this issue is happening, this option was learned from issue discussion https://internals.rust-lang.org/t/librustc-driver-so-not-reproducible/19639 and this was working fine till 1.74.1)

I've analyzed the changes from 1.74.1 to 1.75.0, there are changes related to Cargo, llvm & some changes w.r.t to bolt feature/optimization are there. I've tried a few builds by reverting these changes but still the issue is reproducing.

There are a few commits in 85c0ce2 for src/bootstrap/src/core/builder.rs & src/bootstrap/src/bin/rustc.rs files which have changes related to remap-debuginfo option and I suspect this commit might causing the issue. I tried build by reverting the commit & with the latest changes in 4b7e0a0 but still issue is reproduing. There is a new RUSTC_CARGO_REGISTRY_SRC_TO_REMAP is added in this commit. I added a few debug statements in here to see the build paths passed, I can see those are passed correctly to RUSTC_CARGO_REGISTRY_SRC_TO_REMAP.

Any hints on what might cause reproducible issues with this commit on rust 1.75? Let me know if any other info is needed.

Non-reproducible libs are here:
libs

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 9, 2024
bjorn3

bjorn3 commented on Feb 9, 2024

@bjorn3
Member

Could you see if you can extract both versions of the .rustc section, follow the instructions in https://internals.rust-lang.org/t/librustc-driver-so-not-reproducible/19639/10 to decompress and then show a diff of the decompressed data?

Edit: Forgot that I removed metadata compression for dylibs a while ago. So you can just diff the .rustc section directly.

saethlin

saethlin commented on Feb 10, 2024

@saethlin
Member

I'm assigning myself because I'm going to try to build a tool to help with this. It might be pretty cooked.

self-assigned this
on Feb 10, 2024
added
A-metadataArea: Crate metadata
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 10, 2024
sundeep-kokkonda

sundeep-kokkonda commented on Feb 11, 2024

@sundeep-kokkonda
ContributorAuthor

Could you see if you can extract both versions of the .rustc section, follow the instructions in https://internals.rust-lang.org/t/librustc-driver-so-not-reproducible/19639/10 to decompress and then show a diff of the decompressed data?

Edit: Forgot that I removed metadata compression for dylibs a while ago. So you can just diff the .rustc section directly.

Attached librustc_driver-cbccc190731a002e & libcstr-13225ad2e5d1b622 libs .rustc section diff here (There are many more libs differed).

Diff for .rustc section of librustc_driver-cbccc190731a002e (in librustc_driver the diff is huge, below image is part of it. The attached librustc_driver_report.pdf is full diff report)
librustc_driver_rustc_section
librustc_driver_report.pdf

Diff for .rustc section of libcstr-13225ad2e5d1b622
libcstr_rustc

sundeep-kokkonda

sundeep-kokkonda commented on Feb 11, 2024

@sundeep-kokkonda
ContributorAuthor

I'm assigning myself because I'm going to try to build a tool to help with this. It might be pretty cooked.

@saethlin Tool for what?

saethlin

saethlin commented on Feb 11, 2024

@saethlin
Member

Figuring out what these bytes are.

bjorn3

bjorn3 commented on Feb 11, 2024

@bjorn3
Member

Looks like some paths aren't getting remapped as they should.

sundeep-kokkonda

sundeep-kokkonda commented on Feb 11, 2024

@sundeep-kokkonda
ContributorAuthor

Looks like some paths aren't getting remapped as they should.

Is there a way to pull out that info, which paths, build stage, crate info etc? The verbose build log shows me the --remap-path-prefix option is passed during build of each crate and the debug statements (I added) in 4b7e0a0 also shows correct paths.

sundeep-kokkonda

sundeep-kokkonda commented on Feb 11, 2024

@sundeep-kokkonda
ContributorAuthor

Edit: Forgot that I removed metadata compression for dylibs a while ago. So you can just diff the .rustc section directly.

Does this mean the -Zls options mentioned here are not supporting now?

30 remaining items

added 5 commits that reference this issue on Mar 6, 2024
added a commit that references this issue on Mar 6, 2024
workingjubilee

workingjubilee commented on Aug 3, 2024

@workingjubilee
Member

It looks like the shell script in this comment #120825 (comment) should be converted to a test. Possibly an rmake test.

added
O-yoctoTarget: a Linux distro that builds everything from source and patches our build extensively
and removed
O-yoctoTarget: a Linux distro that builds everything from source and patches our build extensively
on Jan 29, 2025
nastynaz

nastynaz commented on Jun 6, 2025

@nastynaz

@sundeep-kokkonda Did you ever find a way to reliably check if the code content of a Rust binary has changed? I need to know when certain binaries require to be deployed. Deployment is a costly step so I'd like to do it only when strictly necessary. Any help would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-metadataArea: Crate metadataA-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @davidtwco@nastynaz@saethlin@fmease@bjorn3

        Issue actions

          rust libs are not reproducible from 1.75 · Issue #120825 · rust-lang/rust