mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-28 12:57:57 +00:00
criu/pie/Makefile: simplify and fix
The way criu/pie/Makefile is currently written, ld is run twice: 1. link $(NAME-obj-y) objects to NAME.built-in.o 2. link NAME.built-in.o, pie.lib.a, and compel plugins to NAME.built-in.bin.o (with compel ldflags and linker script) There is absolutely no need for such two-stage linking, but it was OK. It is not OK now, as "compel ldflags" for ARM doesn't need -r, and we can't run the first stage with -r and the second stage without it. So, let's simplify linking using a single ld invocation. This is my third attempt in doing it, I think I nailed it this time -- it is now clean and (relatively) simple. While at it: - fix compel linker script dependency (it was not working); - rearrange the Makefile so variables goes first, then rules; - remove a comment about mount implementation in restorer. NOTE that compel is called with ./ prefix so the file paths it prints are also prefixed with ./, which is needed for objectify macro to ignore those. Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Kir Kolyshkin <kir@openvz.org> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
9cf884f02f
commit
37904cc91a
@ -1,4 +1,4 @@
|
|||||||
COMPEL_BIN := compel/compel-host
|
COMPEL_BIN := ./compel/compel-host
|
||||||
export COMPEL_BIN
|
export COMPEL_BIN
|
||||||
|
|
||||||
COMPEL_VERSION_HEADER := compel/include/version.h
|
COMPEL_VERSION_HEADER := compel/include/version.h
|
||||||
|
@ -1,7 +1,25 @@
|
|||||||
target += parasite restorer
|
target := parasite restorer
|
||||||
|
|
||||||
|
CFLAGS := $(filter-out -pg $(CFLAGS-GCOV) $(CFLAGS-ASAN),$(CFLAGS))
|
||||||
|
ccflags-y += $(COMPEL_UAPI_INCLUDES)
|
||||||
|
ccflags-y += -DCR_NOGLIBC
|
||||||
|
ccflags-y += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
|
||||||
|
ccflags-y += -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=0
|
||||||
|
|
||||||
|
ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
|
||||||
|
CFLAGS += $(shell $(COMPEL_BIN) cflags)
|
||||||
|
LDFLAGS += $(shell $(COMPEL_BIN) ldflags)
|
||||||
|
compel_plugins := $(shell $(COMPEL_BIN) plugins)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SRCARCH),arm)
|
||||||
|
ccflags-y += -marm
|
||||||
|
endif
|
||||||
|
|
||||||
|
asflags-y += -D__ASSEMBLY__
|
||||||
|
|
||||||
|
LDS := compel/arch/$(SRCARCH)/scripts/compel-pack.lds.S
|
||||||
|
|
||||||
parasite-obj-y += parasite.o
|
|
||||||
restorer-obj-y += restorer.o
|
|
||||||
restorer-obj-y += ./$(ARCH_DIR)/restorer.o
|
restorer-obj-y += ./$(ARCH_DIR)/restorer.o
|
||||||
|
|
||||||
ifeq ($(ARCH),x86)
|
ifeq ($(ARCH),x86)
|
||||||
@ -11,51 +29,20 @@ ifeq ($(ARCH),x86)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#
|
define gen-pie-rules
|
||||||
# We can't provide proper mount implementation
|
$(1)-obj-y += $(1).o
|
||||||
# in parasite code -- it requires run-time rellocation
|
$(1)-obj-e += pie.lib.a
|
||||||
# applications, which is not the target of the
|
$(1)-obj-e += $$(compel_plugins)
|
||||||
# project.
|
|
||||||
#
|
|
||||||
CFLAGS := $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))
|
|
||||||
CFLAGS := $(filter-out $(CFLAGS-ASAN),$(CFLAGS))
|
|
||||||
|
|
||||||
ccflags-y += $(COMPEL_UAPI_INCLUDES)
|
# Dependency on compel linker script, to relink if it has changed
|
||||||
ccflags-y += -DCR_NOGLIBC
|
$$(obj)/$(1).built-in.o: $$(LDS)
|
||||||
ccflags-y += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
|
|
||||||
ccflags-y += -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=0
|
|
||||||
|
|
||||||
ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
|
$$(obj)/$(1)-blob.h: $$(obj)/$(1).built-in.o
|
||||||
CFLAGS += $(shell $(COMPEL_BIN) cflags)
|
$$(call msg-gen, $$@)
|
||||||
compel_std := $(shell $(COMPEL_BIN) plugins)
|
$$(Q) $$(COMPEL_BIN) hgen -f $$< -o $$@
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(SRCARCH),arm)
|
all-y += $$(obj)/$(1)-blob.h
|
||||||
ccflags-y += -marm
|
cleanup-y += $$(obj)/$(1)-blob.h
|
||||||
endif
|
endef
|
||||||
|
|
||||||
asflags-y += -D__ASSEMBLY__
|
$(foreach t,$(target),$(eval $(call gen-pie-rules,$(t))))
|
||||||
|
|
||||||
BLOBS += $(obj)/restorer-blob.h $(obj)/parasite-blob.h
|
|
||||||
LDS := compel/arch/$(SRCARCH)/scripts/compel-pack.lds.S
|
|
||||||
|
|
||||||
.SECONDARY:
|
|
||||||
|
|
||||||
target-name = $(patsubst criu/pie/%-blob.h,%,$(1))
|
|
||||||
|
|
||||||
$(obj)/%.build-in.bin.o: $(LDS)
|
|
||||||
$(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(obj)/pie.lib.a $(compel_std)
|
|
||||||
$(call msg-gen, $@)
|
|
||||||
$(Q) $(LD) $(shell $(COMPEL_BIN) ldflags) -o $@ $^
|
|
||||||
|
|
||||||
$(obj)/%-blob.h: $(obj)/%.built-in.bin.o
|
|
||||||
$(call msg-gen, $@)
|
|
||||||
$(Q) $(COMPEL_BIN) hgen -f $< -o $@
|
|
||||||
|
|
||||||
all-y += $(BLOBS)
|
|
||||||
# blobs and pields are in cleanup, rather than in mrproper because
|
|
||||||
# we want them to be re-generated after `make clean && make`
|
|
||||||
cleanup-y += $(BLOBS)
|
|
||||||
cleanup-y += $(obj)/*.bin
|
|
||||||
cleanup-y += $(obj)/*.built-in.bin.o
|
|
||||||
cleanup-y += $(obj)/*.built-in.bin
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user