diff options
author | Michel Alexandre Salim <salimma@fedoraproject.org> | 2022-04-04 12:03:27 -0700 |
---|---|---|
committer | Michel Alexandre Salim <salimma@fedoraproject.org> | 2022-04-04 12:10:26 -0700 |
commit | 5a3e4c03a2458e2f35cd1fc6f156d6f8dc90d650 (patch) | |
tree | fbc1cc5fc68a7999d3b6ea7ebca2a0c077cd4d9c /rust | |
parent | 0fd1e4ab8441ccaa2a3b176208f52faf6c4b3cc9 (diff) | |
download | specs-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')
-rw-r--r-- | rust/libmimalloc-sys-rust2rpm.conf | 3 | ||||
-rw-r--r-- | rust/libmimalloc-sys-use-system.patch | 47 | ||||
-rw-r--r-- | rust/rust-libmimalloc-sys.spec | 157 |
3 files changed, 207 insertions, 0 deletions
diff --git a/rust/libmimalloc-sys-rust2rpm.conf b/rust/libmimalloc-sys-rust2rpm.conf new file mode 100644 index 0000000..568a385 --- /dev/null +++ b/rust/libmimalloc-sys-rust2rpm.conf @@ -0,0 +1,3 @@ +[DEFAULT] +buildrequires = + cmake(mimalloc) 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 + diff --git a/rust/rust-libmimalloc-sys.spec b/rust/rust-libmimalloc-sys.spec new file mode 100644 index 0000000..0b0b03b --- /dev/null +++ b/rust/rust-libmimalloc-sys.spec @@ -0,0 +1,157 @@ +# Generated by rust2rpm 21 +%bcond_without check +%global debug_package %{nil} + +%global crate libmimalloc-sys + +Name: rust-%{crate} +Version: 0.1.24 +Release: %autorelease +Summary: Sys crate wrapping the mimalloc allocator + +# Upstream license specification: MIT +License: MIT +URL: https://crates.io/crates/libmimalloc-sys +Source: %{crates_source} +# Compile against system mimalloc-devel +Patch: %{crate}-use-system.patch + +ExclusiveArch: %{rust_arches} + +BuildRequires: rust-packaging >= 21 + +%global _description %{expand: +Sys crate wrapping the mimalloc allocator.} + +%description %{_description} + +%package devel +Summary: %{summary} +BuildArch: noarch + +%description devel %{_description} + +This package contains library source intended for building other packages which +use the "%{crate}" crate. + +%files devel +%license %{crate_instdir}/c_src/mimalloc/LICENSE +%{crate_instdir}/ + +%package -n %{name}+default-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+default-devel %{_description} + +This package contains library source intended for building other packages which +use the "default" feature of the "%{crate}" crate. + +%files -n %{name}+default-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+cty-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+cty-devel %{_description} + +This package contains library source intended for building other packages which +use the "cty" feature of the "%{crate}" crate. + +%files -n %{name}+cty-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+debug-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+debug-devel %{_description} + +This package contains library source intended for building other packages which +use the "debug" feature of the "%{crate}" crate. + +%files -n %{name}+debug-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+debug_in_debug-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+debug_in_debug-devel %{_description} + +This package contains library source intended for building other packages which +use the "debug_in_debug" feature of the "%{crate}" crate. + +%files -n %{name}+debug_in_debug-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+extended-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+extended-devel %{_description} + +This package contains library source intended for building other packages which +use the "extended" feature of the "%{crate}" crate. + +%files -n %{name}+extended-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+local_dynamic_tls-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+local_dynamic_tls-devel %{_description} + +This package contains library source intended for building other packages which +use the "local_dynamic_tls" feature of the "%{crate}" crate. + +%files -n %{name}+local_dynamic_tls-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+override-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+override-devel %{_description} + +This package contains library source intended for building other packages which +use the "override" feature of the "%{crate}" crate. + +%files -n %{name}+override-devel +%ghost %{crate_instdir}/Cargo.toml + +%package -n %{name}+secure-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+secure-devel %{_description} + +This package contains library source intended for building other packages which +use the "secure" feature of the "%{crate}" crate. + +%files -n %{name}+secure-devel +%ghost %{crate_instdir}/Cargo.toml + +%prep +%autosetup -n %{crate}-%{version_no_tilde} -p2 +%cargo_prep + +%generate_buildrequires +%cargo_generate_buildrequires +echo 'cmake(mimalloc)' + +%build +%cargo_build + +%install +%cargo_install + +%if %{with check} +%check +%cargo_test +%endif + +%changelog +%autochangelog |