[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] tools: work around collision of -O0 and -D_FORTIFY_SOURCE



On 02/04/15 12:01, Jan Beulich wrote:
> The former gets enforced by our debug builds, the latter appears to be
> not uncommon for certain distros' Python packages. Newer glibc warns on
> uses of _FORTIFY_SOURCE without optimization being enabled, which with
> -Werror causes the build to fail.
> 
> Determine Python's intended flags to be passed to the C compiler via
> "python-config --cflags", and replace -O0 by -O1 when a non-zero value
> gets set for _FORTIFY_SOURCE.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 

Well, this does not fix debug=y builds for me:

...
make -C python install
make[3]: Entering directory `/home/don/xen-master/tools/python'
CC="gcc" CFLAGS="  -O1 -fno-omit-frame-pointer -m64 -g
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes
-Wdeclaration-after-statement -Wno-unused-but-set-variable
-Wno-unused-local-typedefs   -O0 -g3 -D__XEN_TOOLS__ -MMD -MF .install.d
-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls
  " python setup.py install \
        --prefix="/usr" --root="/home/don/xen-master/dist/install" --force
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/xen
copying xen/__init__.py -> build/lib.linux-x86_64-2.7/xen
creating build/lib.linux-x86_64-2.7/xen/lowlevel
copying xen/lowlevel/__init__.py -> build/lib.linux-x86_64-2.7/xen/lowlevel
running build_ext
building 'xc' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/xen
creating build/temp.linux-x86_64-2.7/xen/lowlevel
creating build/temp.linux-x86_64-2.7/xen/lowlevel/xc
gcc -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic
-D_GNU_SOURCE -fPIC -fwrapv -O1 -fno-omit-frame-pointer -m64 -g
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes
-Wdeclaration-after-statement -Wno-unused-but-set-variable
-Wno-unused-local-typedefs -O0 -g3 -D__XEN_TOOLS__ -MMD -MF .install.d
-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls
-fPIC -I../../tools/include -I../../tools/libxc/include
-Ixen/lowlevel/xc -I/usr/include/python2.7 -c xen/lowlevel/xc/xc.c -o
build/temp.linux-x86_64-2.7/xen/lowlevel/xc/xc.o -fno-strict-aliasing
-Werror
In file included from /usr/include/limits.h:27:0,
                 from
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/include/limits.h:169,
                 from
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/include/syslimits.h:7,
                 from
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/include/limits.h:34,
                 from /usr/include/python2.7/Python.h:19,
                 from xen/lowlevel/xc/xc.c:7:
/usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires
compiling with optimization (-O) [-Werror=cpp]
cc1: all warnings being treated as errors
error: command 'gcc' failed with exit status 1
make[3]: *** [install] Error 1
make[3]: Leaving directory `/home/don/xen-master/tools/python'
make[2]: *** [subdir-install-python] Error 2
make[2]: Leaving directory `/home/don/xen-master/tools'
make[1]: *** [subdirs-install] Error 2
make[1]: Leaving directory `/home/don/xen-master/tools'
make: *** [install-tools] Error 2


Using this change:

dcs-xen-54:~/xen-master>git show | cat
commit 3cda306a162e55d73c25efc14840e7afeec8d3d3
Author: Don Slutz <dslutz@xxxxxxxxxxx>
Date:   Wed Feb 4 17:57:00 2015 -0500

    tools/Rules.mk: Drop -O0 for debug=y

    This is a partial revert of

    commit 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6
    Author: Euan Harris <euan.harris@xxxxxxxxxx>
    Date:   Mon Dec 1 14:21:05 2014 +0000

        tools/Rules.mk: Don't optimize debug builds; add macro debugging
information

    Signed-off-by: Don Slutz <dslutz@xxxxxxxxxxx>

diff --git a/tools/Rules.mk b/tools/Rules.mk
index 74cf37e..8bf603d 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -56,7 +56,7 @@ SHLIB_libxenvchan  = -Wl,-rpath-link=$(XEN_LIBVCHAN)

 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+CFLAGS += -g3
 endif

 LIBXL_BLKTAP ?= $(CONFIG_BLKTAP2)


