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

From: Efraim Flashner <[email-masked]>
Date: Tue, 18 Mar 2025 13:49:21 +0200

I'm not sure how I feel about this one.  On one hand the
unprefixed_malloc flag is definitely necessary.  On the other hand
sometimes we use libjemalloc.so and sometimes libjemalloc_pic.a, and I
don't remember when/why we use one over the other, other than "it just
works"

On Tue, Mar 18, 2025 at 03:24:21PM +0800, Hilton Chain wrote:
> 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
> 

-- 
Efraim Flashner   <[email-masked]>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted