mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 09:58:09 +00:00
compel cli: show includes
1. Add "compel includes" command, to be used for parasite *loading* code compilation. 2. Add includes to output of "compel cflags", which is used for parasite code compilation. Now, this patch looks big and complex, this is mostly because we want compel cli to work for both uninstalled (right from the source tree) and installed cases. The paths to be printed are quite different for these two cases, so I had to introduce a wrapper for a non-installed case. The wrapper sets an environment variable, which compel binary uses as a path to non-installed file. If this env var is not set, it means compel is installed so no tricks are needed. Note the wrapper is only provided for the compel-host binary, as compel (which differs from compel-host in case of cross-compiling) is not executed from within the source tree. Because of the wrapper, the original binary had to be renamed, thus the changes to Makefiles and .gitignore. travis-ci: success for More polishing for compel cli Signed-off-by: Kir Kolyshkin <kir@openvz.org> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
f53189c520
commit
51c4569cd9
2
.gitignore
vendored
2
.gitignore
vendored
@ -17,7 +17,7 @@ tags
|
|||||||
TAGS
|
TAGS
|
||||||
Makefile.local
|
Makefile.local
|
||||||
compel/compel
|
compel/compel
|
||||||
compel/compel-host
|
compel/compel-host-bin
|
||||||
images/*.c
|
images/*.c
|
||||||
images/*.h
|
images/*.h
|
||||||
images/google/protobuf/*.c
|
images/google/protobuf/*.c
|
||||||
|
4
Makefile
4
Makefile
@ -222,9 +222,9 @@ $(SOCCR_A): |soccr/built-in.o
|
|||||||
#
|
#
|
||||||
# But note that we're already included
|
# But note that we're already included
|
||||||
# the nmk so we can reuse it there.
|
# the nmk so we can reuse it there.
|
||||||
criu/%: images/built-in.o compel/plugins/std.built-in.o compel/libcompel.a compel/compel-host $(VERSION_HEADER) .FORCE
|
criu/%: images/built-in.o compel/plugins/std.built-in.o compel/libcompel.a compel/compel-host-bin $(VERSION_HEADER) .FORCE
|
||||||
$(Q) $(MAKE) $(build)=criu $@
|
$(Q) $(MAKE) $(build)=criu $@
|
||||||
criu: images/built-in.o compel/plugins/std.built-in.o compel/libcompel.a compel/compel-host $(SOCCR_A) $(VERSION_HEADER)
|
criu: images/built-in.o compel/plugins/std.built-in.o compel/libcompel.a compel/compel-host-bin $(SOCCR_A) $(VERSION_HEADER)
|
||||||
$(Q) $(MAKE) $(build)=criu all
|
$(Q) $(MAKE) $(build)=criu all
|
||||||
.PHONY: criu
|
.PHONY: criu
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ include $(SRC_DIR)/Makefile.versions
|
|||||||
|
|
||||||
COMPEL_SO_VERSION := $(COMPEL_SO_VERSION_MAJOR)$(if $(COMPEL_SO_VERSION_MINOR),.$(COMPEL_SO_VERSION_MINOR))$(if $(COMPEL_SO_VERSION_SUBLEVEL),.$(COMPEL_SO_VERSION_SUBLEVEL))
|
COMPEL_SO_VERSION := $(COMPEL_SO_VERSION_MAJOR)$(if $(COMPEL_SO_VERSION_MINOR),.$(COMPEL_SO_VERSION_MINOR))$(if $(COMPEL_SO_VERSION_SUBLEVEL),.$(COMPEL_SO_VERSION_SUBLEVEL))
|
||||||
COMPEL_SO_VERSION_CODE := $(shell expr $(COMPEL_SO_VERSION_MAJOR) \* 65536 \+ $(COMPEL_SO_VERSION_MINOR) \* 256 \+ $(COMPEL_SO_VERSION_SUBLEVEL))
|
COMPEL_SO_VERSION_CODE := $(shell expr $(COMPEL_SO_VERSION_MAJOR) \* 65536 \+ $(COMPEL_SO_VERSION_MINOR) \* 256 \+ $(COMPEL_SO_VERSION_SUBLEVEL))
|
||||||
|
ccflags-y += -DINCLUDEDIR=\"$(INCLUDEDIR)\"
|
||||||
ccflags-y += -iquote compel/arch/$(ARCH)/src/lib/include
|
ccflags-y += -iquote compel/arch/$(ARCH)/src/lib/include
|
||||||
ccflags-y += -iquote compel/include
|
ccflags-y += -iquote compel/include
|
||||||
ccflags-y += -iquote compel/plugins/include
|
ccflags-y += -iquote compel/plugins/include
|
||||||
@ -45,8 +46,8 @@ endif
|
|||||||
|
|
||||||
host-ccflags-y += $(ccflags-y)
|
host-ccflags-y += $(ccflags-y)
|
||||||
|
|
||||||
hostprogs-y += compel-host
|
hostprogs-y += compel-host-bin
|
||||||
compel-host-objs := $(patsubst %.o,%-host.o,$(obj-y) $(host-lib-y))
|
compel-host-bin-objs := $(patsubst %.o,%-host.o,$(obj-y) $(host-lib-y))
|
||||||
|
|
||||||
ifeq ($(ARCH),x86)
|
ifeq ($(ARCH),x86)
|
||||||
HOSTCFLAGS_handle-elf-32-host.o += -UCONFIG_X86_64 -DCONFIG_X86_32
|
HOSTCFLAGS_handle-elf-32-host.o += -UCONFIG_X86_64 -DCONFIG_X86_32
|
||||||
@ -54,7 +55,7 @@ HOSTCFLAGS_handle-elf-32-host.d += -UCONFIG_X86_64 -DCONFIG_X86_32
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
cleanup-y += compel/compel
|
cleanup-y += compel/compel
|
||||||
cleanup-y += compel/compel-host
|
cleanup-y += compel/compel-host-bin
|
||||||
cleanup-y += compel/libcompel.so
|
cleanup-y += compel/libcompel.so
|
||||||
|
|
||||||
install: compel/compel compel/$(LIBCOMPEL_SO) compel/$(LIBCOMPEL_A)
|
install: compel/compel compel/$(LIBCOMPEL_SO) compel/$(LIBCOMPEL_A)
|
||||||
|
8
compel/compel-host
Executable file
8
compel/compel-host
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# A wrapper to use compel-host right from the source dir
|
||||||
|
# (i.e. when it is not yet installed).
|
||||||
|
|
||||||
|
COMPEL_UNINSTALLED_ROOTDIR=$(dirname "$0")
|
||||||
|
export COMPEL_UNINSTALLED_ROOTDIR
|
||||||
|
exec "${COMPEL_UNINSTALLED_ROOTDIR}/compel-host-bin" "$@"
|
@ -48,6 +48,7 @@ static const flags_t flags = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
piegen_opt_t opts = {};
|
piegen_opt_t opts = {};
|
||||||
|
const char *uninst_root;
|
||||||
|
|
||||||
static int piegen(void)
|
static int piegen(void)
|
||||||
{
|
{
|
||||||
@ -114,7 +115,7 @@ static int usage(int rc) {
|
|||||||
|
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
" compel [--compat] cflags | ldflags\n"
|
" compel [--compat] includes | cflags | ldflags\n"
|
||||||
" compel -f FILE -o FILE -p NAME [-l N] hgen\n"
|
" compel -f FILE -o FILE -p NAME [-l N] hgen\n"
|
||||||
" -f, --file FILE input (parasite object) file name\n"
|
" -f, --file FILE input (parasite object) file name\n"
|
||||||
" -o, --output FILE output (header) file name\n"
|
" -o, --output FILE output (header) file name\n"
|
||||||
@ -128,9 +129,35 @@ static int usage(int rc) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_includes(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
/* list of standard include dirs (built into C preprocessor) */
|
||||||
|
const char *standard_includes[] = {
|
||||||
|
"/usr/include",
|
||||||
|
"/usr/local/include",
|
||||||
|
};
|
||||||
|
|
||||||
|
/* I am not installed, called via a wrapper */
|
||||||
|
if (uninst_root) {
|
||||||
|
printf("-I %s/include/uapi\n", uninst_root);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* I am installed
|
||||||
|
* Make sure to not print banalities */
|
||||||
|
for (i = 0; i < ARRAY_SIZE(standard_includes); i++)
|
||||||
|
if (strcmp(INCLUDEDIR, standard_includes[i]) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Finally, print our non-standard include path */
|
||||||
|
printf("%s\n", "-I " INCLUDEDIR);
|
||||||
|
}
|
||||||
|
|
||||||
static void print_cflags(bool compat)
|
static void print_cflags(bool compat)
|
||||||
{
|
{
|
||||||
printf("%s\n", compat ? flags.cflags_compat : flags.cflags);
|
printf("%s\n", compat ? flags.cflags_compat : flags.cflags);
|
||||||
|
print_includes();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -152,6 +179,8 @@ int main(int argc, char *argv[])
|
|||||||
{ },
|
{ },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uninst_root = getenv("COMPEL_UNINSTALLED_ROOTDIR");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
idx = -1;
|
idx = -1;
|
||||||
opt = getopt_long(argc, argv, short_opts, long_opts, &idx);
|
opt = getopt_long(argc, argv, short_opts, long_opts, &idx);
|
||||||
@ -195,6 +224,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
action = argv[optind++];
|
action = argv[optind++];
|
||||||
|
|
||||||
|
if (!strcmp(action, "includes")) {
|
||||||
|
print_includes();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!strcmp(action, "cflags")) {
|
if (!strcmp(action, "cflags")) {
|
||||||
print_cflags(compat);
|
print_cflags(compat);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3,7 +3,6 @@ CFLAGS ?= -O2 -g -Wall -Werror
|
|||||||
ARCH ?= x86
|
ARCH ?= x86
|
||||||
|
|
||||||
COMPEL := ../../../compel/compel-host
|
COMPEL := ../../../compel/compel-host
|
||||||
COMPEL_IDIR := ../../../compel/include/uapi
|
|
||||||
COMPEL_PACK_LDS := ../../../compel/arch/$(ARCH)/scripts/compel-pack.lds.S
|
COMPEL_PACK_LDS := ../../../compel/arch/$(ARCH)/scripts/compel-pack.lds.S
|
||||||
COMPEL_PLUGINS := ../../../compel/plugins
|
COMPEL_PLUGINS := ../../../compel/plugins
|
||||||
COMPEL_LIBRARY := ../../../compel/libcompel.a
|
COMPEL_LIBRARY := ../../../compel/libcompel.a
|
||||||
@ -21,7 +20,7 @@ victim: victim.c
|
|||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
spy: spy.c | parasite.h
|
spy: spy.c | parasite.h
|
||||||
$(CC) $(CFLAGS) -I$(COMPEL_IDIR) -o $@ $^ $(COMPEL_LIBRARY)
|
$(CC) $(CFLAGS) $(shell $(COMPEL) includes) -o $@ $^ $(COMPEL_LIBRARY)
|
||||||
|
|
||||||
parasite.h: parasite.po
|
parasite.h: parasite.po
|
||||||
$(COMPEL) hgen -f $^ -l 4 \
|
$(COMPEL) hgen -f $^ -l 4 \
|
||||||
@ -32,4 +31,4 @@ parasite.po: parasite.o $(COMPEL_PLUGINS)/std.built-in.o
|
|||||||
ld -r -T $(COMPEL_PACK_LDS) -o $@ $^
|
ld -r -T $(COMPEL_PACK_LDS) -o $@ $^
|
||||||
|
|
||||||
parasite.o: parasite.c
|
parasite.o: parasite.c
|
||||||
$(CC) $(CFLAGS) -c $(shell $(COMPEL) cflags) -I$(COMPEL_IDIR) -o $@ $^
|
$(CC) $(CFLAGS) -c $(shell $(COMPEL) cflags) -o $@ $^
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
CC := gcc
|
CC := gcc
|
||||||
CFLAGS ?= -O2 -g -Wall -Werror
|
CFLAGS ?= -O2 -g -Wall -Werror
|
||||||
|
|
||||||
COMPEL_IDIR := ../../../compel/include/uapi
|
COMPEL := ../../../compel/compel-host
|
||||||
COMPEL_LIBRARY := ../../../compel/libcompel.a
|
COMPEL_LIBRARY := ../../../compel/libcompel.a
|
||||||
|
|
||||||
all: victim spy
|
all: victim spy
|
||||||
@ -14,4 +14,4 @@ victim: victim.c
|
|||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
spy: spy.c
|
spy: spy.c
|
||||||
$(CC) $(CFLAGS) -I$(COMPEL_IDIR) -o $@ $^ $(COMPEL_LIBRARY)
|
$(CC) $(CFLAGS) $(shell $(COMPEL) includes) -o $@ $^ $(COMPEL_LIBRARY)
|
||||||
|
@ -62,7 +62,7 @@ $(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(obj)/pie.lib.a $(compel_lds)
|
|||||||
$(call msg-gen, $@)
|
$(call msg-gen, $@)
|
||||||
$(Q) $(LD) -r -T $(compel_lds) -o $@ $< $(obj)/pie.lib.a
|
$(Q) $(LD) -r -T $(compel_lds) -o $@ $< $(obj)/pie.lib.a
|
||||||
|
|
||||||
$(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(SRC_DIR)/compel/compel-host
|
$(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(SRC_DIR)/compel/compel-host-bin
|
||||||
$(call msg-gen, $@)
|
$(call msg-gen, $@)
|
||||||
$(Q) $(SRC_DIR)/compel/compel-host hgen -f $< \
|
$(Q) $(SRC_DIR)/compel/compel-host hgen -f $< \
|
||||||
-l 4 \
|
-l 4 \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user