All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools: work around collision of -O0 and -D_FORTIFY_SOURCE
@ 2015-02-04 17:01 Jan Beulich
  2015-02-04 23:33 ` Don Slutz
  2015-02-05 11:08 ` Ian Jackson
  0 siblings, 2 replies; 24+ messages in thread
From: Jan Beulich @ 2015-02-04 17:01 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell, Ian Jackson, Wei Liu, Stefano Stabellini

[-- Attachment #1: Type: text/plain, Size: 2880 bytes --]

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@suse.com>

--- 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




[-- Attachment #2: tools-python-build.patch --]
[-- Type: text/plain, Size: 2935 bytes --]

tools: work around collision of -O0 and -D_FORTIFY_SOURCE

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@suse.com>

--- 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

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2015-09-01 16:21 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-04 17:01 [PATCH] tools: work around collision of -O0 and -D_FORTIFY_SOURCE Jan Beulich
2015-02-04 23:33 ` Don Slutz
2015-02-05 10:17   ` Jan Beulich
2015-02-05 14:55     ` Don Slutz
2015-02-05 11:08 ` Ian Jackson
2015-02-05 11:18   ` Jan Beulich
2015-02-05 12:25     ` Ian Campbell
2015-02-05 15:26     ` Ian Jackson
2015-02-05 15:46       ` Jan Beulich
2015-02-05 15:47       ` Euan Harris
2015-02-05 16:36         ` Ian Jackson
2015-02-05 16:52           ` Jan Beulich
2015-02-05 16:56             ` Ian Jackson
2015-02-05 17:01               ` Jan Beulich
2015-02-06  8:19               ` Jan Beulich
2015-02-06  8:22                 ` Jan Beulich
2015-02-06 11:04                   ` [PATCH] tools: work around collision of -O0 and -D_FORTIFY_SOURCE [and 1 more messages] Ian Jackson
2015-02-06 11:04                     ` [PATCH v4] tools: work around collision of -O0 and -D_FORTIFY_SOURCE Ian Jackson
2015-02-06 16:13                       ` Don Slutz
2015-02-06 17:28                         ` Ian Jackson
2015-02-06 15:24                     ` [PATCH] tools: work around collision of -O0 and -D_FORTIFY_SOURCE [and 1 more messages] Don Slutz
2015-09-01 14:54             ` [PATCH] tools: work around collision of -O0 and -D_FORTIFY_SOURCE George Dunlap
2015-09-01 15:10               ` Ian Campbell
2015-09-01 16:21                 ` George Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.