Patchwork cmake.bbclass: modify construction of compiler flags

login
register
mail settings
Submitter Joe Slater
Date Sept. 25, 2012, 9:37 p.m.
Message ID <1348609047-4118-1-git-send-email-jslater@windriver.com>
Download mbox | patch
Permalink /patch/37223/
State New
Headers show

Comments

Joe Slater - Sept. 25, 2012, 9:37 p.m.
Use CFLAGS instead of CPPFLAGS for C_FLAGS variants.
Also remove duplicate flags from _RELEASE variants.

Signed-off-by: Joe Slater <jslater@windriver.com>

*** Note - this can break things that have never really
***        been compiled with -O2 optimization

---
 meta/classes/cmake.bbclass |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Richard Purdie - Sept. 26, 2012, 8:47 a.m.
On Tue, 2012-09-25 at 14:37 -0700, Joe Slater wrote:
> Use CFLAGS instead of CPPFLAGS for C_FLAGS variants.
> Also remove duplicate flags from _RELEASE variants.
> 
> Signed-off-by: Joe Slater <jslater@windriver.com>
> 
> *** Note - this can break things that have never really
> ***        been compiled with -O2 optimization

This change says what you're doing but not really why. How are things
broken and why is this an improvement?

Cheers,

Richard

> ---
>  meta/classes/cmake.bbclass |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
> index dcd974a..ac5c048 100644
> --- a/meta/classes/cmake.bbclass
> +++ b/meta/classes/cmake.bbclass
> @@ -19,10 +19,10 @@ OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
>  OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
>  
>  # Compiler flags
> -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS}"
> +OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}"
>  OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} -fpermissive"
> -OECMAKE_C_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} ${CPPFLAGS} -DNDEBUG"
> -OECMAKE_CXX_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} ${CXXFLAGS} -DNDEBUG"
> +OECMAKE_C_FLAGS_RELEASE ?= "${CFLAGS} -DNDEBUG"
> +OECMAKE_CXX_FLAGS_RELEASE ?= "${CXXFLAGS} -DNDEBUG"
>  
>  OECMAKE_RPATH ?= ""
>  OECMAKE_PERLNATIVE_DIR ??= ""
Slater, Joseph - Sept. 26, 2012, 5:47 p.m.
> -----Original Message-----
> From: Richard Purdie [mailto:richard.purdie@linuxfoundation.org]
> Sent: Wednesday, September 26, 2012 1:48 AM
> To: Slater, Joseph
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH] cmake.bbclass: modify construction of compiler flags
> 
> On Tue, 2012-09-25 at 14:37 -0700, Joe Slater wrote:
> > Use CFLAGS instead of CPPFLAGS for C_FLAGS variants.
> > Also remove duplicate flags from _RELEASE variants.
> >
> > Signed-off-by: Joe Slater <jslater@windriver.com>
> >
> > *** Note - this can break things that have never really
> > ***        been compiled with -O2 optimization
> 
> This change says what you're doing but not really why. How are things
> broken and why is this an improvement?

The specific problem is that, since CFLAGS are ignored, there is no difference
between debug (-O0) and production (-O2) builds.  It also seems counter-intuitive
that CXX_FLAGS are based on CXXFLAGS, but C_FLAGS are not based on CFLAGS.

Joe

> 
> Cheers,
> 
> Richard
> 
> > ---
> >  meta/classes/cmake.bbclass |    6 +++---
> >  1 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
> > index dcd974a..ac5c048 100644
> > --- a/meta/classes/cmake.bbclass
> > +++ b/meta/classes/cmake.bbclass
> > @@ -19,10 +19,10 @@ OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
> >  OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
> >
> >  # Compiler flags
> > -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS}"
> > +OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}"
> >  OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} -fpermissive"
> > -OECMAKE_C_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} ${CPPFLAGS} -DNDEBUG"
> > -OECMAKE_CXX_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} ${CXXFLAGS} -DNDEBUG"
> > +OECMAKE_C_FLAGS_RELEASE ?= "${CFLAGS} -DNDEBUG"
> > +OECMAKE_CXX_FLAGS_RELEASE ?= "${CXXFLAGS} -DNDEBUG"
> >
> >  OECMAKE_RPATH ?= ""
> >  OECMAKE_PERLNATIVE_DIR ??= ""
>

Patch

diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index dcd974a..ac5c048 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -19,10 +19,10 @@  OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
 OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
 
 # Compiler flags
-OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS}"
+OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}"
 OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} -fpermissive"
-OECMAKE_C_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} ${CPPFLAGS} -DNDEBUG"
-OECMAKE_CXX_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} ${CXXFLAGS} -DNDEBUG"
+OECMAKE_C_FLAGS_RELEASE ?= "${CFLAGS} -DNDEBUG"
+OECMAKE_CXX_FLAGS_RELEASE ?= "${CXXFLAGS} -DNDEBUG"
 
 OECMAKE_RPATH ?= ""
 OECMAKE_PERLNATIVE_DIR ??= ""