about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/debuginfo
diff options
context:
space:
mode:
authorb-naber <bn263@gmx.de>2022-06-14 10:50:20 +0200
committerb-naber <bn263@gmx.de>2022-06-14 16:12:34 +0200
commite14b34c386ad2809e937e0e6e0379c5cc5474954 (patch)
tree6fe4f81a06d5869ba2b18fe91a699e79fd74c49e /compiler/rustc_codegen_ssa/src/debuginfo
parent060acc97db878964b6229dc89a657201f4232b14 (diff)
downloadrust-e14b34c386ad2809e937e0e6e0379c5cc5474954.tar.gz
rust-e14b34c386ad2809e937e0e6e0379c5cc5474954.zip
account for endianness in debuginfo for const args
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/debuginfo')
-rw-r--r--compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
index 4ac3d2eaa0c..8755d91818d 100644
--- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
+++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
@@ -707,12 +707,15 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
                 hcx.while_hashing_spans(false, |hcx| ct.to_valtree().hash_stable(hcx, &mut hasher));
                 // Let's only emit 64 bits of the hash value. That should be plenty for
                 // avoiding collisions and will make the emitted type names shorter.
-                let hash: u64 = hasher.finish();
+                // Note: Don't use `StableHashResult` impl of `u64` here directly, since that
+                // would lead to endianness problems.
+                let hash: u128 = hasher.finish();
+                let hash_short = (hash.to_le() as u64).to_le();
 
                 if cpp_like_debuginfo(tcx) {
-                    write!(output, "CONST${:x}", hash)
+                    write!(output, "CONST${:x}", hash_short)
                 } else {
-                    write!(output, "{{CONST#{:x}}}", hash)
+                    write!(output, "{{CONST#{:x}}}", hash_short)
                 }
             }
         },