summaryrefslogtreecommitdiffstats
path: root/rust/libmimalloc-sys-use-system.patch
diff options
context:
space:
mode:
authorMichel Alexandre Salim <salimma@fedoraproject.org>2022-04-04 12:03:27 -0700
committerMichel Alexandre Salim <salimma@fedoraproject.org>2022-04-04 12:10:26 -0700
commit5a3e4c03a2458e2f35cd1fc6f156d6f8dc90d650 (patch)
treefbc1cc5fc68a7999d3b6ea7ebca2a0c077cd4d9c /rust/libmimalloc-sys-use-system.patch
parent0fd1e4ab8441ccaa2a3b176208f52faf6c4b3cc9 (diff)
downloadspecs-5a3e4c03a2458e2f35cd1fc6f156d6f8dc90d650.tar.gz
specs-5a3e4c03a2458e2f35cd1fc6f156d6f8dc90d650.tar.xz
specs-5a3e4c03a2458e2f35cd1fc6f156d6f8dc90d650.zip
+ rust-libmimalloc-sys
Signed-off-by: Michel Alexandre Salim <salimma@fedoraproject.org>
Diffstat (limited to 'rust/libmimalloc-sys-use-system.patch')
-rw-r--r--rust/libmimalloc-sys-use-system.patch47
1 files changed, 47 insertions, 0 deletions
diff --git a/rust/libmimalloc-sys-use-system.patch b/rust/libmimalloc-sys-use-system.patch
new file mode 100644
index 0000000..1a90974
--- /dev/null
+++ b/rust/libmimalloc-sys-use-system.patch
@@ -0,0 +1,47 @@
+From 6d46e073040d03be4abffc599e11609febecf9fc Mon Sep 17 00:00:00 2001
+From: Michel Alexandre Salim <salimma@fedoraproject.org>
+Date: Mon, 4 Apr 2022 11:52:40 -0700
+Subject: [PATCH] Use system mimalloc if available
+
+When packaging for Fedora, bundled libraries are discouraged:
+https://docs.fedoraproject.org/en-US/fesco/Bundled_Software_policy/
+
+Build against the system mimalloc if we detect its header.
+
+Signed-off-by: Michel Alexandre Salim <salimma@fedoraproject.org>
+---
+ libmimalloc-sys/build.rs | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/libmimalloc-sys/build.rs b/libmimalloc-sys/build.rs
+index 7cc9379..1afdf18 100644
+--- a/libmimalloc-sys/build.rs
++++ b/libmimalloc-sys/build.rs
+@@ -1,15 +1,21 @@
+ use std::env;
++use std::path;
+
+ fn main() {
++ let target_os = env::var("CARGO_CFG_TARGET_OS").expect("target_os not defined!");
++ let target_family = env::var("CARGO_CFG_TARGET_FAMILY").expect("target_family not defined!");
++
++ // use system mimalloc if available
++ if target_family == "unix" && path::Path::new("/usr/include/mimalloc.h").exists() {
++ return
++ }
++
+ let mut build = cc::Build::new();
+
+ build.include("c_src/mimalloc/include");
+ build.include("c_src/mimalloc/src");
+ build.file("c_src/mimalloc/src/static.c");
+
+- let target_os = env::var("CARGO_CFG_TARGET_OS").expect("target_os not defined!");
+- let target_family = env::var("CARGO_CFG_TARGET_FAMILY").expect("target_family not defined!");
+-
+ if env::var_os("CARGO_FEATURE_OVERRIDE").is_some() {
+ // Overriding malloc is only available on windows in shared mode, but we
+ // only ever build a static lib.
+--
+2.35.1
+