diff --git a/.gitignore b/.gitignore index 236f765..604cc3d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /zstd-sys-1.6.1+zstd.1.5.0.crate /zstd-sys-1.6.2+zstd.1.5.1.crate /zstd-sys-1.6.3+zstd.1.5.2.crate +/zstd-sys-2.0.1+zstd.1.5.2.crate diff --git a/0001-unconditionally-use-bindgen-and-pkg-config-to-link-a.patch b/0001-unconditionally-use-bindgen-and-pkg-config-to-link-a.patch new file mode 100644 index 0000000..2d7a755 --- /dev/null +++ b/0001-unconditionally-use-bindgen-and-pkg-config-to-link-a.patch @@ -0,0 +1,209 @@ +From d68956f4ce606077a716b7fba3148d8986dd6165 Mon Sep 17 00:00:00 2001 +From: Fabio Valentini +Date: Sat, 6 Aug 2022 18:54:46 +0200 +Subject: [PATCH] unconditionally use bindgen and pkg-config to link against + system libzstd + +--- + build.rs | 170 +------------------------------------------------------ + 1 file changed, 1 insertion(+), 169 deletions(-) + +diff --git a/build.rs b/build.rs +index 83f2dc2..2336d61 100644 +--- a/build.rs ++++ b/build.rs +@@ -2,7 +2,6 @@ use std::ffi::OsStr; + use std::path::{Path, PathBuf}; + use std::{env, fs}; + +-#[cfg(feature = "bindgen")] + fn generate_bindings(defs: Vec<&str>, headerpaths: Vec) { + let bindings = bindgen::Builder::default() + .header("zstd.h"); +@@ -36,10 +35,6 @@ fn generate_bindings(defs: Vec<&str>, headerpaths: Vec) { + .expect("Could not write bindings"); + } + +-#[cfg(not(feature = "bindgen"))] +-fn generate_bindings(_: Vec<&str>, _: Vec) {} +- +-#[cfg(feature = "pkg-config")] + fn pkg_config() -> (Vec<&'static str>, Vec) { + let library = pkg_config::Config::new() + .statik(true) +@@ -49,171 +44,8 @@ fn pkg_config() -> (Vec<&'static str>, Vec) { + (vec!["PKG_CONFIG"], library.include_paths) + } + +-#[cfg(not(feature = "pkg-config"))] +-fn pkg_config() -> (Vec<&'static str>, Vec) { +- unimplemented!() +-} +- +-#[cfg(not(feature = "legacy"))] +-fn set_legacy(_config: &mut cc::Build) {} +- +-#[cfg(feature = "legacy")] +-fn set_legacy(config: &mut cc::Build) { +- config.define("ZSTD_LEGACY_SUPPORT", Some("1")); +- config.include("zstd/lib/legacy"); +-} +- +-#[cfg(feature = "zstdmt")] +-fn set_pthread(config: &mut cc::Build) { +- config.flag("-pthread"); +-} +- +-#[cfg(not(feature = "zstdmt"))] +-fn set_pthread(_config: &mut cc::Build) {} +- +-#[cfg(feature = "zstdmt")] +-fn enable_threading(config: &mut cc::Build) { +- config.define("ZSTD_MULTITHREAD", Some("")); +-} +- +-#[cfg(not(feature = "zstdmt"))] +-fn enable_threading(_config: &mut cc::Build) {} +- +-fn compile_zstd() { +- let mut config = cc::Build::new(); +- +- // Search the following directories for C files to add to the compilation. +- for dir in &[ +- "zstd/lib/common", +- "zstd/lib/compress", +- "zstd/lib/decompress", +- #[cfg(feature = "zdict_builder")] +- "zstd/lib/dictBuilder", +- #[cfg(feature = "legacy")] +- "zstd/lib/legacy", +- ] { +- for entry in fs::read_dir(dir).unwrap() { +- let path = entry.unwrap().path(); +- // Skip xxhash*.c files: since we are using the "PRIVATE API" +- // mode, it will be inlined in the headers. +- if path +- .file_name() +- .and_then(|p| p.to_str()) +- .map_or(false, |p| p.contains("xxhash")) +- { +- continue; +- } +- if path.extension() == Some(OsStr::new("c")) { +- config.file(path); +- } +- } +- } +- +- // Either include ASM files, or disable ASM entirely. +- // Also disable it on windows, apparently it doesn't do well with these .S files at the moment. +- if cfg!(any(target_os = "windows", feature = "no_asm")) { +- config.define("ZSTD_DISABLE_ASM", Some("")); +- } else { +- config.file("zstd/lib/decompress/huf_decompress_amd64.S"); +- } +- +- let is_wasm_unknown_unknown = env::var("TARGET").ok() == Some("wasm32-unknown-unknown".into()); +- +- if is_wasm_unknown_unknown { +- println!("cargo:rerun-if-changed=wasm-shim/stdlib.h"); +- println!("cargo:rerun-if-changed=wasm-shim/string.h"); +- +- config.include("wasm-shim/"); +- config.define("XXH_STATIC_ASSERT", Some("0")); +- } +- +- // Some extra parameters +- config.opt_level(3); +- config.include("zstd/lib/"); +- config.include("zstd/lib/common"); +- config.warnings(false); +- +- config.define("ZSTD_LIB_DEPRECATED", Some("0")); +- +- #[cfg(feature = "thin")] +- { +- config.define("HUF_FORCE_DECOMPRESS_X1", Some("1")); +- config.define("ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT", Some("1")); +- config.define("ZSTD_NO_INLINE ", Some("1")); +- config.flag_if_supported("-flto=thin"); +- config.flag_if_supported("-Oz"); +- } +- +- // Hide symbols from resulting library, +- // so we can be used with another zstd-linking lib. +- // See https://github.com/gyscos/zstd-rs/issues/58 +- config.flag("-fvisibility=hidden"); +- config.define("XXH_PRIVATE_API", Some("")); +- config.define("ZSTDLIB_VISIBILITY", Some("")); +- #[cfg(feature = "zdict_builder")] +- config.define("ZDICTLIB_VISIBILITY", Some("")); +- config.define("ZSTDERRORLIB_VISIBILITY", Some("")); +- +- // https://github.com/facebook/zstd/blob/d69d08ed6c83563b57d98132e1e3f2487880781e/lib/common/debug.h#L60 +- /* recommended values for DEBUGLEVEL : +- * 0 : release mode, no debug, all run-time checks disabled +- * 1 : enables assert() only, no display +- * 2 : reserved, for currently active debug path +- * 3 : events once per object lifetime (CCtx, CDict, etc.) +- * 4 : events once per frame +- * 5 : events once per block +- * 6 : events once per sequence (verbose) +- * 7+: events at every position (*very* verbose) +- */ +- #[cfg(feature = "debug")] +- if !is_wasm_unknown_unknown { +- config.define("DEBUGLEVEL", Some("5")); +- } +- +- set_pthread(&mut config); +- set_legacy(&mut config); +- enable_threading(&mut config); +- +- // Compile! +- config.compile("libzstd.a"); +- +- let src = env::current_dir().unwrap().join("zstd").join("lib"); +- let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); +- let include = dst.join("include"); +- fs::create_dir_all(&include).unwrap(); +- fs::copy(src.join("zstd.h"), include.join("zstd.h")).unwrap(); +- fs::copy(src.join("zstd_errors.h"), include.join("zstd_errors.h")) +- .unwrap(); +- #[cfg(feature = "zdict_builder")] +- fs::copy(src.join("zdict.h"), include.join("zdict.h")).unwrap(); +- println!("cargo:root={}", dst.display()); +-} +- + fn main() { +- let target_arch = +- std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); +- let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); +- +- if target_arch == "wasm32" || target_os == "hermit" { +- println!("cargo:rustc-cfg=feature=\"std\""); +- } +- +- // println!("cargo:rustc-link-lib=zstd"); +- let (defs, headerpaths) = if cfg!(feature = "pkg-config") { +- pkg_config() +- } else { +- if !Path::new("zstd/lib").exists() { +- panic!("Folder 'zstd/lib' does not exists. Maybe you forgot to clone the 'zstd' submodule?"); +- } +- +- let manifest_dir = PathBuf::from( +- env::var("CARGO_MANIFEST_DIR") +- .expect("Manifest dir is always set by cargo"), +- ); +- +- compile_zstd(); +- (vec![], vec![manifest_dir.join("zstd/lib")]) +- }; ++ let (defs, headerpaths) = pkg_config(); + + let includes: Vec<_> = headerpaths + .iter() +-- +2.37.1 + diff --git a/rust-zstd-sys.spec b/rust-zstd-sys.spec index fc9d47d..7794e3a 100644 --- a/rust-zstd-sys.spec +++ b/rust-zstd-sys.spec @@ -1,24 +1,26 @@ -# Generated by rust2rpm 21 +# Generated by rust2rpm 22 %bcond_without check %global debug_package %{nil} %global crate zstd-sys -%global upstream_version 1.6.3+zstd.1.5.2 +%global upstream_version 2.0.1+zstd.1.5.2 -Name: rust-%{crate} -Version: 1.6.3 +Name: rust-zstd-sys +Version: 2.0.1 Release: %autorelease Summary: Low-level bindings for the zstd compression library # Upstream license specification: MIT/Apache-2.0 -License: MIT or ASL 2.0 +License: MIT OR Apache-2.0 URL: https://crates.io/crates/zstd-sys Source: %{crates_source %{crate} %{upstream_version}} -# Initial patched metadata -# * Remove zstd version from version field -# * Make pkg-config and bindgen default features -# * Fix logic for included / excluded files -Patch0: zstd-sys-fix-metadata.diff +# Manually created patch for downstream crate metadata changes +# * remove zstd version from version field +# * make bindgen and pkg-config build-dependencies non-optional +# * fix logic for included / excluded files +Patch: zstd-sys-fix-metadata.diff +# * unconditionally use bindgen and pkg-config to link against system libzstd +Patch: 0001-unconditionally-use-bindgen-and-pkg-config-to-link-a.patch ExclusiveArch: %{rust_arches} @@ -166,6 +168,18 @@ use the "thin" feature of the "%{crate}" crate. %files -n %{name}+thin-devel %ghost %{crate_instdir}/Cargo.toml +%package -n %{name}+zdict_builder-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+zdict_builder-devel %{_description} + +This package contains library source intended for building other packages which +use the "zdict_builder" feature of the "%{crate}" crate. + +%files -n %{name}+zdict_builder-devel +%ghost %{crate_instdir}/Cargo.toml + %package -n %{name}+zstdmt-devel Summary: %{summary} BuildArch: noarch @@ -180,23 +194,23 @@ use the "zstdmt" feature of the "%{crate}" crate. %prep %autosetup -n %{crate}-%{upstream_version} -p1 -# Remove bundled zstd -rm -rfv zstd/ +# * remove bundled zstd sources +rm -vr zstd/ %cargo_prep %generate_buildrequires -%cargo_generate_buildrequires -a +%cargo_generate_buildrequires echo 'pkgconfig(libzstd)' %build -%cargo_build -a +%cargo_build %install -%cargo_install -a +%cargo_install %if %{with check} %check -%cargo_test -a +%cargo_test %endif %changelog diff --git a/.rust2rpm.conf b/rust2rpm.conf similarity index 100% rename from .rust2rpm.conf rename to rust2rpm.conf diff --git a/sources b/sources index c412e84..ecd9971 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (zstd-sys-1.6.3+zstd.1.5.2.crate) = a8aaa3ddb7295cdb12623d1b6b06e30a029bce42a825adb427594e030ba0a1e51bf499f462d42bae47cd75178761d0e5071e86b0bcb8d8ff9cc8ebff1406b689 +SHA512 (zstd-sys-2.0.1+zstd.1.5.2.crate) = a54ff4159640d31f898cbd374b9117d1e7ee4b54c5b4a8e1ed6286d9e954341e077088c52161e086ef0f28dfec13e03f64013712fa9bc59d471191cffd8e0e1e diff --git a/zstd-sys-fix-metadata.diff b/zstd-sys-fix-metadata.diff index 8138049..261e75f 100644 --- a/zstd-sys-fix-metadata.diff +++ b/zstd-sys-fix-metadata.diff @@ -1,25 +1,56 @@ ---- zstd-sys-1.6.3+zstd.1.5.2/Cargo.toml 1970-01-01T00:00:01+00:00 -+++ zstd-sys-1.6.3+zstd.1.5.2/Cargo.toml 2022-04-12T10:22:49.978386+00:00 -@@ -12,11 +12,11 @@ +--- zstd-sys-2.0.1+zstd.1.5.2/Cargo.toml 1970-01-01T00:00:01+00:00 ++++ zstd-sys-2.0.1+zstd.1.5.2/Cargo.toml 2022-08-06T17:03:27.974126+00:00 +@@ -12,20 +12,15 @@ [package] edition = "2018" name = "zstd-sys" --version = "1.6.3+zstd.1.5.2" -+version = "1.6.3" +-version = "2.0.1+zstd.1.5.2" ++version = "2.0.1" authors = ["Alexandre Bury "] build = "build.rs" links = "zstd" --include = ["/LICENSE", "/*.*", "/src/", "/zstd/LICENSE", "/zstd/COPYING", "/zstd/lib/**/*.c", "/zstd/lib/**/*.h", "/zstd/lib/**/*.S"] -+exclude = ["/test_it.sh", "/update_bindings.sh", "/update_zstd.sh"] +-include = [ +- "/LICENSE", +- "/*.*", +- "/src/", +- "/wasm-shim/**/*.h", +- "/zstd/LICENSE", +- "/zstd/COPYING", +- "/zstd/lib/**/*.c", +- "/zstd/lib/**/*.h", +- "/zstd/lib/**/*.S", ++exclude = [ ++ "/test_it.sh", ++ "/update_bindings.sh", ++ "/update_zstd.sh", ++ "/wasm-shim/", + ] description = "Low-level bindings for the zstd compression library." readme = "Readme.md" - keywords = ["zstd", "zstandard", "compression"] -@@ -44,7 +44,7 @@ +@@ -52,7 +47,6 @@ + + [build-dependencies.bindgen] + version = "0.59" +-optional = true + + [build-dependencies.cc] + version = "1.0.45" +@@ -60,9 +54,9 @@ + + [build-dependencies.pkg-config] + version = "0.3" +-optional = true [features] ++bindgen = [] debug = [] --default = ["legacy"] -+default = ["legacy", "pkg-config", "bindgen"] - experimental = [] + default = [ + "legacy", +@@ -72,6 +66,7 @@ legacy = [] no_asm = [] + non-cargo = [] ++pkg-config = [] + std = [] + thin = [] + zdict_builder = []