[GRASS-dev] FORTIFY_SOURCE=2 brakes congigure

Hi,

Arch has recently added CPPFLAGS="-D_FORTIFY_SOURCE=2" [1] to its package and build management toolset config [2].

This brakes ./configure for any GRASS version as follows:

$ CPPFLAGS="-D_FORTIFY_SOURCE=2" ./configure | tail
configure: error: *** Unable to locate curses includes.
checking for X... libraries , headers /usr/include
checking for dnet_ntoa in -ldnet... no
checking for dnet_ntoa in -ldnet_stub... no
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking whether to use Curses... yes
checking for curses.h... no

--without-curses makes it pass only until:

checking for zlib.h... no
configure: error: *** Unable to locate zlib includes.

Is there something that GRASS can do about this problem?

BTW, I found an old ticket [3] where Glynn says GRASS 7 don't use curses at all. Is it still not going to?

Maciek

[1] https://projects.archlinux.org/svntogit/packages.git/diff/trunk/makepkg.conf?h=packages/pacman&id=a050c8a4e9bb27693dc848f923564223defbb76c

[2] https://projects.archlinux.org/svntogit/packages.git/tree/trunk/makepkg.conf?h=packages/pacman#n32

[3] http://trac.osgeo.org/grass/ticket/473

--
Maciej Sieczka
http://www.sieczka.org

On Sun, Apr 21, 2013 at 8:23 PM, Maciej Sieczka <msieczka@sieczka.org> wrote:

Hi,

Arch has recently added CPPFLAGS="-D_FORTIFY_SOURCE=2" [1] to its package
and build management toolset config [2].

This brakes ./configure for any GRASS version as follows:

$ CPPFLAGS="-D_FORTIFY_SOURCE=2" ./configure | tail
configure: error: *** Unable to locate curses includes.

... apparently you try with GRASS 6 here?
Because:

[neteler@oboe grass70]$ grep curses *
configure:#AC_CHECK_HEADERS(curses.h limits.h termio.h termios.h
unistd.h values.h)
configure.in:#AC_CHECK_HEADERS(curses.h limits.h termio.h termios.h
unistd.h values.h)

in GRASS 7 it is commented.

Testing it with GRASS 7 I also get the complaint about missing zlib.h.
But check config.log:

configure:4988: gcc -o conftest -g -O2 -D_FORTIFY_SOURCE=2
-Wl,--export-dynamic conftest.c 1>&5
configure:5071: checking for location of zlib includes
configure:5097: checking for zlib.h
configure:5105: /lib/cpp -I/usr/include -D_FORTIFY_SOURCE=2
conftest.c >/dev/null 2>conftest.out
In file included from /usr/include/sys/types.h:25:0,
                 from /usr/include/zconf.h:424,
                 from /usr/include/zlib.h:34,
                 from configure:5101:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE
requires compiling with optimization (-O) [-Wcpp]
configure: failed program was:
#line 5100 "configure"
#include "confdefs.h"
#include <zlib.h>

Hence (guessing):
CFLAGS="-O" CPPFLAGS="-O -D_FORTIFY_SOURCE=2" ./configure
...
Now it passes.

If other errors occur, config.log will tell.

Markus

W dniu 21.04.2013 21:43, Markus Neteler pisze:

On Sun, Apr 21, 2013 at 8:23 PM, Maciej Sieczka <msieczka@sieczka.org> wrote:

Arch has recently added CPPFLAGS="-D_FORTIFY_SOURCE=2" [1] to its package
and build management toolset config [2].

This brakes ./configure for any GRASS version as follows:

$ CPPFLAGS="-D_FORTIFY_SOURCE=2" ./configure | tail
configure: error: *** Unable to locate curses includes.

... apparently you try with GRASS 6 here?

7 svn too.

/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE
requires compiling with optimization (-O) [-Wcpp]

Missed that. Thanks.

