make: Add optional LZ4 support

Memory page compression requires liblz4, but making it mandatory would
prevent CRIU from building on systems that do not provide it.

Detect liblz4 with pkg-config and enable CONFIG_LZ4 only when it is
available. Add NO_LZ4=1 as an explicit opt-out and register the
development package in the supported distribution dependency lists.
Install liblz4 for the per-commit build, then run a separate NO_LZ4
build and unit test to keep the optional configuration usable.

Assisted-by: Codex:GPT-5
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov 2026-03-15 17:17:57 +00:00
parent 8851c1a26d
commit 1544013406
8 changed files with 20 additions and 1 deletions

View file

@ -19,7 +19,7 @@ jobs:
# Checkout pull request HEAD commit instead of merge commit
ref: ${{ github.event.pull_request.head.sha }}
- name: Install dependencies
run: sudo contrib/apt-install libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python3-protobuf libnl-3-dev libnet-dev libcap-dev uuid-dev
run: sudo contrib/apt-install libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python3-protobuf libnl-3-dev libnet-dev libcap-dev uuid-dev liblz4-dev
- name: Configure git user details
run: |
git config --global user.email "checkpoint-restore@users.noreply.github.com"
@ -28,3 +28,8 @@ jobs:
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
- name: Build each commit
run: git rebase ${{ github.base_ref }} -x "make -C scripts/ci check-commit"
- name: Build without LZ4
run: |
make mrproper
make -j "$(nproc)" NO_LZ4=1
make unittest NO_LZ4=1

View file

@ -237,6 +237,7 @@ else
export CONFIG_COMPAT := y
export CONFIG_GNUTLS := y
export CONFIG_HAS_LIBBPF := y
export CONFIG_LZ4 := y
endif
#

View file

@ -46,6 +46,14 @@ else
$(info $S Install gnutls-devel (RPM) or gnutls-dev (DEB) to fix.)
endif
ifeq ($(NO_LZ4)x$(call pkg-config-check,liblz4),xy)
LIBS_FEATURES += -llz4
export CONFIG_LZ4 := y
FEATURE_DEFINES += -DCONFIG_LZ4
else
$(info Note: Building without LZ4 compression support.)
endif
ifeq ($(call pkg-config-check,libnftables),y)
LIB_NFTABLES := $(shell $(PKG_CONFIG) --libs libnftables)
ifeq ($(call try-cc,$(FEATURE_TEST_NFTABLES_LIB_API_0),$(LIB_NFTABLES)),true)

View file

@ -19,6 +19,7 @@ apk add --no-cache \
libcap-dev \
libcap-utils \
libdrm-dev \
lz4-dev \
libnet-dev \
libnl3-dev \
libtraceevent-dev \

View file

@ -18,6 +18,7 @@ fi
libelf-dev:"${DEBIAN_ARCH}" \
libexpat1-dev:"${DEBIAN_ARCH}" \
libgnutls28-dev:"${DEBIAN_ARCH}" \
liblz4-dev:"${DEBIAN_ARCH}" \
libnet-dev:"${DEBIAN_ARCH}" \
libnftables-dev:"${DEBIAN_ARCH}" \
libnl-3-dev:"${DEBIAN_ARCH}" \

View file

@ -23,6 +23,7 @@ fi
libelf-dev \
libgnutls28-dev \
libgnutls30 \
liblz4-dev \
libnet-dev \
libnl-3-dev \
libnl-route-3-dev \

View file

@ -17,6 +17,7 @@ dnf install -y \
libbsd-devel \
libcap-devel \
libdrm-devel \
lz4-devel \
libnet-devel \
libnl3-devel \
libselinux-devel \

View file

@ -15,6 +15,7 @@ pacman -Syu --noconfirm \
libbsd \
libcap \
libdrm \
lz4 \
libelf \
libnet \
libnl \