]> xenbits.xensource.com Git - people/vhanquez/xen-unstable.git/commitdiff
tools: pass EXTRA_CFLAGS via environment
authorOlaf Hering <olaf@aepfle.de>
Thu, 7 Jun 2012 17:51:42 +0000 (18:51 +0100)
committerOlaf Hering <olaf@aepfle.de>
Thu, 7 Jun 2012 17:51:42 +0000 (18:51 +0100)
Currently qemu-xen will be compiled with CFLAGS only if CFLAGS was
already in the environment during make invocation. If CFLAGS is in
environment then make will append all of the various flags specified in
xen Makefiles to this environment variable, which is then used in qemu
configure. Since qemu-xen is not ready for compiler flags like
"-std=gnu99" compilation will fail. If CFLAGS is not in environment,
then configure will use just its own "-O2 -g" because make does not
export its own CFLAGS variable.

>From a distro perspective, it is required to build libraries and
binaries with certain global cflags (arbitrary gcc options). Up to the
point when qemu-xen was imported it worked as expected by exporting
CFLAGS before 'make tools'.  Now qemu-upstream reuses these CFLAGS, but
it cant deal with the result.

This patch extends the tools Makefiles so that three new environment
variables are recognized:
  EXTRA_CFLAGS_XEN_TOOLS= specifies CFLAGS for the tools build.
  EXTRA_CFLAGS_QEMU_TRADITIONAL= specifies CFLAGS for old qemu.
  EXTRA_CFLAGS_QEMU_XEN= specifies CFLAGS for new qemu.

Special care needs to be taken in tools/firmware because the resulting
binaries are not linked with the hosts runtime libraries. These binaries
run in guest context. To avoid build errors from gcc options like
-fstack-protector, reuse existing practice to unset the new
EXTRA_CFLAGS_XEN_TOOLS for the firmware dirs.

The new feature can be used like this in a rpm xen.spec file:

   export EXTRA_CFLAGS_XEN_TOOLS="${RPM_OPT_FLAGS}"
   export EXTRA_CFLAGS_QEMU_TRADITIONAL="${RPM_OPT_FLAGS}"
   export EXTRA_CFLAGS_QEMU_XEN="${RPM_OPT_FLAGS}"
   ./configure \
    --libdir=%{_libdir} \
    --prefix=/usr
   make

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/Makefile
tools/Rules.mk
tools/firmware/Rules.mk

index 7b146785eb022630c088e3ff8df89707d86dcb21..6688d07a7dacec427718ce263dcdde8bbc018076 100644 (file)
@@ -122,7 +122,9 @@ subdir-all-qemu-xen-traditional-dir subdir-install-qemu-xen-traditional-dir: qem
        set -e; \
                $(buildmakevars2shellvars); \
                cd qemu-xen-traditional-dir; \
-               $(QEMU_ROOT)/xen-setup $(IOEMU_CONFIGURE_CROSS); \
+               $(QEMU_ROOT)/xen-setup \
+               --extra-cflags="$(EXTRA_CFLAGS_QEMU_TRADITIONAL)" \
+               $(IOEMU_CONFIGURE_CROSS); \
                $(MAKE) install
 
 subdir-clean-qemu-xen-traditional-dir:
@@ -151,7 +153,8 @@ subdir-all-qemu-xen-dir subdir-install-qemu-xen-dir: qemu-xen-dir-find
                --extra-cflags="-I$(XEN_ROOT)/tools/include \
                -I$(XEN_ROOT)/tools/libxc \
                -I$(XEN_ROOT)/tools/xenstore \
-               -I$(XEN_ROOT)/tools/xenstore/compat" \
+               -I$(XEN_ROOT)/tools/xenstore/compat \
+               $(EXTRA_CFLAGS_QEMU_XEN)" \
                --extra-ldflags="-L$(XEN_ROOT)/tools/libxc \
                -L$(XEN_ROOT)/tools/xenstore" \
                --bindir=$(LIBEXEC) \
index a2a1a5846a3e3615d1198ac4c8a49c67a8f032fd..1e928b7b22daf9f1027132edba4bbcf3c17de703 100644 (file)
@@ -76,6 +76,8 @@ endif
 CFLAGS-$(CONFIG_X86_32) += $(call cc-option,$(CC),-mno-tls-direct-seg-refs)
 CFLAGS += $(CFLAGS-y)
 
+CFLAGS += $(EXTRA_CFLAGS_XEN_TOOLS)
+
 # Require GCC v3.4+ (to avoid issues with alignment constraints in Xen headers)
 check-$(CONFIG_X86) = $(call cc-ver-check,CC,0x030400,\
                         "Xen requires at least gcc-3.4")
index 8a8830911be539b55b3a6feda1e551d84c463747..26bbddccd410f58695301119edcffaa5bc61346b 100644 (file)
@@ -3,6 +3,7 @@ override XEN_TARGET_ARCH = x86_32
 
 # User-supplied CFLAGS are not useful here.
 CFLAGS =
+EXTRA_CFLAGS_XEN_TOOLS =
 
 include $(XEN_ROOT)/tools/Rules.mk