From f9a6eba4e0b31247116256545b3c12e1df88c0de Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Sat, 14 May 2016 19:23:09 +0200 Subject: build: Filter -D_FORTIFY_SOURCE from CFLAGS We use python-config to get recommended CFLAGS. It provides -D_FORTIFY_SOURCE=2 by default that conflicts with our --enable-debug option or a developer provided no-optimization option. Hence, filter it out from default CFLAGS. Cherry picked from commit 5e65701f2660d1be101da81bffea7721d4f9ece0: > Change-Id: Id80196baeb55415b1ea334e7b17143e56dfbadb3 > BUG: 1283948 > Co-authored-by: Kaleb S KEITHLEY > Signed-off-by: Raghavendra Talur > Reviewed-on: http://review.gluster.org/12707 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Kaleb KEITHLEY Change-Id: Id80196baeb55415b1ea334e7b17143e56dfbadb3 BUG: 1336137 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/14339 Smoke: Gluster Build System Tested-by: Anoop C S NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Kaleb KEITHLEY --- configure.ac | 133 ++++++++++++++------------------- xlators/features/glupy/src/Makefile.am | 5 +- 2 files changed, 62 insertions(+), 76 deletions(-) diff --git a/configure.ac b/configure.ac index e50b46d05ef..2cb4a18a63c 100644 --- a/configure.ac +++ b/configure.ac @@ -1161,92 +1161,75 @@ if test "x$LIBAIO" != "x"; then BUILD_LIBAIO=yes fi -# glupy section +dnl glupy section BUILD_GLUPY=no have_python2=no have_Python_h=no -AM_PATH_PYTHON() -if echo $PYTHON_VERSION | grep ^2; then - have_python2=yes -fi +AC_ARG_ENABLE([glupy], AS_HELP_STRING([--enable-glupy], [build glupy])) +if test "x$enable_glupy" != "xno"; then enable_glupy=yes; fi -# Save flags before testing python -saved_CFLAGS=$CFLAGS -saved_CPPFLAGS=$CPPFLAGS -saved_LDFLAGS=$LDFLAGS - -# Use pkg-config to get runtime search patch missing from ${PYTHON}-config -# Just do "true" on failure so that configure does not bail out -PKG_CHECK_MODULES([PYTHON], "python-$PYTHON_VERSION",,true) -CFLAGS="`${PYTHON}-config --cflags`" -CPPFLAGS=$CFLAGS -LDFLAGS="${PYTHON_LIBS} -L`${PYTHON}-config --prefix`/lib -L`${PYTHON}-config --prefix`/$libdir `${PYTHON}-config --ldflags`" - -AC_CHECK_HEADERS([python$PYTHON_VERSION/Python.h],[have_Python_h=yes],[]) -AC_ARG_ENABLE([glupy], - AS_HELP_STRING([--enable-glupy], - [build glupy])) -case x$enable_glupy in - xyes) - if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then - BUILD_GLUPY=yes - PYTHONDEV_CFLAGS="$CFLAGS" - PYTHONDEV_CPPFLAGS="$CPPFLAGS" - PYTHONDEV_LDFLAGS="$LDFLAGS" - AC_SUBST(PYTHONDEV_CFLAGS) - AC_SUBST(PYTHONDEV_CPPFLAGS) - AC_SUBST(PYTHONDEV_LDFLAGS) - else - AC_MSG_ERROR([glupy requires python-devel/python-dev package and python2.x]) - fi - ;; - xno) - ;; - *) - if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then - BUILD_GLUPY=yes - PYTHONDEV_CFLAGS="$CFLAGS" - PYTHONDEV_CPPFLAGS="$CPPFLAGS" - PYTHONDEV_LDFLAGS="$LDFLAGS" - AC_SUBST(PYTHONDEV_CFLAGS) - AC_SUBST(PYTHONDEV_CPPFLAGS) - AC_SUBST(PYTHONDEV_LDFLAGS) - else +if test "x$enable_glupy" = "xyes"; then + dnl Check if python exists + AM_PATH_PYTHON() + dnl Check if version matches that we require + if echo $PYTHON_VERSION | grep ^2; then + have_python2=yes + fi + + dnl Use pkg-config to get runtime search patch missing from ${PYTHON}-config + dnl Just do "true" on failure so that configure does not bail out + PKG_CHECK_MODULES([PYTHON], "python-$PYTHON_VERSION",,true) + + PYTHONDEV_CPPFLAGS="`${PYTHON}-config --cflags`" + dnl Edit out the flags that are not required or are conflicting + PYTHONDEV_CPPFLAGS=`echo ${PYTHONDEV_CPPFLAGS} | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[[0-9]]//g'` + + dnl Find python libs at user configured libdir and also "lib" under prefix + PYTHONDEV_LDFLAGS="${PYTHON_LIBS} -L`${PYTHON}-config --prefix`/lib -L`${PYTHON}-config --prefix`/$libdir `${PYTHON}-config --ldflags`" + + BUILD_PYTHON_SITE_PACKAGES=`$PYTHON -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'` + BUILD_PYTHON_INC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()"` + BUILD_PYTHON_LIB=python$PYTHON_VERSION + + GLUPY_SUBDIR=glupy + GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile + GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile + + dnl Now check for python header using the include path obtained above + AC_CHECK_HEADERS([${BUILD_PYTHON_INC}/Python.h],[have_Python_h=yes],[]) + + if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then + case $host_os in + darwin*) + BUILD_GLUPY=no + ;; + *) + BUILD_GLUPY=yes + ;; + esac + else AC_MSG_WARN([ --------------------------------------------------------------------------------- - cannot build glupy. python 2.x and python-devel/python-dev package are required. + cannot build glupy. python 2.x and python-devel/python-dev package are required. ---------------------------------------------------------------------------------]) - fi - ;; -esac -# Restore flags -CFLAGS=$saved_CFLAGS -CPPFLAGS=$saved_CPPFLAGS -LDFLAGS=$saved_LDFLAGS + fi -case $host_os in - darwin*) - BUILD_GLUPY=no - ;; -esac + if test "x$BUILD_GLUPY" = "xyes"; then + + echo "building glupy with -isystem $BUILD_PYTHON_INC -l $BUILD_PYTHON_LIB" -if test "x$BUILD_GLUPY" = "xyes"; then - BUILD_PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix='$prefix'))"` - BUILD_PYTHON_INC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()"` - BUILD_PYTHON_LIB=python$PYTHON_VERSION - GLUPY_SUBDIR=glupy - GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile - GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile - echo "building glupy with -isystem $BUILD_PYTHON_INC -l $BUILD_PYTHON_LIB" - AC_SUBST(BUILD_PYTHON_SITE_PACKAGES) - AC_SUBST(BUILD_PYTHON_INC) - AC_SUBST(BUILD_PYTHON_LIB) - AC_SUBST(GLUPY_SUBDIR) - AC_SUBST(GLUPY_SUBDIR_MAKEFILE) - AC_SUBST(GLUPY_SUBDIR_SRC_MAKEFILE) + AC_SUBST(PYTHONDEV_CPPFLAGS) + AC_SUBST(PYTHONDEV_LDFLAGS) + AC_SUBST(BUILD_PYTHON_SITE_PACKAGES) + AC_SUBST(BUILD_PYTHON_INC) + AC_SUBST(BUILD_PYTHON_LIB) + AC_SUBST(GLUPY_SUBDIR) + AC_SUBST(GLUPY_SUBDIR_MAKEFILE) + AC_SUBST(GLUPY_SUBDIR_SRC_MAKEFILE) + fi fi -# end glupy section +dnl end glupy section dnl Check for userspace-rcu PKG_CHECK_MODULES([URCU], [liburcu-bp]) diff --git a/xlators/features/glupy/src/Makefile.am b/xlators/features/glupy/src/Makefile.am index 2ac0d99cd5f..dab023f69be 100644 --- a/xlators/features/glupy/src/Makefile.am +++ b/xlators/features/glupy/src/Makefile.am @@ -4,7 +4,10 @@ xlator_LTLIBRARIES = glupy.la xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features glupydir = $(xlatordir)/glupy AM_CPPFLAGS = $(PYTHONDEV_CPPFLAGS) $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src -isystem $(BUILD_PYTHON_INC) -AM_CFLAGS = $(PYTHONDEV_CFLAGS) -Wall -fno-strict-aliasing -DGLUSTER_PYTHON_PATH=\"$(glupydir)\" -DPATH_GLUSTERFS_GLUPY_MODULE=\"${xlatordir}/glupy${shrext_cmds}\" $(GF_CFLAGS) +AM_CFLAGS = $(PYTHONDEV_CPPFLAGS) -Wall -fno-strict-aliasing \ + -DGLUSTER_PYTHON_PATH=\"$(glupydir)\" \ + -DPATH_GLUSTERFS_GLUPY_MODULE=\"${xlatordir}/glupy${shrext_cmds}\" \ + $(GF_CFLAGS) # Flags to build glupy.so with glupy_la_LDFLAGS = $(PYTHONDEV_LDFLAGS) -module -avoid-version -nostartfiles -- cgit