[X2Go-Dev] Bug#84: Hardcoded -O3 in CFLAGS

Reinhard Tartler siretart at gmail.com
Wed Jan 9 15:21:01 CET 2013


On Wed, Jan 9, 2013 at 3:16 PM, Jan Engelhardt <jengelh at inai.de> wrote:
> On Wednesday 2013-01-09 01:00, Bernard Cafarelli wrote:
>
>>Le Tue, 8 Jan 2013 17:07:12 +0100 (CET)
>>Jan Engelhardt <jengelh at inai.de> a écrit:
>>> Why would autoreconf be rerun if you use ./configure CFLAGS=-O2
>>> CXXFLAGS=-O2?
>>
>>I meant, without first removing the "-O3" from configure.in (before
>>autoreconf)
>>
>>With current configure.in, setting CXXFLAGS to "-O2" will give this:
>>nxcomp $ autoreconf && ./configure && make
>>[...]
>>g++ -c -O2 -O3 -fno-rtti -fno-exceptions -I../nx-X11/exports/include
>>-Wmissing-declarations -fPIC -DIN_ADDR_T=in_addr_t -DVERSION=\"3.5.0\"
>>-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
>>-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -Wall
>>-Wpointer-arith   EncodeBuffer.cpp
>
> I tried the following, but it's not taking any effect. Must be some
> !@#$%^& going on.
>
> <<<<
>
> Give user-specified CXXFLAGS/CFLAGS/LDFLAGS/LIBS higher precedence.
>
> ---
>  nxcomp/Makefile.in     |    6 ++----
>  nxcompext/Makefile.in  |   14 +++++++-------
>  nxcompshad/Makefile.in |    5 ++---
>  nxproxy/Makefile.in    |    4 ++--
>  4 files changed, 13 insertions(+), 16 deletions(-)
>
> Index: nx-libs-3.5.0.17/nxcomp/Makefile.in
> ===================================================================
> --- nx-libs-3.5.0.17.orig/nxcomp/Makefile.in
> +++ nx-libs-3.5.0.17/nxcomp/Makefile.in
> @@ -36,8 +36,7 @@ LIBVERSION=@LIBVERSION@
>  #
>
>  CXX         = @CXX@
> -CXXFLAGS    = @CXXFLAGS@ @X_CFLAGS@ @DEFS@ \
> -              -Wall -Wpointer-arith
> +CXXFLAGS    = @X_CFLAGS@ @DEFS@ -Wall -Wpointer-arith @CXXFLAGS@
>  CXXINCLUDES =
>  CXXDEFINES  =
>
> @@ -46,8 +45,7 @@ CXXDEFINES  =
>  #
>
>  CC          = @CC@
> -CCFLAGS     = @CFLAGS@ @X_CFLAGS@ @DEFS@ \
> -              -Wall -Wpointer-arith
> +CCFLAGS     = @X_CFLAGS@ @DEFS@ -Wall -Wpointer-arith @CFLAGS@
>  CCINCLUDES  =
>  CCDEFINES   =
>
> Index: nx-libs-3.5.0.17/nxcompext/Makefile.in
> ===================================================================
> --- nx-libs-3.5.0.17.orig/nxcompext/Makefile.in
> +++ nx-libs-3.5.0.17/nxcompext/Makefile.in
> @@ -28,26 +28,26 @@ LIBVERSION=@LIBVERSION@
>  #
>
>  CXX         = @CXX@
> -CXXFLAGS    = @CXXFLAGS@ @X_CFLAGS@ @DEFS@ \
> +CXXFLAGS    = @X_CFLAGS@ @DEFS@ \
>                -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
> -              -Wmissing-declarations -Wnested-externs
> +              -Wmissing-declarations -Wnested-externs @CXXFLAGS@
>  CXXINCLUDES = -I. -I../nxcomp
>  CXXDEFINES  =
>
>  CC          = @CC@
> -CCFLAGS     = @CFLAGS@ @X_CFLAGS@ @DEFS@ \
> +CCFLAGS     = @X_CFLAGS@ @DEFS@ \
>                -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
> -              -Wmissing-declarations -Wnested-externs
> +              -Wmissing-declarations -Wnested-externs @CFLAGS@
>  CCINCLUDES  = -I. -I../nxcomp
>  CCDEFINES   =
>
> -LDFLAGS     = @LDFLAGS@ -L../nxcomp
> -LIBS        = @LIBS@ -lz -lNX_X11 -lXcomp
> +LDFLAGS     = -L../nxcomp @LDFLAGS@
> +LIBS        = -lz -lNX_X11 -lXcomp @LIBS@
>
>  #
>  # Only if THREADS is defined
>  #
> -# LIBS = @LIBS@ -lz -ljpeg -lpthread -lNX_X11 -lXcomp
> +# LIBS = -lz -ljpeg -lpthread -lNX_X11 -lXcomp @LIBS@
>  #
>
>  srcdir      = @srcdir@
> Index: nx-libs-3.5.0.17/nxcompshad/Makefile.in
> ===================================================================
> --- nx-libs-3.5.0.17.orig/nxcompshad/Makefile.in
> +++ nx-libs-3.5.0.17/nxcompshad/Makefile.in
> @@ -31,8 +31,7 @@ LIBVERSION=@LIBVERSION@
>  #
>
>  CXX         = @CXX@
> -CXXFLAGS    = @CXXFLAGS@ @X_CFLAGS@ @DEFS@ \
> -              -Wall -Wpointer-arith
> +CXXFLAGS    = @X_CFLAGS@ @DEFS@ -Wall -Wpointer-arith @CXXFLAGS@
>  CXXINCLUDES =
>  CXXDEFINES  =
>
> @@ -48,7 +47,7 @@ CCINCLUDES  =
>  CCDEFINES   =
>
>  LDFLAGS     = @LDFLAGS@
> -LIBS        = @LIBS@ -lNX_X11
> +LIBS        = -lNX_X11 @LIBS@
>
>  #
>  # Only if THREADS is defined.
> Index: nx-libs-3.5.0.17/nxproxy/Makefile.in
> ===================================================================
> --- nx-libs-3.5.0.17.orig/nxproxy/Makefile.in
> +++ nx-libs-3.5.0.17/nxproxy/Makefile.in
> @@ -11,9 +11,9 @@ LIBVERSION=@LIBVERSION@
>  # -Wredundant-decls
>  #
>  CXX      = @CXX@
> -CXXFLAGS = @CXXFLAGS@ @X_CFLAGS@ @DEFS@ \
> +CXXFLAGS = @X_CFLAGS@ @DEFS@ \
>             -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
> -           -Wmissing-declarations -Wnested-externs
> +           -Wmissing-declarations -Wnested-externs @CXXFLAGS@
>
>  CXXINCLUDES = -I. -I../nxcomp


AFAIUI, this is not a fix. Instead of replacing the hardcoded values,
this patch ensures that all options end behind the hardcoded values.
This makes it impossible to drop compiler flags that are specified
within.

This may be fair when your goal is to only change the optimization
level, but may be insufficient when the goal is a hardened build.

-- 
regards,
    Reinhard



More information about the x2go-dev mailing list