From 52de4257fab3e770f73d5174c12a095b49572fba Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Fri, 17 Sep 2021 16:52:44 +0800 Subject: [PATCH] Add riscv64 support (#14) Signed-off-by: Felix Yan --- benches/roundtrip.rs | 1 + jemalloc-sys/build.rs | 5 +++++ src/lib.rs | 1 + 3 files changed, 7 insertions(+) diff --git a/benches/roundtrip.rs b/benches/roundtrip.rs index 6dfa362..767abe8 100644 --- a/benches/roundtrip.rs +++ b/benches/roundtrip.rs @@ -32,6 +32,7 @@ const MIN_ALIGN: usize = 8; target_arch = "powerpc64", target_arch = "powerpc64le", target_arch = "mips64", + target_arch = "riscv64", target_arch = "s390x", target_arch = "sparc64" )))] diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index 95d1437..f1828c4 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -309,6 +309,11 @@ fn main() { } else if !target.contains("windows") { println!("cargo:rustc-link-lib=pthread"); } + // GCC may generate a __atomic_exchange_1 library call which requires -latomic + // during the final linking. https://github.com/riscv-collab/riscv-gcc/issues/12 + if target.contains("riscv") { + println!("cargo:rustc-link-lib=atomic"); + } println!("cargo:rerun-if-changed=jemalloc"); } diff --git a/src/lib.rs b/src/lib.rs index 5c53285..bea6caf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,6 +54,7 @@ const ALIGNOF_MAX_ALIGN_T: usize = 8; target_arch = "powerpc64", target_arch = "powerpc64le", target_arch = "mips64", + target_arch = "riscv64", target_arch = "s390x", target_arch = "sparc64" )))]