diff mbox series

[v2,3/3] rust: reproducibility issue fix with v1.76

Message ID 20240615160415.3457966-3-Yash.Shinde@windriver.com
State New
Headers show
Series [v2,1/3] rust: Oe-selftest fixes for rust v1.76. | expand

Commit Message

Yash Shinde June 15, 2024, 4:04 p.m. UTC
From: Yash Shinde <Yash.Shinde@windriver.com>

A few crates are using the updated version of the 'cc' crate and
this is causing the generated object file names containing a unique hashmap id.
The hashmap addition to generated files is reverted here.

Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@windriver.com>
Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
---
 ...epro-issue-fix-with-cc-crate-hashmap.patch | 59 +++++++++++++++++++
 meta/recipes-devtools/rust/rust-source.inc    |  1 +
 2 files changed, 60 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/files/repro-issue-fix-with-cc-crate-hashmap.patch

Comments

Alexander Kanavin June 17, 2024, 9:41 a.m. UTC | #1
This does not address my previous comment. This needs a link to
upstream report or patch submission.

Alex

On Sat, 15 Jun 2024 at 18:05, <Yash.Shinde@windriver.com> wrote:
>
> From: Yash Shinde <Yash.Shinde@windriver.com>
>
> A few crates are using the updated version of the 'cc' crate and
> this is causing the generated object file names containing a unique hashmap id.
> The hashmap addition to generated files is reverted here.
>
> Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@windriver.com>
> Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
> ---
>  ...epro-issue-fix-with-cc-crate-hashmap.patch | 59 +++++++++++++++++++
>  meta/recipes-devtools/rust/rust-source.inc    |  1 +
>  2 files changed, 60 insertions(+)
>  create mode 100644 meta/recipes-devtools/rust/files/repro-issue-fix-with-cc-crate-hashmap.patch
>
> diff --git a/meta/recipes-devtools/rust/files/repro-issue-fix-with-cc-crate-hashmap.patch b/meta/recipes-devtools/rust/files/repro-issue-fix-with-cc-crate-hashmap.patch
> new file mode 100644
> index 0000000000..20d7e3fc15
> --- /dev/null
> +++ b/meta/recipes-devtools/rust/files/repro-issue-fix-with-cc-crate-hashmap.patch
> @@ -0,0 +1,59 @@
> +rust: reproducibility issue fix with v1.76
> +
> +A few crates are using the updated version of the 'cc' crate and this is causing the generated object file names containing a unique hashmap id.
> +The hashmap addition to generated files is reverted here.
> +
> +
> +Upstream-Status: Inappropriate [patches need rework]
> +Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@windriver.com>
> +---
> +--- a/vendor/cc-1.0.79/src/lib.rs
> ++++ b/vendor/cc-1.0.79/src/lib.rs
> +@@ -56,12 +56,11 @@
> + #![allow(deprecated)]
> + #![deny(missing_docs)]
> +
> +-use std::collections::{hash_map, HashMap};
> ++use std::collections::HashMap;
> + use std::env;
> + use std::ffi::{OsStr, OsString};
> + use std::fmt::{self, Display, Formatter};
> + use std::fs;
> +-use std::hash::Hasher;
> + use std::io::{self, BufRead, BufReader, Read, Write};
> + use std::path::{Component, Path, PathBuf};
> + use std::process::{Child, Command, Stdio};
> +@@ -1037,24 +1036,7 @@
> +
> +         let mut objects = Vec::new();
> +         for file in self.files.iter() {
> +-            let obj = if file.has_root() {
> +-                // If `file` is an absolute path, prefix the `basename`
> +-                // with the `dirname`'s hash to ensure name uniqueness.
> +-                let basename = file
> +-                    .file_name()
> +-                    .ok_or_else(|| Error::new(ErrorKind::InvalidArgument, "file_name() failure"))?
> +-                    .to_string_lossy();
> +-                let dirname = file
> +-                    .parent()
> +-                    .ok_or_else(|| Error::new(ErrorKind::InvalidArgument, "parent() failure"))?
> +-                    .to_string_lossy();
> +-                let mut hasher = hash_map::DefaultHasher::new();
> +-                hasher.write(dirname.to_string().as_bytes());
> +-                dst.join(format!("{:016x}-{}", hasher.finish(), basename))
> +-                    .with_extension("o")
> +-            } else {
> +-                dst.join(file).with_extension("o")
> +-            };
> ++            let obj = dst.join(file).with_extension("o");
> +             let obj = if !obj.starts_with(&dst) {
> +                 dst.join(obj.file_name().ok_or_else(|| {
> +                     Error::new(ErrorKind::IOError, "Getting object file details failed.")
> +Index: rustc-1.77.0-src/vendor/cc-1.0.79/.cargo-checksum.json
> +===================================================================
> +--- a/vendor/cc-1.0.79/.cargo-checksum.json
> ++++ b/vendor/cc-1.0.79/.cargo-checksum.json
> +@@ -1 +1 @@
> +-{"files":{"Cargo.lock":"dddb9c49058d411a098e98dc1c06e3bc89f859a2080d96c11b11aec67394bb8c","Cargo.toml":"1953a8bc4b98e351fe75917c151b1e08a46531d562aebba25a90add4aadecac2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"58af5106352aafa62175a90f8a5f25fa114028bf909220dc0735d79745999ec1","src/bin/gcc-shim.rs":"36dc4e447428e73c548cc7106ca1e8f282c098463b014e13a729a44445de4880","src/com.rs":"29d0dee08a656ab1a4cc3e5fe24542e0fab5c1373cbc9b05059f7572cf9b8313","src/lib.rs":"17a4659710aa290c4ed9c23063c7b202c5bcf2a84de33aa1f01fc6fded69a1f8","src/registry.rs":"98ae2b71781acc49297e5544fa0cf059f735636f8f1338edef8dbf7232443945","src/setup_config.rs":"72deaf1927c0b713fd5c2b2d5b8f0ea3a303a00fda1579427895cac26a94122d","src/vs_instances.rs":"2d3f8278a803b0e7052f4eeb1979b29f963dd0143f4458e2cb5f33c4e5f0963b","src/winapi.rs":"e128e95b2d39ae7a02f54a7e25d33c488c14759b9f1a50a449e10545856950c3","src/windows_registry.rs":"1f973f804b4b451e48ff6d98ce660355772f164dfdf79a6ae514645c7c764005","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"a3c8d116973bb16066bf6ec4de5143183f97de7aad085d85f8118a2eaac3e1e0","tests/test.rs":"61fb35ae6dd5cf506ada000bdd82c92e9f8eac9cc053b63e83d3f897436fbf8f"},"package":"50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"}
> +\ No newline at end of file
> ++{"files":{"Cargo.lock":"dddb9c49058d411a098e98dc1c06e3bc89f859a2080d96c11b11aec67394bb8c","Cargo.toml":"1953a8bc4b98e351fe75917c151b1e08a46531d562aebba25a90add4aadecac2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"58af5106352aafa62175a90f8a5f25fa114028bf909220dc0735d79745999ec1","src/bin/gcc-shim.rs":"36dc4e447428e73c548cc7106ca1e8f282c098463b014e13a729a44445de4880","src/com.rs":"29d0dee08a656ab1a4cc3e5fe24542e0fab5c1373cbc9b05059f7572cf9b8313","src/lib.rs":"dfb36b17362e9a5b266cb19a229d982e8c0bba784b1e99769f690692b0cd5c4e","src/registry.rs":"98ae2b71781acc49297e5544fa0cf059f735636f8f1338edef8dbf7232443945","src/setup_config.rs":"72deaf1927c0b713fd5c2b2d5b8f0ea3a303a00fda1579427895cac26a94122d","src/vs_instances.rs":"2d3f8278a803b0e7052f4eeb1979b29f963dd0143f4458e2cb5f33c4e5f0963b","src/winapi.rs":"e128e95b2d39ae7a02f54a7e25d33c488c14759b9f1a50a449e10545856950c3","src/windows_registry.rs":"1f973f804b4b451e48ff6d98ce660355772f164dfdf79a6ae514645c7c764005","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"a3c8d116973bb16066bf6ec4de5143183f97de7aad085d85f8118a2eaac3e1e0","tests/test.rs":"61fb35ae6dd5cf506ada000bdd82c92e9f8eac9cc053b63e83d3f897436fbf8f"},"package":"50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"}
> diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
> index 6b7414b5c1..e68bc18c9f 100644
> --- a/meta/recipes-devtools/rust/rust-source.inc
> +++ b/meta/recipes-devtools/rust/rust-source.inc
> @@ -10,6 +10,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
>              file://repro-issue-fix-with-v175.patch;patchdir=${RUSTSRC} \
>              file://0001-cargo-do-not-write-host-information-into-compilation.patch;patchdir=${RUSTSRC} \
>              file://rust-oe-selftest.patch;patchdir=${RUSTSRC} \
> +            file://repro-issue-fix-with-cc-crate-hashmap.patch;patchdir=${RUSTSRC} \
>  "
>  SRC_URI[rust.sha256sum] = "805482b436442a6786d270cacbab8f00529e06141b27b7fb01909b97ce4f3464"
>
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/meta/recipes-devtools/rust/files/repro-issue-fix-with-cc-crate-hashmap.patch b/meta/recipes-devtools/rust/files/repro-issue-fix-with-cc-crate-hashmap.patch
new file mode 100644
index 0000000000..20d7e3fc15
--- /dev/null
+++ b/meta/recipes-devtools/rust/files/repro-issue-fix-with-cc-crate-hashmap.patch
@@ -0,0 +1,59 @@ 
+rust: reproducibility issue fix with v1.76
+
+A few crates are using the updated version of the 'cc' crate and this is causing the generated object file names containing a unique hashmap id.
+The hashmap addition to generated files is reverted here.
+
+
+Upstream-Status: Inappropriate [patches need rework]
+Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@windriver.com>
+---
+--- a/vendor/cc-1.0.79/src/lib.rs
++++ b/vendor/cc-1.0.79/src/lib.rs
+@@ -56,12 +56,11 @@
+ #![allow(deprecated)]
+ #![deny(missing_docs)]
+ 
+-use std::collections::{hash_map, HashMap};
++use std::collections::HashMap;
+ use std::env;
+ use std::ffi::{OsStr, OsString};
+ use std::fmt::{self, Display, Formatter};
+ use std::fs;
+-use std::hash::Hasher;
+ use std::io::{self, BufRead, BufReader, Read, Write};
+ use std::path::{Component, Path, PathBuf};
+ use std::process::{Child, Command, Stdio};
+@@ -1037,24 +1036,7 @@
+ 
+         let mut objects = Vec::new();
+         for file in self.files.iter() {
+-            let obj = if file.has_root() {
+-                // If `file` is an absolute path, prefix the `basename`
+-                // with the `dirname`'s hash to ensure name uniqueness.
+-                let basename = file
+-                    .file_name()
+-                    .ok_or_else(|| Error::new(ErrorKind::InvalidArgument, "file_name() failure"))?
+-                    .to_string_lossy();
+-                let dirname = file
+-                    .parent()
+-                    .ok_or_else(|| Error::new(ErrorKind::InvalidArgument, "parent() failure"))?
+-                    .to_string_lossy();
+-                let mut hasher = hash_map::DefaultHasher::new();
+-                hasher.write(dirname.to_string().as_bytes());
+-                dst.join(format!("{:016x}-{}", hasher.finish(), basename))
+-                    .with_extension("o")
+-            } else {
+-                dst.join(file).with_extension("o")
+-            };
++            let obj = dst.join(file).with_extension("o");
+             let obj = if !obj.starts_with(&dst) {
+                 dst.join(obj.file_name().ok_or_else(|| {
+                     Error::new(ErrorKind::IOError, "Getting object file details failed.")
+Index: rustc-1.77.0-src/vendor/cc-1.0.79/.cargo-checksum.json
+===================================================================
+--- a/vendor/cc-1.0.79/.cargo-checksum.json
++++ b/vendor/cc-1.0.79/.cargo-checksum.json
+@@ -1 +1 @@
+-{"files":{"Cargo.lock":"dddb9c49058d411a098e98dc1c06e3bc89f859a2080d96c11b11aec67394bb8c","Cargo.toml":"1953a8bc4b98e351fe75917c151b1e08a46531d562aebba25a90add4aadecac2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"58af5106352aafa62175a90f8a5f25fa114028bf909220dc0735d79745999ec1","src/bin/gcc-shim.rs":"36dc4e447428e73c548cc7106ca1e8f282c098463b014e13a729a44445de4880","src/com.rs":"29d0dee08a656ab1a4cc3e5fe24542e0fab5c1373cbc9b05059f7572cf9b8313","src/lib.rs":"17a4659710aa290c4ed9c23063c7b202c5bcf2a84de33aa1f01fc6fded69a1f8","src/registry.rs":"98ae2b71781acc49297e5544fa0cf059f735636f8f1338edef8dbf7232443945","src/setup_config.rs":"72deaf1927c0b713fd5c2b2d5b8f0ea3a303a00fda1579427895cac26a94122d","src/vs_instances.rs":"2d3f8278a803b0e7052f4eeb1979b29f963dd0143f4458e2cb5f33c4e5f0963b","src/winapi.rs":"e128e95b2d39ae7a02f54a7e25d33c488c14759b9f1a50a449e10545856950c3","src/windows_registry.rs":"1f973f804b4b451e48ff6d98ce660355772f164dfdf79a6ae514645c7c764005","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"a3c8d116973bb16066bf6ec4de5143183f97de7aad085d85f8118a2eaac3e1e0","tests/test.rs":"61fb35ae6dd5cf506ada000bdd82c92e9f8eac9cc053b63e83d3f897436fbf8f"},"package":"50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"}
+\ No newline at end of file
++{"files":{"Cargo.lock":"dddb9c49058d411a098e98dc1c06e3bc89f859a2080d96c11b11aec67394bb8c","Cargo.toml":"1953a8bc4b98e351fe75917c151b1e08a46531d562aebba25a90add4aadecac2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"58af5106352aafa62175a90f8a5f25fa114028bf909220dc0735d79745999ec1","src/bin/gcc-shim.rs":"36dc4e447428e73c548cc7106ca1e8f282c098463b014e13a729a44445de4880","src/com.rs":"29d0dee08a656ab1a4cc3e5fe24542e0fab5c1373cbc9b05059f7572cf9b8313","src/lib.rs":"dfb36b17362e9a5b266cb19a229d982e8c0bba784b1e99769f690692b0cd5c4e","src/registry.rs":"98ae2b71781acc49297e5544fa0cf059f735636f8f1338edef8dbf7232443945","src/setup_config.rs":"72deaf1927c0b713fd5c2b2d5b8f0ea3a303a00fda1579427895cac26a94122d","src/vs_instances.rs":"2d3f8278a803b0e7052f4eeb1979b29f963dd0143f4458e2cb5f33c4e5f0963b","src/winapi.rs":"e128e95b2d39ae7a02f54a7e25d33c488c14759b9f1a50a449e10545856950c3","src/windows_registry.rs":"1f973f804b4b451e48ff6d98ce660355772f164dfdf79a6ae514645c7c764005","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"a3c8d116973bb16066bf6ec4de5143183f97de7aad085d85f8118a2eaac3e1e0","tests/test.rs":"61fb35ae6dd5cf506ada000bdd82c92e9f8eac9cc053b63e83d3f897436fbf8f"},"package":"50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"}
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index 6b7414b5c1..e68bc18c9f 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -10,6 +10,7 @@  SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
             file://repro-issue-fix-with-v175.patch;patchdir=${RUSTSRC} \
             file://0001-cargo-do-not-write-host-information-into-compilation.patch;patchdir=${RUSTSRC} \
             file://rust-oe-selftest.patch;patchdir=${RUSTSRC} \
+            file://repro-issue-fix-with-cc-crate-hashmap.patch;patchdir=${RUSTSRC} \
 "
 SRC_URI[rust.sha256sum] = "805482b436442a6786d270cacbab8f00529e06141b27b7fb01909b97ce4f3464"