`CPPFLAGS="-O -D_FORTIFY_SOURCE=2" ./configure' works. I don't like the idea of forcing the optimisation though. I think I'll rather override the Arch's default with -D_FORTIFY_SOURCE=0.

Maciek

--
Maciej Sieczka
http://www.sieczka.org

On Sun, Apr 21, 2013 at 11:08 PM, Maciej Sieczka <msieczka@sieczka.org> wrote:

W dniu 21.04.2013 21:43, Markus Neteler pisze:

On Sun, Apr 21, 2013 at 8:23 PM, Maciej Sieczka wrote:

$ CPPFLAGS="-D_FORTIFY_SOURCE=2" ./configure | tail
configure: error: *** Unable to locate curses includes.

... apparently you try with GRASS 6 here?

7 svn too.

Old local copy of GRASS 7? Try

grep curses config*

For me it results as commented and inactive.

Markus

W dniu 21.04.2013 23:14, Markus Neteler pisze:

On Sun, Apr 21, 2013 at 11:08 PM, Maciej Sieczka <msieczka@sieczka.org> wrote:

W dniu 21.04.2013 21:43, Markus Neteler pisze:

On Sun, Apr 21, 2013 at 8:23 PM, Maciej Sieczka wrote:

$ CPPFLAGS="-D_FORTIFY_SOURCE=2" ./configure | tail
configure: error: *** Unable to locate curses includes.

... apparently you try with GRASS 6 here?

7 svn too.

Old local copy of GRASS 7? Try

grep curses config*

For me it results as commented and inactive.

Ahh, alright. It's about the zlib includes, and as expected:

$ svn info
Path: .
Working Copy Root Path: /home/users/pok/aur/grass70-svn/src/grass70-svn
URL: http://svn.osgeo.org/grass/grass/trunk
Repository Root: http://svn.osgeo.org/grass
Repository UUID: 15284696-431f-4ddb-bdfa-cd5b030d7da7
Revision: 55941
Node Kind: directory
Schedule: normal
Last Changed Author: hamish
Last Changed Rev: 55939
Last Changed Date: 2013-04-22 06:42:58 +0200 (Mon, 22 Apr 2013)

$ CPPFLAGS="-D_FORTIFY_SOURCE=2" ./configure | tail
configure: error: *** Unable to locate zlib includes.
checking for library containing cuserid... none required
checking for asprintf... yes
checking for atan... no
checking for atan in -lm... yes
checking for dlsym... no
checking for dlsym in -ldl... yes
checking for iconv... yes
checking for socket... yes
checking for location of zlib includes...
checking for zlib.h... no

I saw what I wanted to ;).

Maciek

--
Maciej Sieczka
http://www.sieczka.org

W dniu 21.04.2013 23:08, Maciej Sieczka pisze:

W dniu 21.04.2013 21:43, Markus Neteler pisze:

On Sun, Apr 21, 2013 at 8:23 PM, Maciej Sieczka <msieczka@sieczka.org>

/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE
requires compiling with optimization (-O) [-Wcpp]

Missed that. Thanks.

Wait a sec - but the default makepkg.conf *does* enable -O2 in CFLAGS and CXXFLAGS [1]. So why would I have to set it in the CPPFLAGS too?

`CPPFLAGS="-O -D_FORTIFY_SOURCE=2" ./configure' works. I don't like the
idea of forcing the optimisation though. I think I'll rather override
the Arch's default with -D_FORTIFY_SOURCE=0.

But thinking more about it, I find it hard to believe that Arch developers would relase a makepkg.conf with CPPFLAGS="-D_FORTIFY_SOURCE=2" enabled, knowing that it would brake configure for lots of software. Haven't heard of any. Yet, for GRASS it does brake it.

I have noticed GRASS's configure was generated with a very old autoconf version (2.13, dated 1999). So I have run a mindeless `autoreconf --force' (v. 2.69) for 6.4RC3. This has thrown severeal warnings [2], but after that 6.4RC3 configures fine even with CPPFLAGS="-D_FORTIFY_SOURCE=2". make fails miserably though.

To me this suggests that it might actually be the GRASS ancient configure script at fault here, rather than Arch default build env configuration. I know nothing about autotools, so maybe someone who knows this stuff could give his opinion?

Maciek

[1] https://projects.archlinux.org/svntogit/packages.git/tree/trunk/makepkg.conf?h=packages/pacman#n32

[2] $ autoreconf --force
autoheader: warning: missing template: CURSES_MAXY
autoheader: Use AC_DEFINE([CURSES_MAXY], , [Description])
autoheader: warning: missing template: HAVE_FFMPEG
autoheader: warning: missing template: HAVE_GDAL
autoheader: warning: missing template: HAVE_GEOS
autoheader: warning: missing template: HAVE_KEYPAD
autoheader: warning: missing template: HAVE_LARGEFILES
autoheader: warning: missing template: HAVE_LIBATLAS
autoheader: warning: missing template: HAVE_LIBBLAS
autoheader: warning: missing template: HAVE_LIBLAPACK
autoheader: warning: missing template: HAVE_LONG_LONG_INT
autoheader: warning: missing template: HAVE_OGR
autoheader: warning: missing template: HAVE_PBUFFERS
autoheader: warning: missing template: HAVE_PIXMAPS
autoheader: warning: missing template: HAVE_POSTGRES
autoheader: warning: missing template: HAVE_PQCMDTUPLES
autoheader: warning: missing template: HAVE_SOCKET
autoheader: warning: missing template: HAVE_SQLITE
autoheader: warning: missing template: HAVE_TCLTK
autoheader: warning: missing template: OPENGL_AQUA
autoheader: warning: missing template: OPENGL_WINDOWS
autoheader: warning: missing template: OPENGL_X11
autoheader: warning: missing template: PEEK_XCLOSEIM
autoheader: warning: missing template: STATIC_BUILD
autoheader: warning: missing template: USE_DELTA_FOR_TZ
autoheader: warning: missing template: USE_NLS
autoheader: warning: missing template: _OE_SOCKETS
autoheader: warning: missing template: _POSIX_PTHREAD_SEMANTICS
autoheader: warning: missing template: _REENTRANT
autoheader: warning: missing template: _XOPEN_SOURCE
autoheader: warning: missing template: _XOPEN_SOURCE_EXTENDED
autoreconf: /usr/bin/autoheader failed with exit status: 1

--
Maciej Sieczka
http://www.sieczka.org