diff --git a/enable-CET.patch b/enable-CET.patch new file mode 100644 index 0000000000000000000000000000000000000000..335e95d33cdaf55e2f2669c35f4e205b1e20eb05 --- /dev/null +++ b/enable-CET.patch @@ -0,0 +1,38 @@ +From cd7620a730413a48843e175d34dc408c152f8125 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Tue, 11 Jan 2022 07:28:25 -0800 +Subject: [PATCH] x86-64: Enable Intel CET + +Intel Control-flow Enforcement Technology (CET): + +https://en.wikipedia.org/wiki/Control-flow_integrity#Intel_Control-flow_Enforcement_Technology + +requires that on Linux, all linker input files are marked as CET enabled +in .note.gnu.property section. For high-level language source codes, +.note.gnu.property section is added by compiler with the -fcf-protection +option. For assembly sources, include to add .note.gnu.property +section. +--- + lib/common/portability_macros.h | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/lib/common/portability_macros.h b/lib/common/portability_macros.h +index 627ef9eed4..6ac4b05510 100644 +--- a/lib/common/portability_macros.h ++++ b/lib/common/portability_macros.h +@@ -128,4 +128,15 @@ + # define ZSTD_ENABLE_ASM_X86_64_BMI2 0 + #endif + ++/* ++ * For x86 ELF targets, add .note.gnu.property section for Intel CET in ++ * assembly sources when CET is enabled. ++ */ ++#if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__)) \ ++ && defined(__has_include) ++# if __has_include() ++# include ++# endif ++#endif ++ + #endif /* ZSTD_PORTABILITY_MACROS_H */ diff --git a/pzstd.1.patch b/pzstd.1.patch new file mode 100644 index 0000000000000000000000000000000000000000..30243d4a3ef92f17165008ad50e0b5b8c63e3448 --- /dev/null +++ b/pzstd.1.patch @@ -0,0 +1,17 @@ +diff -Naur zstd-1.5.2.orig/programs/zstd.1 zstd-1.5.2/programs/zstd.1 +--- zstd-1.5.2.orig/programs/zstd.1 2022-01-20 21:17:18.000000000 +0000 ++++ zstd-1.5.2/programs/zstd.1 2022-01-22 17:40:54.130314058 +0000 +@@ -214,6 +214,13 @@ + . + .IP "\(bu" 4 + \fB\-\-\fR: All arguments after \fB\-\-\fR are treated as files ++ ++.SH Parallel Zstd OPTIONS ++Additional options for the pzstd utility ++.TP ++.BR \-p ", " --processes ++ number of threads to use for (de)compression (default:4) ++ + . + .IP "" 0 + . diff --git a/zstd-1.5.2.tar.zst b/zstd-1.5.2.tar.zst new file mode 100644 index 0000000000000000000000000000000000000000..61e5633328595163e600a1673233a880d1062bbd Binary files /dev/null and b/zstd-1.5.2.tar.zst differ diff --git a/zstd.spec b/zstd.spec new file mode 100644 index 0000000000000000000000000000000000000000..04350b6c1fa548359a72f52258ad6621fa28d9e8 --- /dev/null +++ b/zstd.spec @@ -0,0 +1,140 @@ +%define anolis_release 1 + +%bcond_without asm +%bcond_without lz4 +%bcond_without lzma +%bcond_without zlib +%ifarch x86_64 +%bcond_without pzstd +%else +%bcond_with pzstd +%endif + +Name: zstd +Version: 1.5.2 +Release: %{anolis_release}%{?dist} +Summary: Zstd compression library + +License: BSD and GPLv2 +URL: https://github.com/facebook/zstd +Source0: https://github.com/facebook/zstd/releases/download/v%{version}/%{name}-%{version}.tar.zst + +Patch1: pzstd.1.patch +Patch2: enable-CET.patch + +BuildRequires: make +BuildRequires: gcc gtest-devel +%if %{with lz4} +BuildRequires: lz4-devel +%endif +%if %{with lzma} +BuildRequires: xz-devel +%endif +%if %{with pzstd} +BuildRequires: gcc-c++ +%endif +%if %{with zlib} +BuildRequires: zlib-devel +%endif +BuildRequires: execstack + +%description +Zstd, short for Zstandard, is a fast lossless compression algorithm, +targeting real-time compression scenarios at zlib-level compression ratio. + +%package -n lib%{name} +Summary: Zstd shared library + +%description -n lib%{name} +Zstandard compression shared library. + +%package -n lib%{name}-devel +Summary: Header files for Zstd library +Requires: lib%{name}%{?_isa} = %{version}-%{release} + +%package -n lib%{name}-static +Summary: Static variant of the Zstd library +Requires: lib%{name}-devel = %{version}-%{release} + +%description -n lib%{name}-devel +Header files for Zstd library. + +%description -n lib%{name}-static +Static variant of the Zstd library. + +%prep +%setup -q +find -name .gitignore -delete +%if %{with pzstd} +%patch1 -p1 +%endif +%patch2 -p1 + +%build +export CFLAGS="$RPM_OPT_FLAGS" +export LDFLAGS="$RPM_LD_FLAGS" +export PREFIX="%{_prefix}" +export LIBDIR="%{_libdir}" +%make_build -C lib lib-mt %{!?with_asm:ZSTD_NO_ASM=1} +%make_build -C programs %{!?with_asm:ZSTD_NO_ASM=1} +%if %{with pzstd} +export CXXFLAGS="$RPM_OPT_FLAGS" +%make_build -C contrib/pzstd %{!?with_asm:ZSTD_NO_ASM=1} +%endif + +%check +execstack lib/libzstd.so.1 + +export CFLAGS="$RPM_OPT_FLAGS" +export LDFLAGS="$RPM_LD_FLAGS" +make -C tests test-zstd +%if %{with pzstd} +export CXXFLAGS="$RPM_OPT_FLAGS" +make -C contrib/pzstd test +%endif + +%install +%make_install PREFIX=%{_prefix} LIBDIR=%{_libdir} +%if %{with pzstd} +install -D -m755 contrib/pzstd/pzstd %{buildroot}%{_bindir}/pzstd +install -D -m644 programs/%{name}.1 %{buildroot}%{_mandir}/man1/p%{name}.1 +%endif + +%files +%doc CHANGELOG README.md +%{_bindir}/%{name} +%if %{with pzstd} +%{_bindir}/p%{name} +%{_mandir}/man1/p%{name}.1* +%endif +%{_bindir}/%{name}mt +%{_bindir}/un%{name} +%{_bindir}/%{name}cat +%{_bindir}/%{name}grep +%{_bindir}/%{name}less +%{_mandir}/man1/%{name}.1* +%{_mandir}/man1/un%{name}.1* +%{_mandir}/man1/%{name}cat.1* +%{_mandir}/man1/%{name}grep.1* +%{_mandir}/man1/%{name}less.1* +%license COPYING LICENSE + +%files -n lib%{name} +%{_libdir}/libzstd.so.* +%license COPYING LICENSE + +%files -n lib%{name}-devel +%{_includedir}/zdict.h +%{_includedir}/zstd.h +%{_includedir}/zstd_errors.h +%{_libdir}/pkgconfig/libzstd.pc +%{_libdir}/libzstd.so + +%files -n lib%{name}-static +%{_libdir}/libzstd.a + +%ldconfig_scriptlets -n lib%{name} + +%changelog +* Wed Mar 09 2022 zhang xianting - 1.5.2-1 +- Initial build for Anolis V23