[CRIU] [PATCH] make: Be able to force turning off piegen

Cyrill Gorcunov gorcunov at openvz.org
Tue Jun 16 02:31:21 PDT 2015


For testing purpose we need to disable using of
piegen utility. So lets add PIEGEN make option
thus one can "PIEGEN=no make" to build criu
without piegen at all.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 Makefile         | 22 ++++++++++++++++------
 Makefile.config  |  3 +++
 pie/Makefile     |  2 +-
 pie/pie-relocs.h |  2 +-
 4 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index ea6a7c6c3b1d..6ed4c90807dc 100644
--- a/Makefile
+++ b/Makefile
@@ -118,6 +118,16 @@ export ARCH SRCARCH
 
 $(if $(wildcard $(ARCH_DIR)),,$(error "The architecture $(ARCH) isn't supported"))
 
+#
+# piegen might be disabled by hands. Don't use it  until
+# you know what you're doing.
+ifneq ($(filter i386 ia32 x86_64 ppc64le, $(ARCH)),)
+ifneq ($(PIEGEN),no)
+	piegen-y := y
+	export piegen-y
+endif
+endif
+
 cflags-y		+= -iquote include -iquote pie -iquote .
 cflags-y		+= -iquote $(ARCH_DIR) -iquote $(ARCH_DIR)/include
 cflags-y		+= -fno-strict-aliasing
@@ -152,8 +162,8 @@ ARCH-LIB	:= $(ARCH_DIR)/crtools.built-in.o
 CRIU-SO		:= libcriu
 CRIU-LIB	:= lib/$(CRIU-SO).so
 CRIU-INC	:= lib/criu.h include/criu-plugin.h include/criu-log.h protobuf/rpc.proto
-ifneq ($(filter i386 ia32 x86_64 ppc64le, $(ARCH)),)
-PIEGEN		:= pie/piegen/piegen
+ifeq ($(piegen-y),y)
+piegen		:= pie/piegen/piegen
 endif
 
 export CC MAKE CFLAGS LIBS SRCARCH DEFINES MAKEFLAGS CRIU-SO
@@ -197,20 +207,20 @@ $(ARCH_DIR)/%:: protobuf config
 $(ARCH_DIR): protobuf config
 	$(Q) $(MAKE) $(build)=$(ARCH_DIR) all
 
-ifneq ($(filter i386 ia32 x86_64 ppc64le, $(ARCH)),)
+ifeq ($(piegen-y),y)
 pie/piegen/%: config
 	$(Q) $(MAKE) $(build)=pie/piegen $@
 pie/piegen: config
 	$(Q) $(MAKE) $(build)=pie/piegen all
-$(PIEGEN): pie/piegen/built-in.o
+$(piegen): pie/piegen/built-in.o
 	$(E) "  LINK    " $@
 	$(Q) $(CC) $(CFLAGS) pie/piegen/built-in.o $(LDFLAGS) -o $@
 .PHONY: pie/piegen
 endif
 
-pie/%:: $(ARCH_DIR) $(PIEGEN)
+pie/%:: $(ARCH_DIR) $(piegen)
 	$(Q) $(MAKE) $(build)=pie $@
-pie: $(ARCH_DIR) $(PIEGEN)
+pie: $(ARCH_DIR) $(piegen)
 	$(Q) $(MAKE) $(build)=pie all
 
 %.o %.i %.s %.d: $(VERSION_HEADER) pie
diff --git a/Makefile.config b/Makefile.config
index e1d2a3b8d6b4..ce4b8d844982 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -41,6 +41,9 @@ endif
 ifeq ($(call try-cc,$(SETPROCTITLE_INIT_TEST),-lbsd),y)
 	$(Q) @echo '#define CONFIG_HAS_SETPROCTITLE_INIT' >> $@
 endif
+ifeq ($(piegen-y),y)
+	$(Q) @echo '#define CONFIG_PIEGEN' >> $@
+endif
 	$(Q) @echo '#endif /* __CR_CONFIG_H__ */' >> $@
 
 config: $(CONFIG)
diff --git a/pie/Makefile b/pie/Makefile
index f43746f38b71..03cd4bc2b546 100644
--- a/pie/Makefile
+++ b/pie/Makefile
@@ -52,7 +52,7 @@ PIELDS			:= pie.lds.S
 
 .SECONDARY:
 
-ifneq ($(filter i386 ia32 x86_64 ppc64le, $(ARCH)),)
+ifeq ($(piegen-y),y)
 ldflags-y += -r
 target-name = $(patsubst pie/%-blob.h,%,$(1))
 
diff --git a/pie/pie-relocs.h b/pie/pie-relocs.h
index 1caf266d0911..354aa9bbd478 100644
--- a/pie/pie-relocs.h
+++ b/pie/pie-relocs.h
@@ -6,7 +6,7 @@
 #include "compiler.h"
 #include "config.h"
 
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_32) || defined(CONFIG_PPC64)
+#ifdef CONFIG_PIEGEN
 
 extern __maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size,
 					    elf_reloc_t *elf_relocs, size_t nr_relocs);
-- 
2.4.3



More information about the CRIU mailing list