Files
xen/tools/libs/util/Makefile
T
Julien Grall 40be6307ec Only compile the hypervisor with -Wdeclaration-after-statement
Right now, all tools and hypervisor will be complied with the option
-Wdeclaration-after-statement. While most of the code in the hypervisor
is controlled by us, for tools we may import external libraries.

The build will fail if one of them are using the construct we are
trying to prevent. This is the case when building against Python 3.12
and Yocto:

| In file included from /srv/storage/alex/yocto/build-virt/tmp/work/core2-64-poky-linux/xen-tools/4.17+stable/recipe-sysroot/usr/include/python3.12/Python.h:44,
|                  from xen/lowlevel/xc/xc.c:8:
| /srv/storage/alex/yocto/build-virt/tmp/work/core2-64-poky-linux/xen-tools/4.17+stable/recipe-sysroot/usr/include/python3.12/object.h: In function 'Py_SIZE':
| /srv/storage/alex/yocto/build-virt/tmp/work/core2-64-poky-linux/xen-tools/4.17+stable/recipe-sysroot/usr/include/python3.12/object.h:233:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
|   233 |     PyVarObject *var_ob = _PyVarObject_CAST(ob);
|       |     ^~~~~~~~~~~
| In file included from /srv/storage/alex/yocto/build-virt/tmp/work/core2-64-poky-linux/xen-tools/4.17+stable/recipe-sysroot/usr/include/python3.12/Python.h:53:
| /srv/storage/alex/yocto/build-virt/tmp/work/core2-64-poky-linux/xen-tools/4.17+stable/recipe-sysroot/usr/include/python3.12/cpython/longintrepr.h: In function '_PyLong_CompactValue':
| /srv/storage/alex/yocto/build-virt/tmp/work/core2-64-poky-linux/xen-tools/4.17+stable/recipe-sysroot/usr/include/python3.12/cpython/longintrepr.h:121:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
|   121 |     Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
|       |     ^~~~~~~~~~
| cc1: all warnings being treated as errors

Looking at the tools directory, a fair few directory already add
-Wno-declaration-after-statement to inhibit the default behavior.

We have always build the hypervisor with the flag, so for now remove
only the flag for anything but the hypervisor. We can decide at later
time whether we want to relax.

Also remove the -Wno-declaration-after-statement in some subdirectory
as the flag is now unnecessary.

Part of the commit message was take from Alexander's first proposal:

Link: https://lore.kernel.org/xen-devel/20231128174729.3880113-1-alex@linutronix.de/
Reported-by: Alexander Kanavin <alex@linutronix.de>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Jason Andryuk <jandryuk@gmail.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
2023-12-06 19:12:40 +00:00

57 lines
1.5 KiB
Makefile

XEN_ROOT = $(CURDIR)/../../..
include $(XEN_ROOT)/tools/Rules.mk
OBJS-y += libxlu_cfg_y.o
OBJS-y += libxlu_cfg_l.o
OBJS-y += libxlu_cfg.o
OBJS-y += libxlu_disk_l.o
OBJS-y += libxlu_disk.o
OBJS-y += libxlu_vif.o
OBJS-y += libxlu_pci.o
CFLAGS += -Wno-format-zero-length -Wmissing-declarations -Wformat-nonliteral
CFLAGS += $(CFLAGS_libxenctrl)
CFLAGS += $(PTHREAD_CFLAGS)
LDFLAGS += $(PTHREAD_LDFLAGS)
ifeq ($(FLEX),)
%.c %.h:: %.l
$(warning Flex is needed to rebuild some libxl parsers and \
scanners, please install it and rerun configure)
endif
ifeq ($(BISON),)
%.c %.h:: %.y
$(warning Bison is needed to rebuild some libxl parsers and \
scanners, please install it and rerun configure)
endif
AUTOINCS = libxlu_cfg_y.h libxlu_cfg_l.h libxlu_disk_l.h
LIBHEADER := libxlutil.h
PKG_CONFIG_NAME := Xlutil
PKG_CONFIG_DESC := The xl utility library for Xen hypervisor
NO_HEADERS_CHK := y
include $(XEN_ROOT)/tools/libs/libs.mk
$(OBJS-y) $(PIC_OBJS): $(AUTOINCS)
# Adding the .c conterparts of the headers generated by flex/bison as
# prerequisite of all objects.
# This is to tell make that if only the .c file is out-of-date but not the
# header, it should still wait for the .c file to be rebuilt.
# Otherwise, make doesn't considered "%.c %.h" as grouped targets, and will run
# the flex/bison rules in parallel of CC rules which only need the header.
$(OBJS-y) $(PIC_OBJS): libxlu_cfg_l.c libxlu_cfg_y.c libxlu_disk_l.c
%.c %.h:: %.y
@rm -f $*.[ch]
$(BISON) --output=$*.c $<
%.c %.h:: %.l
@rm -f $*.[ch]
$(FLEX) --header-file=$*.h --outfile=$*.c $<