mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
1. For some reason, Marier distribution headers
not correctly define __GLIBC_HAVE_KERNEL_RSEQ
compile-time constant. It remains undefined,
but in fact header files provides corresponding
rseq types declaration which leads to conflict.
2. Another issue, is that they use uint*_t types
instead of __u* types as in original rseq.h.
This leads to compile time issues like this:
format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'uint64_t' {aka 'long unsigned int'}
and we can't even replace %llx to %PRIx64 because it will break
compilation on other distros (like Fedora) with analogical error:
error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘__u64’ {aka ‘long long unsigned int’}
Let's use our-own struct rseq copy fully equal to the kernel one,
it's safe because this structure is a part of Linux Kernel ABI.
Fixes #1934
Reported-by: Nikola Bojanic
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
103 lines
3.5 KiB
Text
103 lines
3.5 KiB
Text
include $(__nmk_dir)utils.mk
|
|
include $(__nmk_dir)msg.mk
|
|
include scripts/feature-tests.mak
|
|
|
|
ifeq ($(call try-cc,$(FEATURE_TEST_LIBBSD_DEV),-lbsd),true)
|
|
LIBS_FEATURES += -lbsd
|
|
FEATURE_DEFINES += -DCONFIG_HAS_LIBBSD
|
|
else
|
|
$(info Note: Building without setproctitle() and strlcpy() support.)
|
|
$(info $(info) To enable these features, please install libbsd-devel (RPM) / libbsd-dev (DEB).)
|
|
endif
|
|
|
|
ifeq ($(call pkg-config-check,libselinux),y)
|
|
LIBS_FEATURES += -lselinux
|
|
FEATURE_DEFINES += -DCONFIG_HAS_SELINUX
|
|
endif
|
|
|
|
ifeq ($(call pkg-config-check,libbpf),y)
|
|
LIBS_FEATURES += -lbpf
|
|
FEATURE_DEFINES += -DCONFIG_HAS_LIBBPF
|
|
export CONFIG_HAS_LIBBPF := y
|
|
endif
|
|
|
|
ifeq ($(call pkg-config-check,libdrm),y)
|
|
export CONFIG_AMDGPU := y
|
|
$(info Note: Building criu with amdgpu_plugin.)
|
|
else
|
|
$(info Note: Building criu without amdgpu_plugin.)
|
|
$(info Note: libdrm and libdrm_amdgpu are required to build amdgpu_plugin.)
|
|
endif
|
|
|
|
ifeq ($(NO_GNUTLS)x$(call pkg-config-check,gnutls),xy)
|
|
LIBS_FEATURES += -lgnutls
|
|
export CONFIG_GNUTLS := y
|
|
FEATURE_DEFINES += -DCONFIG_GNUTLS
|
|
else
|
|
$(info Note: Building without GnuTLS 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)
|
|
LIBS_FEATURES += $(LIB_NFTABLES)
|
|
FEATURE_DEFINES += -DCONFIG_HAS_NFTABLES_LIB_API_0
|
|
else ifeq ($(call try-cc,$(FEATURE_TEST_NFTABLES_LIB_API_1),$(LIB_NFTABLES)),true)
|
|
LIBS_FEATURES += $(LIB_NFTABLES)
|
|
FEATURE_DEFINES += -DCONFIG_HAS_NFTABLES_LIB_API_1
|
|
else
|
|
$(warning Warn: you have libnftables installed but it has incompatible API)
|
|
$(warning Warn: Building without nftables support)
|
|
endif
|
|
else
|
|
$(warning Warn: you have no libnftables installed)
|
|
$(warning Warn: Building without nftables support)
|
|
endif
|
|
|
|
export LIBS += $(LIBS_FEATURES)
|
|
|
|
CONFIG_FILE = .config
|
|
|
|
$(CONFIG_FILE):
|
|
touch $(CONFIG_FILE)
|
|
|
|
ifeq ($(ARCH),x86)
|
|
# CONFIG_COMPAT is only for x86 now, no need for compile-test other archs
|
|
ifeq ($(call try-asm,$(FEATURE_TEST_X86_COMPAT)),true)
|
|
export CONFIG_COMPAT := y
|
|
FEATURE_DEFINES += -DCONFIG_COMPAT
|
|
else
|
|
$(info Note: Building without ia32 C/R, missed ia32 support in gcc)
|
|
$(info $(info) That may be related to missing gcc-multilib in your)
|
|
$(info $(info) distribution or you may have Debian with buggy toolchain)
|
|
$(info $(info) (issue https://github.com/checkpoint-restore/criu/issues/315))
|
|
endif
|
|
endif
|
|
|
|
export DEFINES += $(FEATURE_DEFINES)
|
|
export CFLAGS += $(FEATURE_DEFINES)
|
|
|
|
FEATURES_LIST := TCP_REPAIR STRLCPY STRLCAT PTRACE_PEEKSIGINFO \
|
|
SETPROCTITLE_INIT MEMFD TCP_REPAIR_WINDOW FSCONFIG MEMFD_CREATE \
|
|
OPENAT2 NO_LIBC_RSEQ_DEFS
|
|
|
|
# $1 - config name
|
|
define gen-feature-test
|
|
ifeq ($$(call try-cc,$$(FEATURE_TEST_$(1)),$$(LIBS_FEATURES),$$(DEFINES)),true)
|
|
$(Q) echo '#define CONFIG_HAS_$(1)' >> $$@
|
|
$(Q) echo '' >> $$@
|
|
endif
|
|
endef
|
|
|
|
define config-header-rule
|
|
$(CONFIG_HEADER): scripts/feature-tests.mak $(CONFIG_FILE)
|
|
$(call msg-gen, $$@)
|
|
$(Q) echo '#ifndef __CR_CONFIG_H__' > $$@
|
|
$(Q) echo '#define __CR_CONFIG_H__' >> $$@
|
|
$(Q) echo '' >> $$@
|
|
$(call map,gen-feature-test,$(FEATURES_LIST))
|
|
$(Q) cat $(CONFIG_FILE) | sed -n -e '/^[^#]/s/^/#define CONFIG_/p' >> $$@
|
|
$(Q) echo '#endif /* __CR_CONFIG_H__ */' >> $$@
|
|
endef
|
|
|
|
$(eval $(config-header-rule))
|