From: Wen Congyang <wency@cn.fujitsu.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Ian.Jackson@eu.citrix.com, Euan Harris <euan.harris@citrix.com>,
xen-devel@lists.xen.org
Subject: Re: [PATCH v2] tools/Rules.mk: Don't optimize debug builds; add macro debugging information
Date: Thu, 15 Jan 2015 11:38:11 +0800 [thread overview]
Message-ID: <54B73623.9040503@cn.fujitsu.com> (raw)
In-Reply-To: <1421148619.19103.18.camel@citrix.com>
On 01/13/2015 07:30 PM, Ian Campbell wrote:
> On Tue, 2015-01-13 at 19:17 +0800, Wen Congyang wrote:
>> On 01/13/2015 06:11 PM, Ian Campbell wrote:
>>> On Tue, 2015-01-13 at 13:52 +0800, Wen Congyang wrote:
>>>> On 12/01/2014 10:21 PM, Euan Harris wrote:
>>>>> Tools debug builds are built with optimization level -O1, inherited from
>>>>> the CFLAGS definition in StdGNU.mk. Optimizations confuse the debugger,
>>>>> and the comment justifying -O1 in StdGNU.mk should not apply for a
>>>>> userspace library. Disable optimization by appending -O0 to CFLAGS,
>>>>> which overrides the -O1 flag specified earlier.
>>>>>
>>>>> Also specify -g3, to add macro debugging information which allows
>>>>> gdb to expand macro invocations. This is useful as libxl uses many
>>>>> non-trivial macros.
>>>>>
>>>>> Signed-off-by: Euan Harris <euan.harris@citrix.com>
>>>>>
>>>>> Changes since v1:
>>>>> * moved flag override to tools/Rules.mk so it affects all tools
>>>>> ---
>>>>> tools/Rules.mk | 5 +++++
>>>>> 1 files changed, 5 insertions(+), 0 deletions(-)
>>>>>
>>>>> diff --git a/tools/Rules.mk b/tools/Rules.mk
>>>>> index 87a56dc..7ef1ce5 100644
>>>>> --- a/tools/Rules.mk
>>>>> +++ b/tools/Rules.mk
>>>>> @@ -54,6 +54,11 @@ CFLAGS_libxenvchan = -I$(XEN_LIBVCHAN)
>>>>> LDLIBS_libxenvchan = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) -L$(XEN_LIBVCHAN) -lxenvchan
>>>>> SHLIB_libxenvchan = -Wl,-rpath-link=$(XEN_LIBVCHAN)
>>>>>
>>>>> +ifeq ($(debug),y)
>>>>> +# Disable optimizations and debugging information for macros
>>>>> +CFLAGS += -O0 -g3
>>>>> +endif
>>>>> +
>>>>> LIBXL_BLKTAP ?= $(CONFIG_BLKTAP2)
>>>>>
>>>>> ifeq ($(LIBXL_BLKTAP),y)
>>>>>
>>>>
>>>> This patch causes a building error:
>>>> gcc -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -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/low
level/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:25:0,
>>>> from /usr/lib/gcc/x86_64-redhat-linux/4.9.2/include/limits.h:168,
>>>> from /usr/lib/gcc/x86_64-redhat-linux/4.9.2/include/syslimits.h:7,
>>>> from /usr/lib/gcc/x86_64-redhat-linux/4.9.2/include/limits.h:34,
>>>> from /usr/include/python2.7/Python.h:19,
>>>> from xen/lowlevel/xc/xc.c:7:
>>>> /usr/include/features.h:328:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
>>>
>>> Where is _FORTIFY_SOURCE coming from? I don't see it in our tree
>>> anywhere except stubdom/Makefile which is disabling it and the build
>>> worked for me. Perhaps it is coming from your build environment
>>> somewhere? How are you configuring and building Xen?
>>
>> _FORTIFY_SOURCE is just for python, and it comes from /usr/lib64/python2.7/config/Makefile:
>>
>> # Compiler options
>> OPT= -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv
>> BASECFLAGS= -fno-strict-aliasing
>> CFLAGS= $(BASECFLAGS) -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv $(OPT) $(EXTRA_CFLAGS)
>>
>
> That's a bit antisocial of it...
>
> I can't reproduce this on Debian with Python 2.7. _FORTIFY_SOURCE=2 is
> not passed when building the Python bits (it is passed when linking,
> oddly). Debian's /usr/lib/python2.7/config-x86_64-linux-gnu/Makefile
> looks rather different to what you quote above though, it avoids bare
> CFLAGS for one thing (reserving them for the user).
>
> I have a suspicion that this might be a bug in the Fedora Python
> packaging, in that they have leaked inappropriate build-time flags from
> the actual Python build into the set of flags to be used to build 3rd
> party Python modules.
>
> Please can you check this with the Fedora folks? If they respond that
> this is deliberate etc then please let us know and we'll see what we can
> do in Xen to work around it.
Here is the reponse from Fedora folks:
-------- Forwarded Message --------
Subject: Re: [Xen-devel] [PATCH v2] tools/Rules.mk: Don't optimize debug builds; add macro debugging information
Date: Wed, 14 Jan 2015 12:22:19 -0500
From: Bohuslav Kabrda <bkabrda@redhat.com>
To: Wen Congyang <wency@cn.fujitsu.com>
----- Original Message -----
> Hi, bkabrda
>
> When I build some python modules in xen, I find some building error.
>
> The reason is that: we need to disable optimization by -O0, but
> the CFLAGS in python's Makefile have -Wp,-D_FORTIFY_SOURCE=2.
>
> My question is that: Is this flag essential?
>
> Thanks
> Wen Congyang
Hi,
all the flags come from default RPM build configuration that all Fedora packages are supposed to use. They are saved by Python's build process to config/Makefile. Running "setup.py build" then uses them for building extension modules. So to answer your question: yes, this is mandated by Fedora and will not go away.
Now, there are two solutions to your situation I can see:
- either add "undef_macros" to setup.py definition of the extension module, as documented at [1]
- run "setup.py build" in environment where you set "CFLAGS=-U_FORTIFY_SOURCE"
Both will do the same - undefine the _FORTIFY_SOURCE macro in the gcc invocations.
Hope this helps,
Slavek.
[1] https://docs.python.org/2/distutils/setupscript.html#preprocessor-options
>
> Ian.
>
> .
>
next prev parent reply other threads:[~2015-01-15 3:38 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-01 10:39 [PATCH] libxl/Makefile: Don't optimize debug builds; add macro debugging information Euan Harris
2014-12-01 11:43 ` Ian Campbell
2014-12-01 11:55 ` Euan Harris
2014-12-01 12:12 ` Ian Campbell
2014-12-01 14:21 ` [PATCH v2] tools/Rules.mk: " Euan Harris
2015-01-08 17:16 ` Ian Campbell
2015-01-12 16:42 ` Ian Campbell
2015-01-13 5:52 ` Wen Congyang
2015-01-13 10:11 ` Ian Campbell
2015-01-13 10:38 ` Wen Congyang
2015-01-13 11:17 ` Wen Congyang
2015-01-13 11:30 ` Ian Campbell
2015-01-15 3:38 ` Wen Congyang [this message]
2015-01-15 3:39 ` [PATCH] Fix building error Wen Congyang
2015-01-15 7:57 ` Olaf Hering
2015-01-15 9:04 ` Wen Congyang
2015-01-15 9:21 ` Olaf Hering
2015-01-15 9:28 ` Wen Congyang
2015-01-15 9:33 ` [PATCH v2] " Wen Congyang
2015-01-15 11:26 ` Ian Jackson
2015-01-19 15:23 ` Ian Campbell
2015-01-20 2:21 ` Wen Congyang
2015-01-20 10:18 ` Ian Campbell
2015-01-20 10:39 ` Wen Congyang
2015-01-20 12:47 ` Olaf Hering
2015-01-23 11:34 ` Julien Grall
2015-02-04 15:37 ` Jan Beulich
2015-02-04 15:43 ` Ian Jackson
2015-02-04 16:02 ` Jan Beulich
2015-02-04 16:10 ` Ian Jackson
2015-02-04 16:42 ` Olaf Hering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54B73623.9040503@cn.fujitsu.com \
--to=wency@cn.fujitsu.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=euan.harris@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.