[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 Thu, Feb 5, 2015 at 4:52 PM, Jan Beulich <JBeulich@xxxxxxxx> wrote:
>>>> On 05.02.15 at 17:36, <ian.jackson@xxxxxxxxxxxxx> wrote:
>> Some systems have python-config include -D_FORTIFY_SOURCE in the
>> CFLAGS.  But -D_FORTIFY_SOURCE does not (currently) work with -O0, and
>> -O0 is enabled in debug builds (since 1166ecf781).  As a result, on
>> those systems, debug builds fail.
>>
>> Work around this problem as follows:
>>  * In configure, detect -D_FORTIFY_SOURCE in $(python-config --cflags)
>>  * If detected, set the new autoconf substitution and make variable
>>    PY_NOOPT_CFLAGS to -O1.
>>  * In tools/Rules.mk, where we add -O0, also add PY_NOOPT_CFLAGS
>>    (which will override the -O0 with -O1 if required).
>
> Not having tried it out yet (hopefully some time tomorrow), two
> a remark and a question:
>
>> --- /dev/null
>> +++ b/m4/python_fortify_noopt.m4
>> @@ -0,0 +1,29 @@
>> +dnl Defines PY_NOOPT_CFLAGS to either '' or -O1
>> +dnl
>> +
>> +dnl This is necessary because on some systems setup.py includes
>> +dnl -D_FORTIFY_SOURCE but have a -D_FORTIFY_SOURCE which breaks
>> +dnl with -O0.  On those systems we arrange to use -O1 for debug
>> +dnl builds instead.
>> +
>> +AC_DEFUN([AX_CHECK_PYTHON_FORTIFY_NOOPT], [
>> +    AC_CACHE_CHECK([whether Python setup.py brokenly enables 
>> -D_FORTIFY_SOURCE],
>
> I guess the people having added that would not like to see this
> called "brokenly".
>
>> --- 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 += -O0 -g3 $(PY_NOOPT_CFLAGS)
>
> Why would you do this for all of the tools build rather than just the
> python components?

Because CentOS 7 somehow seems to have picked up _FORTIFY_SOURCE for libxc:

gcc  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector-strong --param=ssp-buffer-size=4
-grecord-gcc-switches   -m64 -mtune=generic -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   -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 .subdirs-install.d -D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls  -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 .subdir-install-libxc.d -D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls  -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 .build.d -D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls -D_GNU_SOURCE
-I../../xen/common/libelf -Werror -Wmissing-prototypes -I. -I./include
-I/build/centos/git/xen/BUILD/xen-4.6.0rc2x/tools/libxc/../../tools/include
-pthread -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 .xc_cpupool.o.d -D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls -D_GNU_SOURCE
-I../../xen/common/libelf -Werror -Wmissing-prototypes -I. -I./include
-I/build/centos/git/xen/BUILD/xen-4.6.0rc2x/tools/libxc/../../tools/include
-pthread -include
/build/centos/git/xen/BUILD/xen-4.6.0rc2x/tools/libxc/../../tools/config.h
 -c -o xc_cpupool.o xc_cpupool.c
In file included from /usr/include/unistd.h:25:0,
                 from xc_private.h:19,
                 from xc_altp2m.c:23:
/usr/include/features.h:330:4: error: #warning _FORTIFY_SOURCE
requires compiling with optimization (-O) [-Werror=cpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
In file included from /usr/include/unistd.h:25:0,
                 from xg_private.h:19,
                 from xc_core_x86.c:20:
/usr/include/features.h:330:4: error: #warning _FORTIFY_SOURCE
requires compiling with optimization (-O) [-Werror=cpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
In file included from /usr/include/unistd.h:25:0,
                 from xc_private.h:19,
                 from xc_cpupool.c:23:
/usr/include/features.h:330:4: error: #warning _FORTIFY_SOURCE
requires compiling with optimization (-O) [-Werror=cpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
In file included from /usr/include/unistd.h:25:0,
                 from xg_private.h:19,
                 from xc_core.c:63:
/usr/include/features.h:330:4: error: #warning _FORTIFY_SOURCE
requires compiling with optimization (-O) [-Werror=cpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
make[4]: *** [xc_core_x86.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: *** [xc_cpupool.o] Error 1
cc1: all warnings being treated as errors
make[4]: *** [xc_core.o] Error 1
cc1: all warnings being treated as errors
make[4]: *** [xc_altp2m.o] Error 1
make[4]: Leaving directory
`/build/centos/git/xen/BUILD/xen-4.6.0rc2x/tools/libxc'
make[3]: *** [build] Error 2
make[3]: Leaving directory
`/build/centos/git/xen/BUILD/xen-4.6.0rc2x/tools/libxc'
make[2]: *** [subdir-install-libxc] Error 2
make[2]: Leaving directory `/build/centos/git/xen/BUILD/xen-4.6.0rc2x/tools'
make[1]: *** [subdirs-install] Error 2
make[1]: Leaving directory `/build/centos/git/xen/BUILD/xen-4.6.0rc2x/tools'
make: *** [install-tools] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.mIYLA9 (%build)

I'm not sure exactly how to track down where it came from; it just
seems to appear out of nowhere in the config.log and config.status
(attached).

 -George

Attachment: config.log
Description: Text Data

Attachment: config.status
Description: Binary data

_______________________________________________
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®.