[Dune] [Dune-Commit] dune-common r6651 - branches/cmake/cmake/modules

Bård Skaflestad Bard.Skaflestad at sintef.no
Mon Apr 23 16:47:36 CEST 2012


On Mon, 2012-04-23 at 15:56 +0200, Christian Engwer wrote:
> Hi Bard,
> 
> > Just a tangential note: As far as I understand the CXX variable is
> > generally considered a user variable in the Autotools and a particular
> > build system should treat CXX as equally off-limits as the CXXFLAGS.
> > Might it be better to pass the "-std=" option in the AM_CXXFLAGS?  In
> > practice, though, this is probably a non-issue.
> 
> I think the user is well aware, that changing CXX is dangerous, think
> e.g. of g++ vs. clang. The AM_CXXFLAGS on the other hand are sometimes
> modified in the Makefile.am, as many people only expect them to hold
> information like debug/release flags. If you want to make sure that
> the code is compiled without any optimization you might be tempted to
> modify AM_CXXFLAGS. That is the reason we have chosen to modify CXX
> instead. If you want to use an other compiler you modify CXX, if this
> means you drop "-std=" OK... it is similar to switching from g++-4.4
> to g++-4.1. Suddenly the compiler supports less features, thus you
> have to update the buildsystem accordingly.

On the contrary--the intended effect of CXX is to allow the user to
freely inject another toolchain into the build--assuming it is able to
build the project in the first place, that is.  For instance, I have a
pair of configurations that modify only the CXX (one is "g++-4.1", the
other is plain "g++" that just happens to correspond to GCC 4.4 on this
particular system).  One might similarly envision a user's desire to
build 32-bit binaries by specifying CXX="g++ -m32".  Moreover, I very
much think that the choice of debug versus release should be made
through the CXXFLAGS--typically at configure time.  A build system has
no business overriding a configuration's choice of debug level--that is
entirely up to the builder.

On the other hand, a build system is very much obligated to define all
aspects of the system that are needed to have the build complete at all.
Such aspects might include additional "-I" or "-L" directives or,
possibly, compiler flags needed to enable specific, required compiler
features (e.g., the support for C++11).  This is the purpose of the AM_*
flags which a *user* (conventionally) is not allowed to modify.  In
other words, the AM_* flags are for internal use of an Autotools build
system only.  In this respect, the AM_* flags play the same role as the 

    _[upper case] or __[alphanumeric character]

global namespaces of the C++ standard.

Hypothetically, a new toolchain might come along in a few months' time.
One that does not need (or support) the "-std=" option to enable C++11.
In my opinion, one possible way to support this toolchain would be to
have GXX0X (a.k.a., dune-common/m4/cxx0x_compiler.m4) AC_SUBST a
variable (DUNE_CXX11_FLAGS, to pick a random name) containing the flags
needed to enable C++11 and then have the AM_CXXFLAGS reference this
variable.


Cheers,

Bård





More information about the Dune mailing list