[petsc-dev] configureLibrary fails for c++11 projects

Stefano Zampini stefano.zampini at gmail.com
Tue Mar 23 11:04:24 CDT 2021


The check fails within buildsystem when running mpicc -E (which uses
CXXPPFLAGS)  The package header needs c++11  to be included properly. C++11
is also needed at preprocessing time

Il Mar 23 Mar 2021, 18:59 Satish Balay <balay at mcs.anl.gov> ha scritto:

> -std=cxx11 for sure is a compile flag. But don't really know if its
> also needed at pre-process stage and/or at link stage.
>
> And for compile stage both CXXFLAGS and CXXPPFLAGS should get
> used. [PETSc makefiles make sure this is the case]
>
> And for link stage CXXFLAGS and LDFLAGS get used [but then sometimes
> we have CLINKER, and FLINKER - and they certainly don't use CXXFLAGS -
> so -std=cxx11 isn't really needed at link time?
>
> So the previous default of CXXPPFLAGS=-std=cxx11 looks reasonable to me.
>
> However if this project is not using PETSc makefiles - it should make sure
> all compile flags are grabbed.
>
> # lib/petsc/conf/variables
> PETSC_CXXCPPFLAGS       = ${PETSC_CC_INCLUDES} ${PETSCFLAGS}
> ${CXXPP_FLAGS} ${CXXPPFLAGS}
> CXXCPPFLAGS             = ${PETSC_CXXCPPFLAGS}
> PETSC_CXXCOMPILE_SINGLE = ${CXX} -o $*.o -c ${CXX_FLAGS} ${CXXFLAGS}
> ${CXXCPPFLAGS}
>
> # lib/petsc/conf/rules
> .cpp.o .cxx.o .cc.o .C.o:
>         ${PETSC_CXXCOMPILE_SINGLE} `pwd`/$<
>
> # gmakefile.test
> PETSC_COMPILE.cxx = $(call quiet,CXX) -c $(CXX_FLAGS) $(CXXFLAGS)
> $(CXXCPPFLAGS) $(CXX_DEPFLAGS)
>
> # lib/petsc/conf/test
> LINK.cc = $(CXXLINKER) $(CXX_FLAGS) $(CXXFLAGS) $(CXXCPPFLAGS) $(LDFLAGS)
>
> Satish
>
>
> On Tue, 23 Mar 2021, Junchao Zhang wrote:
>
> > I would rather directly change the project to use CXXFLAGS instead of
> > CXXPPFLAGS.
> >
> > --Junchao Zhang
> >
> >
> > On Tue, Mar 23, 2021 at 10:01 AM Satish Balay via petsc-dev <
> > petsc-dev at mcs.anl.gov> wrote:
> >
> > > On Tue, 23 Mar 2021, Stefano Zampini wrote:
> > >
> > > > Just tried out of main, and and the include tests of a c++11 project
> fail
> > > > Below my fix, if we agree on, I'll make a MR
> > > >
> > > > diff --git a/config/BuildSystem/config/compilers.py
> > > > b/config/BuildSystem/config/compilers.py
> > > > index c96967e..44e4657 100644
> > > > --- a/config/BuildSystem/config/compilers.py
> > > > +++ b/config/BuildSystem/config/compilers.py
> > > > @@ -527,6 +527,8 @@ class Configure(config.base.Configure):
> > > >          if self.setCompilers.checkCompilerFlag(flag, includes,
> > > > body+body14):
> > > >            newflag = getattr(self.setCompilers,LANG+'FLAGS') + ' ' +
> > > flag #
> > > > append flag to the old
> > > >            setattr(self.setCompilers,LANG+'FLAGS',newflag)
> > > > +          newflag = getattr(self.setCompilers,LANG+'PPFLAGS') + ' '
> +
> > > flag
> > > > # append flag to the old
> > > > +          setattr(self.setCompilers,LANG+'PPFLAGS',newflag)
> > >
> > >
> > >
> https://gitlab.com/petsc/petsc/commit/ead1aa4045d7bca177e78933b9ca25145fc3c574
> > >
> > >           self.setCompilers.CXXPPFLAGS += ' ' + flag
> > >           newflag = getattr(self.setCompilers,LANG+'FLAGS') + ' ' +
> flag #
> > > append flag to the old
> > >           setattr(self.setCompilers,LANG+'FLAGS',newflag)
> > >
> > > So the old code was setting 'PPFLAGS' - but this commit changed to
> > > 'FLAGS'. Maybe this flag is needed at both compile time and link time?
> > >
> > > So this project is somehow using CXXPPFLAGS - but not CXXFLAGS?
> > >
> > > I'm fine with adding it to PPFLAGS - duplicate listing hopefully
> shouldn't
> > > cause grief.
> > >
> > > Satish
> > >
> > > >            cxxdialect = 'C++14'
> > > >            self.addDefine('HAVE_'+LANG+'_DIALECT_CXX14',1)
> > > >            self.addDefine('HAVE_'+LANG+'_DIALECT_CXX11',1)
> > > > @@ -546,6 +548,8 @@ class Configure(config.base.Configure):
> > > >          if self.setCompilers.checkCompilerFlag(flag, includes,
> body):
> > > >            newflag = getattr(self.setCompilers,LANG+'FLAGS') + ' ' +
> > > flag #
> > > > append flag to the old
> > > >            setattr(self.setCompilers,LANG+'FLAGS',newflag)
> > > > +          newflag = getattr(self.setCompilers,LANG+'PPFLAGS') + ' '
> +
> > > flag
> > > > # append flag to the old
> > > > +          setattr(self.setCompilers,LANG+'PPFLAGS',newflag)
> > > >            cxxdialect = 'C++11'
> > > >            self.addDefine('HAVE_'+LANG+'_DIALECT_CXX11',1)
> > > >            break
> > > >
> > > >
> > > >
> > >
> > >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20210323/844e902d/attachment.html>


More information about the petsc-dev mailing list