[Pkg-rust-maintainers] Bug#1082084: rust-criterion-cycles-per-byte: please add support for loong64

wuruilong wuruilong at loongson.cn
Wed Sep 18 08:23:13 BST 2024


Source: rust-criterion-cycles-per-byte
Version: 0.5.0-1
Severity: normal
X-Debbugs-Cc: wuruilong at loongson.cn

Dear Maintainer,

rust-criterion-cycles-per-byte compiled incorrectly on the loongarch platform, the attached patch fixes the problem. I have verified on loongarch that the package compiles successfully.

wuruilong

-- System Information:
Debian Release: trixie/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: loong64 (loongarch64)

Kernel: Linux 5.10.0-60.96.0.126.oe2203.loongarch64 (SMP w/32 CPU threads)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect
-------------- next part --------------
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 rust-criterion-cycles-per-byte (0.5.0-1) unstable; urgency=medium
 .
   * Package criterion-cycles-per-byte 0.5.0 from crates.io using debcargo 2.6.0
Author: Jelmer Vernoo? <jelmer at debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2024-09-18

--- rust-criterion-cycles-per-byte-0.5.0.orig/src/lib.rs
+++ rust-criterion-cycles-per-byte-0.5.0/src/lib.rs
@@ -30,8 +30,12 @@ use criterion::{
     Throughput,
 };
 
-#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
-compile_error!("criterion-cycles-per-byte currently relies on x86 or x86_64.");
+#[cfg(not(any(
+    target_arch = "x86_64",
+    target_arch = "x86",
+    target_arch = "loongarch64"
+)))]
+compile_error!("criterion-cycles-per-byte currently relies on x86 or x86_64 or loongarch64.");
 
 /// `CyclesPerByte` measures clock cycles using the x86 or x86_64 `rdtsc` instruction. `cpb` is
 /// the preferred measurement for cryptographic algorithms.
@@ -48,6 +52,18 @@ fn rdtsc() -> u64 {
     unsafe {
         core::arch::x86::_rdtsc()
     }
+
+    #[cfg(target_arch = "loongarch64")]
+    unsafe {
+        let counter: u64;
+
+        core::arch::asm!(
+            "rdtime.d {0}, $zero",
+            out(reg) counter,
+        );
+
+        counter
+    }
 }
 
 impl Measurement for CyclesPerByte {


More information about the Pkg-rust-maintainers mailing list