I can now build with "debug=y" on Fedora 17.

   -Don Slutz




> --- a/tools/pygrub/Makefile
> +++ b/tools/pygrub/Makefile
> @@ -2,15 +2,24 @@
>  XEN_ROOT = $(CURDIR)/../..
>  include $(XEN_ROOT)/tools/Rules.mk
>  
> +py_cflags := $(shell $(PYTHON)-config --cflags)
> +PY_CFLAGS = $(if $(strip $(py_cflags)),,\
> +                 $(error '$(PYTHON)-config --cflags' produced no output))\
> +            $(if $(filter -D_FORTIFY_SOURCE=%,\
> +                          $(filter-out -D_FORTIFY_SOURCE=0,\
> +                                       $(py_cflags))),\
> +                 $(patsubst -O0,-O1,$(CFLAGS)),\
> +                 $(CFLAGS)) $(APPEND_LDFLAGS)
> +
>  .PHONY: all
>  all: build
>  .PHONY: build
>  build:
> -     CC="$(CC)" CFLAGS="$(CFLAGS) $(APPEND_LDFLAGS)" $(PYTHON) setup.py build
> +     CC="$(CC)" CFLAGS="$(PY_CFLAGS)" $(PYTHON) setup.py build
>  
>  .PHONY: install
>  install: all
> -     CC="$(CC)" CFLAGS="$(CFLAGS) $(APPEND_LDFLAGS)" $(PYTHON) setup.py 
> install \
> +     CC="$(CC)" CFLAGS="$(PY_CFLAGS)" $(PYTHON) setup.py install \
>               $(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" \
>               --install-scripts=$(LIBEXEC_BIN) --force
>       set -e; if [ $(BINDIR) != $(LIBEXEC_BIN) -a \
> --- a/tools/python/Makefile
> +++ b/tools/python/Makefile
> @@ -4,6 +4,15 @@ include $(XEN_ROOT)/tools/Rules.mk
>  .PHONY: all
>  all: build
>  
> +py_cflags := $(shell $(PYTHON)-config --cflags)
> +PY_CFLAGS = $(if $(strip $(py_cflags)),,\
> +                 $(error '$(PYTHON)-config --cflags' produced no output))\
> +            $(if $(filter -D_FORTIFY_SOURCE=%,\
> +                          $(filter-out -D_FORTIFY_SOURCE=0,\
> +                                       $(py_cflags))),\
> +                 $(patsubst -O0,-O1,$(CFLAGS)),\
> +                 $(CFLAGS)) $(LDFLAGS) $(APPEND_LDFLAGS)
> +
>  .PHONY: build
>  build: genwrap.py $(XEN_ROOT)/tools/libxl/libxl_types.idl \
>               $(XEN_ROOT)/tools/libxl/idl.py
> @@ -11,11 +20,11 @@ build: genwrap.py $(XEN_ROOT)/tools/libx
>               $(XEN_ROOT)/tools/libxl/libxl_types.idl \
>               xen/lowlevel/xl/_pyxl_types.h \
>               xen/lowlevel/xl/_pyxl_types.c
> -     CC="$(CC)" CFLAGS="$(CFLAGS) $(LDFLAGS) $(APPEND_LDFLAGS)" $(PYTHON) 
> setup.py build
> +     CC="$(CC)" CFLAGS="$(PY_CFLAGS)" $(PYTHON) setup.py build
>  
>  .PHONY: install
>  install:
> -     CC="$(CC)" CFLAGS="$(CFLAGS) $(LDFLAGS) $(APPEND_LDFLAGS)" $(PYTHON) 
> setup.py install \
> +     CC="$(CC)" CFLAGS="$(PY_CFLAGS)" $(PYTHON) setup.py install \
>               $(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" --force
>  
>  .PHONY: test
> 
> 
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.