<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14875</bug_id>
          
          <creation_ts>2022-08-09 13:15:10 +0000</creation_ts>
          <short_desc>reproducibility failures in rust</short_desc>
          <delta_ts>2025-11-07 23:39:27 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>10</classification_id>
          <classification>QA/Testing</classification>
          <product>Build Testing</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.3 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Richard Purdie">richard.purdie</reporter>
          <assigned_to name="Sundeep Kokkonda">sundeep.kokkonda</assigned_to>
          <cc>alex.kiernan</cc>
    
    <cc>ccasciato</cc>
    
    <cc>frederic.martinsons</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>sundeep.kokkonda</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>93734</commentid>
    <comment_count>0</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2022-08-09 13:15:10 +0000</bug_when>
    <thetext>We&apos;ve had to disable rust and rust-dbg from the reproducibility tests since the binaries generated are not always identical. An example are:

http://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20220803-alsw4xhu/packages/reproducibleA/tmp/deploy/deb/core2-64/rust_1.62.0-r0_amd64.deb

http://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20220803-alsw4xhu/packages/reproducibleB/tmp/deploy/deb/core2-64/rust_1.62.0-r0_amd64.deb

from https://autobuilder.yoctoproject.org/typhoon/#/builders/117/builds/1279 (cancelled as diffoscope can&apos;t cope with the size of these).

This is a different issue to the reproducibility patch which is also applied to the rust recipe.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93768</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-08-11 14:39:52 +0000</bug_when>
    <thetext>Need to fix this so we can continue to report that oe-core is 100% reproducible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93916</commentid>
    <comment_count>2</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-08-25 16:07:46 +0000</bug_when>
    <thetext>Richard, you and Sundeep were talking about this bug today and it seemed that it was only happening on ubu-18.04 but the link below is alma9 only. Were there other build logs to look at or should Sundeep be testing an alma9 docker container? If it is only ubuntu, let me knwo what host is involved and I&apos;ll collect the packages installed to see if that&apos;s a factor. The Wind River shared servers tend to have a superset of the packages installed on the YP AB nodes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94122</commentid>
    <comment_count>3</comment_count>
    <who name="Sundeep KOKKONDA">sundeep.kokkonda</who>
    <bug_when>2022-10-10 04:38:56 +0000</bug_when>
    <thetext>Hello,

This reproducible issue is happening because of the change in the path of the build directory, with the same path name - multiple builds are generating the identical binaries.
The change in build path making differences in the generated object files, static libs (.rlib), .rmeta files, fingerprint/hash data &amp; json outputs in bootstrapping &amp; stage-0 builds which are in turn affecting final binaries generated in stage-1.

This issue is reported in rust community https://github.com/rust-lang/rust/issues/102299 (detailed technical analysis can be found here).
Also, this looks a known issue to rust community, I found a few other similar &apos;open&apos; issues reported in the past, for eg. https://github.com/rust-lang/cargo/issues/5505, https://github.com/rust-lang/cargo/issues/8140.

