Subject: [bug#77093] [PATCH rust-team 08/18] build/cargo: Use system jemalloc.

From: Hilton Chain <[email-masked]>
Date: Tue, 18 Mar 2025 15:24:21 +0800

From: Efraim Flashner <[email-masked]>

* guix/build/cargo-build-system.scm (configure): Set environment variables to
use system jemalloc.

Change-Id: Ibb1c025c7354ba2befd2770e3f1ccd785baa06c3
Modified-by: Hilton Chain <[email-masked]>
---
 guix/build/cargo-build-system.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index a1c4f556bb..b547421b88 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -248,6 +248,12 @@ (define* (configure #:key inputs
   (setenv "LIBSSH2_SYS_USE_PKG_CONFIG" "1")
   (setenv "SODIUM_USE_PKG_CONFIG" "1")
   (setenv "ZSTD_SYS_USE_PKG_CONFIG" "1")
+  ;; This flag is needed when not using the bundled jemalloc.
+  ;; https://github.com/tikv/jemallocator/issues/19
+  (setenv "CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS" "1")
+  (when (assoc-ref inputs "jemalloc")
+    (setenv "JEMALLOC_OVERRIDE"
+            (string-append (assoc-ref inputs "jemalloc") "/lib/libjemalloc.so")))
   (when (assoc-ref inputs "openssl")
     (setenv "OPENSSL_DIR" (assoc-ref inputs "openssl")))
   (when (assoc-ref inputs "gettext")
-- 
2.48.1