Cannot compile with gcc 4.8

Vernon Schryver vjs@rhyolite.com
Sun Jun 15 07:06:25 UTC 2014


I wrote that 

> Running the DCC ./configure with 
>     CPPFLAS=-D_FORTIFY_SOURCE=2

doesn't fail.  I now see that CPPFLAS differs from CPPFLAGS.

I have diagnosed the problem.  When ./configure tries 
    cc -E -D_FORTIFY_SOURCE=2 ...
to run cpp, it gets what it considers an error:
    /usr/include/features.h:341:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
     #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
	^

That warning happens with the change in /usr/include/features.h from

    #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
	&& __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
    # if _FORTIFY_SOURCE > 1
    #  define __USE_FORTIFY_LEVEL 2
    # else
    #  define __USE_FORTIFY_LEVEL 1
    # endif
    #else
    # define __USE_FORTIFY_LEVEL 0
    #endif

to

    #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0
    # if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0
    #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    # elif !__GNUC_PREREQ (4, 1)
    #  warning _FORTIFY_SOURCE requires GCC 4.1 or later
    # elif _FORTIFY_SOURCE > 1
    #  define __USE_FORTIFY_LEVEL 2
    # else
    #  define __USE_FORTIFY_LEVEL 1
    # endif
    #endif
    #ifndef __USE_FORTIFY_LEVEL
    # define __USE_FORTIFY_LEVEL 0
    #endif


I think that putting _FORTIFY_SOURCE into CPPFLAGS is a bug in the
Arch Linux packaging system.

I also think that checking compiler optimzation levels in cpp is a gcc
bug, even there is no way to know whether cpp is running by itself 
(including as gcc -E) or as a C compiler pre-processor.

Judging from a little Google searching, this will be a widespread problem
as more Linux distributions get the new gcc features.h and if they
make the same choice as Arch Linux of treating -D_FORTIFY_SOURCE
as a pre-preprocessor setting (CPPFLAGS) instead of a compiler
setting (CFLAGS).  By "widespread", by which I mean not just DCC.


Vernon Schryver    vjs@rhyolite.com



More information about the DCC mailing list

Contact vjs@rhyolite.com by mail or use the form.