Initial commit on c10s

... (RHEL-46071)

Resolves: RHEL-46071

Signed-off-by: Vladis Dronov <vdronov@redhat.com>
This commit is contained in:
Vladis Dronov 2024-10-29 19:58:19 +01:00
parent 7d488857d5
commit f2f0215f3c
5 changed files with 169 additions and 0 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
/qat-zstd-plugin-*.tar.gz

46
lib-version.patch Normal file
View File

@ -0,0 +1,46 @@
--- a/src/Makefile 2024-10-09 18:14:19.453675299 +0300
+++ b/src/Makefile 2024-10-09 18:25:13.601675269 +0300
@@ -79,18 +79,27 @@
QATFLAGS += -O3
endif
+VERSION_MAJOR=0
+VERSION_MINOR=2
+VERSION_PATCH=0
+VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
+
qatseqprod.o: qatseqprod.c
$(CC) -c $(CFLAGS) $(QATFLAGS) $(DEBUGFLAGS) $^ -o $@
lib: qatseqprod.o
$(AR) rc libqatseqprod.a $^
- $(CC) -shared $^ $(LDFLAGS) -o libqatseqprod.so
+ $(CC) -shared $^ $(LDFLAGS) -Wl,-soname,libqatseqprod.so.$(VERSION_MAJOR) -o libqatseqprod.so.$(VERSION)
+ ln -sf libqatseqprod.so.$(VERSION) libqatseqprod.so.$(VERSION_MAJOR)
+ ln -sf libqatseqprod.so.$(VERSION_MAJOR) libqatseqprod.so
.PHONY: install
install: lib
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
[ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
- $(INSTALL_PROGRAM) libqatseqprod.so $(DESTDIR)$(LIBDIR)
+ $(INSTALL_PROGRAM) libqatseqprod.so.$(VERSION) $(DESTDIR)$(LIBDIR)
+ ln -sf libqatseqprod.so.$(VERSION) $(DESTDIR)$(LIBDIR)/libqatseqprod.so.$(VERSION_MAJOR)
+ ln -sf libqatseqprod.so.$(VERSION_MAJOR) $(DESTDIR)$(LIBDIR)/libqatseqprod.so
$(INSTALL_DATA) libqatseqprod.a $(DESTDIR)$(LIBDIR)
$(INSTALL_DATA) qatseqprod.h $(DESTDIR)$(INCLUDEDIR)
@echo qatseqprod library successfully installed
@@ -98,10 +107,12 @@
.PHONY: uninstall
uninstall:
$(RM) $(LIBDIR)/libqatseqprod.a
+ $(RM) $(LIBDIR)/libqatseqprod.so.$(VERSION)
+ $(RM) $(LIBDIR)/libqatseqprod.so.$(VERSION_MAJOR)
$(RM) $(LIBDIR)/libqatseqprod.so
$(RM) $(INCLUDEDIR)/qatseqprod.h
@echo qatseqprod library successfully uninstalled
clean:
$(RM) *.o
- $(RM) libqatseqprod.a libqatseqprod.so
+ $(RM) libqatseqprod.a libqatseqprod.so libqatseqprod.so.$(VERSION) libqatseqprod.so.$(VERSION_MAJOR)

73
qat-zstd-plugin.spec Normal file
View File

@ -0,0 +1,73 @@
Name: qat-zstd-plugin
Version: 0.2.0
Release: %autorelease
Summary: Intel QuickAssist Technology ZSTD Plugin
License: BSD-3-Clause
URL: https://github.com/intel/QAT-ZSTD-Plugin
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
Patch0: lib-version.patch
Patch1: test.patch
BuildRequires: automake
BuildRequires: gcc
BuildRequires: libzstd-devel
BuildRequires: qatlib-devel
# Upstream only supports x86_64
ExclusiveArch: x86_64
%description
Intel QuickAssist Technology ZSTD is a plugin to Zstandard for accelerating
compression by QAT. ZSTD* is a fast lossless compression algorithm, targeting
real-time compression scenarios at zlib-level and better compression ratios.
%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
The %{name}-devel package contains libraries and header files for
applications that use %{name}.
%package static
Summary: Static library for %{name}
Requires: %{name}-devel%{?_isa} = %{version}-%{release}
%description static
The %{name}-static package contains the static %{name} library.
%prep
%autosetup -p1 -n QAT-ZSTD-Plugin-%{version}
# fedora/rhel path fixes
sed -i -e 's|/usr/local|%{_prefix}|g' src/Makefile
sed -i -e 's|$(PREFIX)/lib|%{_libdir}|g' src/Makefile
sed -i -e 's|$(PREFIX)/include|%{_includedir}|g' src/Makefile
%build
%make_build LDFLAGS="$LDFLAGS -lzstd"
make test
%install
%make_install
%check
LD_LIBRARY_PATH=%{buildroot}%{_libdir} ./test/test README.md
%files
%license LICENSE
%{_libdir}/libqatseqprod.so.0
%{_libdir}/libqatseqprod.so.%{version}
%files devel
%{_includedir}/qatseqprod.h
%{_libdir}/libqatseqprod.so
%files static
%license LICENSE
%{_libdir}/libqatseqprod.a
%changelog
%autochangelog

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (qat-zstd-plugin-0.2.0.tar.gz) = 9039a346d85bed9a84326a6e664de8d0203b92b167468fd5d7d67ff96be08b3edaba92e28a900ba53440eaed66b3621db72c6a3d1200b74b0893b7ba8a6bf21a

48
test.patch Normal file
View File

@ -0,0 +1,48 @@
--- a/test/Makefile
+++ b/test/Makefile
@@ -34,24 +34,12 @@
# #######################################################################
LIB = ../src
-LDFLAGS = $(LIB)/libqatseqprod.a -I$(LIB)
+LDFLAGS = -L$(LIB) -I$(LIB)
ifneq ($(ICP_ROOT), )
LDFLAGS += -lqat_s -lusdm_drv_s -Wl,-rpath,$(ICP_ROOT)/build -L$(ICP_ROOT)/build
else
- LDFLAGS += -lqat -lusdm
-endif
-
-ifdef ZSTDLIB
-LDFLAGS += $(ZSTDLIB)/libzstd.a
-else
-ZSTDLIB := $(shell find /usr /lib /local -name 'libzstd.a' 2>/dev/null | head -n 1)
-ZSTDLIB ?= /usr/local/lib/libzstd.a
-ifneq ("$(wildcard $(ZSTDLIB))","")
- LDFLAGS += $(ZSTDLIB)
-else
- $(error libzstd.a not found, please install libzstd or specify the path manually)
-endif
+ LDFLAGS += -lzstd -lqatseqprod -lqat -lusdm
endif
default: test benchmark
--- a/test/test.c
+++ b/test/test.c
@@ -44,9 +44,6 @@
#include "qatseqprod.h"
-#ifndef ZSTD_STATIC_LINKING_ONLY
-#define ZSTD_STATIC_LINKING_ONLY
-#endif
#include "zstd.h"
#include "zstd_errors.h"
@@ -143,4 +140,4 @@
free(dstBuffer);
free(decompBuffer);
return 0;
-}
\ No newline at end of file
+}