mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 09:58:09 +00:00
compel cli: kill --arch option, add --compat
There is no need to support all possible architectures for "compel cflags" action. In fact, "compel hgen" can only support the one it was compiled for (with the only exception of 32-bit mode for x86). It looks like if we can use a few #ifdefs, there is no need to specify --arch anymore, let's drop it! Still, for the x86 32-bit mode we need to introduce --compat option. Note that "compel hgen" autodetects 32-bit mode for x86 by looking into ELF header, but in case of "compel clfags" there are no files to look into, so we need this --compat specified explicitly. While at it, - Makefile: define CONFIG_AARCH64 if building for ARM64 - fail to compile on unsupported/unspecified ARCH - make "compel --help" output a bit more compact 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
a49d44d2b3
commit
dfee3232e6
4
Makefile
4
Makefile
@ -72,6 +72,10 @@ ifeq ($(ARCH),arm)
|
||||
PROTOUFIX := y
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),aarch64)
|
||||
DEFINES := -DCONFIG_AARCH64
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),x86)
|
||||
DEFINES := -DCONFIG_X86_64
|
||||
endif
|
||||
|
@ -28,27 +28,23 @@
|
||||
#define COMPEL_LDFLAGS_DEFAULT "-r -z noexecstack"
|
||||
|
||||
typedef struct {
|
||||
const char *arch;
|
||||
const char *cflags;
|
||||
} compel_cflags_t;
|
||||
const char *cflags_compat;
|
||||
} flags_t;
|
||||
|
||||
static const compel_cflags_t compel_cflags[] = {
|
||||
{
|
||||
.arch = "x86",
|
||||
static const flags_t flags = {
|
||||
#if defined CONFIG_X86_64
|
||||
.cflags = COMPEL_CFLAGS_PIE,
|
||||
}, {
|
||||
.arch = "ia32",
|
||||
.cflags = COMPEL_CFLAGS_NOPIC,
|
||||
}, {
|
||||
.arch = "aarch64",
|
||||
.cflags_compat = COMPEL_CFLAGS_NOPIC,
|
||||
#elif defined CONFIG_AARCH64
|
||||
.cflags = COMPEL_CFLAGS_PIE,
|
||||
}, {
|
||||
.arch = "arm",
|
||||
#elif defined(CONFIG_ARMV6) || defined(CONFIG_ARMV7)
|
||||
.cflags = COMPEL_CFLAGS_PIE,
|
||||
}, {
|
||||
.arch = "ppc64",
|
||||
#elif defined CONFIG_PPC64
|
||||
.cflags = COMPEL_CFLAGS_PIE,
|
||||
},
|
||||
#else
|
||||
#error "CONFIG_<ARCH> not defined, or unsupported ARCH"
|
||||
#endif
|
||||
};
|
||||
|
||||
piegen_opt_t opts = {};
|
||||
@ -114,24 +110,9 @@ static void cli_log(unsigned int lvl, const char *fmt, va_list parms)
|
||||
}
|
||||
|
||||
static int usage(int rc) {
|
||||
int i = 0;
|
||||
printf(
|
||||
"Usage:\n"
|
||||
" compel --arch=ARCH cflags\n"
|
||||
" compel --arch=ARCH ldflags\n"
|
||||
" ARCH := { "
|
||||
);
|
||||
|
||||
/* Print list of known arches */
|
||||
while (1) {
|
||||
printf("%s", compel_cflags[i++].arch);
|
||||
if (i == ARRAY_SIZE(compel_cflags))
|
||||
break;
|
||||
printf(" | ");
|
||||
}
|
||||
|
||||
printf(
|
||||
" }\n"
|
||||
" compel [--compat] cflags | ldflags\n"
|
||||
" compel -f FILE -o FILE -p NAME [-l N] hgen\n"
|
||||
" -f, --file FILE input (parasite object) file name\n"
|
||||
" -o, --output FILE output (header) file name\n"
|
||||
@ -145,16 +126,21 @@ static int usage(int rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void print_cflags(bool compat)
|
||||
{
|
||||
printf("%s\n", compat ? flags.cflags_compat : flags.cflags);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *current_cflags = NULL;
|
||||
int log_level = DEFAULT_LOGLEVEL;
|
||||
int opt, idx, i;
|
||||
bool compat = false;
|
||||
int opt, idx;
|
||||
char *action;
|
||||
|
||||
static const char short_opts[] = "a:f:o:p:hVl:";
|
||||
static const char short_opts[] = "cf:o:p:hVl:";
|
||||
static struct option long_opts[] = {
|
||||
{ "arch", required_argument, 0, 'a' },
|
||||
{ "compat", no_argument, 0, 'c' },
|
||||
{ "file", required_argument, 0, 'f' },
|
||||
{ "output", required_argument, 0, 'o' },
|
||||
{ "prefix", required_argument, 0, 'p' },
|
||||
@ -170,18 +156,8 @@ int main(int argc, char *argv[])
|
||||
if (opt == -1)
|
||||
break;
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
for (i = 0; i < ARRAY_SIZE(compel_cflags); i++) {
|
||||
if (!strcmp(optarg, compel_cflags[i].arch)) {
|
||||
current_cflags = compel_cflags[i].cflags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!current_cflags) {
|
||||
fprintf(stderr, "Error: unknown arch '%s'\n",
|
||||
optarg);
|
||||
return usage(1);
|
||||
}
|
||||
case 'c':
|
||||
compat = true;
|
||||
break;
|
||||
case 'f':
|
||||
opts.input_filename = optarg;
|
||||
@ -218,11 +194,7 @@ int main(int argc, char *argv[])
|
||||
action = argv[optind++];
|
||||
|
||||
if (!strcmp(action, "cflags")) {
|
||||
if (!current_cflags) {
|
||||
fprintf(stderr, "Error: option --arch required\n");
|
||||
return usage(1);
|
||||
}
|
||||
printf("%s", current_cflags);
|
||||
print_cflags(compat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -32,4 +32,4 @@ parasite.po: parasite.o $(COMPEL_PLUGINS)/std.built-in.o
|
||||
ld -r -T $(COMPEL_PACK_LDS) -o $@ $^
|
||||
|
||||
parasite.o: parasite.c
|
||||
$(CC) $(CFLAGS) -c $(shell $(COMPEL) --arch=$(ARCH) cflags) -I$(COMPEL_IDIR) -o $@ $^
|
||||
$(CC) $(CFLAGS) -c $(shell $(COMPEL) cflags) -I$(COMPEL_IDIR) -o $@ $^
|
||||
|
@ -37,7 +37,7 @@ 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 $(SRC_DIR)/compel/compel-host --arch=$(ARCH) cflags)
|
||||
CFLAGS += $(shell $(SRC_DIR)/compel/compel-host cflags)
|
||||
endif
|
||||
|
||||
ifeq ($(SRCARCH),arm)
|
||||
|
Loading…
x
Reference in New Issue
Block a user