However, I analyzed issue a bit deeper and tried to fix/workaround the issue by using the option like &apos;--remap-path-prefix&apos; &amp; by removing the metadata crate dependencies but still the final binaries are different.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94128</commentid>
    <comment_count>4</comment_count>
    <who name="Sundeep KOKKONDA">sundeep.kokkonda</who>
    <bug_when>2022-10-11 04:07:28 +0000</bug_when>
    <thetext>As per rust community feedback (https://github.com/rust-lang/rust/issues/102299#issuecomment-1273906259) - 
&quot;The build paths are embedded in the rust binaries, this is a known limitation at the moment and projects like Arch Linux that are currently doing reproducible builds use a standardized build path to reproduce their rust binaries (and the rust compiler itself)&quot;.
So, for builds to be reproducible the build path should be same.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94155</commentid>
    <comment_count>5</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-10-13 17:49:50 +0000</bug_when>
    <thetext>Sundeep, thanks for working on this and consulting with upstream.
I suspect that we&apos;d carry a local patch if you can get some guidance from upstream on how to eliminate the build paths.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94593</commentid>
    <comment_count>6</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-12-22 16:46:36 +0000</bug_when>
    <thetext>Sundeep. Moved to M2. 
If it helps, you could document what you know and what each step is that you take to narrow down the issue as discussed in our call earlier today.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94729</commentid>
    <comment_count>7</comment_count>
    <who name="Alex Kiernan">alex.kiernan</who>
    <bug_when>2023-01-16 12:18:12 +0000</bug_when>
    <thetext>I suspect https://github.com/rust-lang/rust/issues/98185 may be relevant (there&apos;s a patch inside the embedded .cargo/config.toml in the rustc-source tarball).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94730</commentid>
    <comment_count>8</comment_count>
    <who name="Sundeep Kokkonda">sundeep.kokkonda</who>
    <bug_when>2023-01-16 14:23:47 +0000</bug_when>
    <thetext>Hi Alex,

Thanks for your inputs.

The .cargo/config.toml mentioned to use the crates from &apos;vendor&apos; directory. The &apos;vendor&apos; directory has the &apos;fixed version&apos; of crates available local to the rust sources.
Removing the usage of this .cargo/config.toml causes the cargo to fetch the latest available version of crates from network and build is aborted by the &apos;--frozen&apos; compiler option which forces the compiler to use the crate versions fixed in Cargo.lock file.
So, the .cargo/config.toml cannot be removed.

The https://github.com/rust-lang/rust/issues/98185 discussion says the hash is changing when the crates are compiled using the local crates and --remap-path-prefix is not working in such cases.
I am trying to compile a crate using the sources from &apos;vendor&apos; directory crates to ensure the hash is changing between the builds.
If the hash is changed may be we can say the issue is due to the usage of local crates.

Let me know if you&apos;ve any comments on this approach...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94731</commentid>
    <comment_count>9</comment_count>
    <who name="Alex Kiernan">alex.kiernan</who>
    <bug_when>2023-01-16 14:29:33 +0000</bug_when>
    <thetext>Most of the vendored sources are wired in using these parts of .cargo/config.toml:

  [source.crates-io]
  replace-with = &quot;vendored-sources&quot;

  [source.vendored-sources]
  directory = &quot;vendor&quot;

but I wonder if this piece:

  [source.&quot;https://github.com/bjorn3/rust-ar.git&quot;]
  git = &quot;https://github.com/bjorn3/rust-ar.git&quot;
  branch = &quot;do_not_remove_cg_clif_ranlib&quot;
  replace-with = &quot;vendored-sources&quot;

leads to the non-reproducibility we see.

Though my recollection when I added the comment was that this was a [patch.&quot;...&quot;] section and it&apos;s clearly not, so may not apply to the upstream ticket.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94735</commentid>
    <comment_count>10</comment_count>
    <who name="Sundeep Kokkonda">sundeep.kokkonda</who>
    <bug_when>2023-01-17 09:19:14 +0000</bug_when>
    <thetext>The https://github.com/bjorn3/rust-ar.git page says that &apos;rust-ar&apos; is a rust library for encoding/decoding Unix archive (.a) files.
There is no directory with &apos;vendored-sources&apos; or &apos;rust-ar&apos; in the tarball, so, I did not understood what is getting patched/replaced with the sources given in the link. 

However, I removed below code and tried a build, still the reproducibility issue is occuring.

  [source.&quot;https://github.com/bjorn3/rust-ar.git&quot;]
  git = &quot;https://github.com/bjorn3/rust-ar.git&quot;
  branch = &quot;do_not_remove_cg_clif_ranlib&quot;
  replace-with = &quot;vendored-sources&quot;

Also, I gave 2 builds with identical path and compared the generated binaries &amp; those are identical i.e., these lines are not having any impact on code generation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94737</commentid>
    <comment_count>11</comment_count>
    <who name="Alex Kiernan">alex.kiernan</who>
    <bug_when>2023-01-17 10:01:58 +0000</bug_when>
    <thetext>It&apos;s referenced here:

  compiler/rustc_codegen_cranelift/Cargo.toml
  21:ar = { git = &quot;https://github.com/bjorn3/rust-ar.git&quot;, branch = &quot;do_not_remove_cg_clif_ranlib&quot; }

and the vendored directory is vendor/ar.

But if removing those doesn&apos;t change the reproducibility, it doesn&apos;t seem like this is a useful line of inquiry after all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95120</commentid>
    <comment_count>12</comment_count>
    <who name="Sundeep Kokkonda">sundeep.kokkonda</who>
    <bug_when>2023-03-13 13:37:41 +0000</bug_when>
    <thetext>This issue is occurring only when local crates from &apos;vendor&apos; directory are used.

I am able to reproduce the same reproducible issue as in Yocto with rust tarball sources when compiled the sources from &apos;vendor&apos; directory inside the rust tarball. (When crates are pulled from network the issue is not reproducible in rust tarball).
We must enable the flag &apos;vendor = true&apos; in config.toml in rust tarball inorder to use the sources from &apos;vendor&apos; directory, when this flag disabled crates are pulled from network and issue is not reproducible.

This bug when using local crates was already raised in rust community https://github.com/rust-lang/rust/issues/98185

Binary diff in rust tarball:
:/tar/rustc-1.67.0-src-&gt; diff -ur buildX/x86_64-unknown-linux-gnu/stage2 buildY/x86_64-unknown-linux-gnu/stage2
Binary files buildX/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-c96e53ba8e842355.so and buildY/x86_64-unknown-linux-gnu/stage2/lib/librustc_driver-c96e53ba8e842355.so differ
:/tar/rustc-1.67.0-src-&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96251</commentid>
    <comment_count>13</comment_count>
    <who name="Frédéric Martinsons">frederic.martinsons</who>
    <bug_when>2023-08-14 07:10:45 +0000</bug_when>
    <thetext>Good news, back in may an RFC about making path trim per default has been merged: https://github.com/rust-lang/rfcs/pull/3127


This may make our reproducible issues disappeared or be less likely , it impacts both cargo (https://github.com/rust-lang/cargo/issues/12137) and rustc (https://github.com/rust-lang/rust/issues/111540) but the implementation is not yet done.

I&apos;ll watch the two issues to be notified about the progress</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96253</commentid>
    <comment_count>14</comment_count>
    <who name="Frédéric Martinsons">frederic.martinsons</who>
    <bug_when>2023-08-14 07:12:26 +0000</bug_when>
    <thetext>*** Bug 15090 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96673</commentid>
    <comment_count>15</comment_count>
    <who name="Sundeep Kokkonda">sundeep.kokkonda</who>
    <bug_when>2023-10-11 14:34:04 +0000</bug_when>
    <thetext>Issue fixed:
https://git.openembedded.org/openembedded-core/commit/?id=6ae62259afbbe861ed74211dab18a27b8c8d8b7a</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96674</commentid>
    <comment_count>16</comment_count>
    <who name="Sundeep Kokkonda">sundeep.kokkonda</who>
    <bug_when>2023-10-11 14:48:59 +0000</bug_when>
    <thetext>Fix committed to master - https://git.openembedded.org/openembedded-core/commit/?id=6ae62259afbbe861ed74211dab18a27b8c8d8b7a</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>