$OpenBSD: patch-src_tools_cargo_src_cargo_core_compiler_context_compilation_files_rs,v 1.8 2019/09/29 08:23:17 semarie Exp $
For port tree, use a custom metadata generation method to have stable hash between archs.
Use an environment variable to use alternate method.

Index: src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs
--- src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs.orig
+++ src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs
@@ -504,6 +504,27 @@ fn compute_metadata<'a, 'cfg>(
 
     let mut hasher = SipHasher::new_with_keys(0, 0);
 
+    // Simplified version for OpenBSD port tree
+    if let Ok(port_version) = env::var("OPENBSD_PORTS_LANG_RUST_VERSION") {
+        port_version.hash(&mut hasher);
+
+        format!("{}", unit.pkg.package_id().name()).hash(&mut hasher);
+        format!("{}", unit.pkg.package_id().version()).hash(&mut hasher);
+
+        let mut dep_targets = cx.dep_targets(unit);
+        dep_targets.sort();
+        for dep in dep_targets {
+            format!("{}", dep.pkg.package_id().name()).hash(&mut hasher);
+            format!("{}", dep.pkg.package_id().version()).hash(&mut hasher);
+        }
+
+        if let Ok(ref channel) = __cargo_default_lib_metadata {
+            channel.hash(&mut hasher);
+        }
+
+        return Some(Metadata(hasher.finish()));
+    }
+
     // This is a generic version number that can be changed to make
     // backwards-incompatible changes to any file structures in the output
     // directory. For example, the fingerprint files or the build-script
