Requiring C++11 in configure.ac

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Requiring C++11 in configure.ac

Rik-4
jwe,

We now require C++11 to build Octave, but is there a test for that in
configure.ac?

--Rik

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Requiring C++11 in configure.ac

Mike Miller-4
On Tue, Jun 20, 2017 at 09:14:01 -0700, Rik wrote:
> We now require C++11 to build Octave, but is there a test for that in
> configure.ac?

The configure script has tests for C++11 features and adds the options
to the compiler command line if needed to enable those, but there is no
error if those tests fail, it just falls back to whatever flavor of C++
the compiler handles by default.

There are variables we could use, for example

  if test x"$ac_prog_cxx_stdcxx" != xcxx11; then
    AC_MSG_ERROR([a C++11 compiler is required to build Octave])
  fi

This will probably change in the future if/when Autoconf decides to add
feature tests for C++14 or C++17.

--
mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Requiring C++11 in configure.ac

John W. Eaton
Administrator
On 06/20/2017 01:20 PM, Mike Miller wrote:
> On Tue, Jun 20, 2017 at 09:14:01 -0700, Rik wrote:
>> We now require C++11 to build Octave, but is there a test for that in
>> configure.ac?
>
> The configure script has tests for C++11 features and adds the options
> to the compiler command line if needed to enable those, but there is no
> error if those tests fail, it just falls back to whatever flavor of C++
> the compiler handles by default.

Right, those tests are added by the std-gnu11 module from gnulib.

jwe



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Requiring C++11 in configure.ac

Rik-4
In reply to this post by Rik-4
On 06/20/2017 01:41 PM, [hidden email] wrote:
> Subject: > Re: Requiring C++11 in configure.ac > From: > "John W. Eaton" [hidden email] > Date: > 06/20/2017 10:22 AM > To: > [hidden email] > CC: > [hidden email] > List-Post: > [hidden email] > Content-Transfer-Encoding: > 7bit > Precedence: > list > MIME-Version: > 1.0 > References: > <MTAwMDAwNS5ub21hZA.1497975248@quikprotect> [hidden email] > In-Reply-To: > [hidden email] > Message-ID: > [hidden email] > Content-Type: > text/plain; charset=utf-8; format=flowed > Message: > 4 > > On 06/20/2017 01:20 PM, Mike Miller wrote: >> On Tue, Jun 20, 2017 at 09:14:01 -0700, Rik wrote: >>> We now require C++11 to build Octave, but is there a test for that in >>> configure.ac? >> >> The configure script has tests for C++11 features and adds the options >> to the compiler command line if needed to enable those, but there is no >> error if those tests fail, it just falls back to whatever flavor of C++ >> the compiler handles by default. > > Right, those tests are added by the std-gnu11 module from gnulib. > > jwe
So maybe after gnulib bootstrap has occurred and the compiler and flags have been determined we should check the version with

AC_LANG_PUSH(C++)
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
                   #if (__cplusplus < 201103L)
                   #  error "Octave requires a C++11 compiler"
                   #endif
                  ]], [])],
                  [],
                  [AC_MSG_ERROR([Octave requires a C++11 compiler])])
AC_LONG_POP(C++)

--Rik

p.s. Actually, probably need to push/pop C++ as the lang before this


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Requiring C++11 in configure.ac

Mike Miller-4
On Tue, Jun 20, 2017 at 15:53:34 -0700, Rik wrote:

> So maybe after gnulib bootstrap has occurred and the compiler and flags
> have been determined we should check the version with
>
> AC_LANG_PUSH(C++)
> AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
>                    #if (__cplusplus < 201103L)
>                    #  error "Octave requires a C++11 compiler"
>                    #endif
>                   ]], [])],
>                   [],
>                   [AC_MSG_ERROR([Octave requires a C++11 compiler])])
> AC_LONG_POP(C++)

I don't think we need this. My point earlier was that the checks we
already have don't throw an error, but they do exhaustively test the
compiler better than this, and do export shell variables like
ac_cv_prog_cxx_cxx11, ac_cv_prog_cxx_stdcxx, and ac_prog_cxx_stdcxx. I
think we can use one or more of these and declare our own error message.

The Autoconf manual explicitly documents the variables
ac_cv_prog_cxx_stdcxx and ac_cv_prog_cxx_cxx11, so I think it's safe to
depend on them.

The gnulib module is a backport of Autoconf's facility until everyone is
on Autoconf 2.70 or newer.

--
mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Requiring C++11 in configure.ac

Mike Miller-4
On Tue, Jun 20, 2017 at 16:18:48 -0700, Mike Miller wrote:
> The Autoconf manual explicitly documents the variables
> ac_cv_prog_cxx_stdcxx and ac_cv_prog_cxx_cxx11, so I think it's safe to
> depend on them.

I'm testing the following change with gcc 6.3, 4.8, and 4.6. It should
fail with 4.6 or older.


diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -398,6 +398,12 @@ AC_PROG_CC
 AC_PROG_CPP
 AC_PROG_GCC_TRADITIONAL
 
+## Ensure that the C++ compiler fully supports C++11.
+
+if test x"$ac_cv_prog_cxx_cxx11" = xno; then
+  AC_MSG_ERROR([a compiler that fully supports C++11 is required to build Octave])
+fi
+
 ## Save and restore CFLAGS and CXXFLAGS globally.  These variables
 ## are for users, so we shouldn't be touching them.  Instead, we should
 ## set the corresponding AM_ flags (currently by way of the XTRA_ variables).


--
mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Requiring C++11 in configure.ac

Rik-4
On 06/20/2017 05:25 PM, Mike Miller wrote:

> On Tue, Jun 20, 2017 at 16:18:48 -0700, Mike Miller wrote:
>> The Autoconf manual explicitly documents the variables
>> ac_cv_prog_cxx_stdcxx and ac_cv_prog_cxx_cxx11, so I think it's safe to
>> depend on them.
> I'm testing the following change with gcc 6.3, 4.8, and 4.6. It should
> fail with 4.6 or older.
>
>
> diff --git a/configure.ac b/configure.ac
> --- a/configure.ac
> +++ b/configure.ac
> @@ -398,6 +398,12 @@ AC_PROG_CC
>  AC_PROG_CPP
>  AC_PROG_GCC_TRADITIONAL
>  
> +## Ensure that the C++ compiler fully supports C++11.
> +
> +if test x"$ac_cv_prog_cxx_cxx11" = xno; then
> +  AC_MSG_ERROR([a compiler that fully supports C++11 is required to build Octave])
> +fi
> +
>  ## Save and restore CFLAGS and CXXFLAGS globally.  These variables
>  ## are for users, so we shouldn't be touching them.  Instead, we should
>  ## set the corresponding AM_ flags (currently by way of the XTRA_ variables).
>
>

Since ac_cv_prog_cxx_cxx11 will be unconditionally you won't need the
x"..." syntax.

For example, this snippet from configure.ac:

if test $ac_cv_f77_compiler_gnu = yes; then

--Rik

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Requiring C++11 in configure.ac

Mike Miller-4
In reply to this post by Mike Miller-4
On Tue, Jun 20, 2017 at 17:25:19 -0700, Mike Miller wrote:
> I'm testing the following change with gcc 6.3, 4.8, and 4.6. It should
> fail with 4.6 or older.

Made this change on default

  https://hg.savannah.gnu.org/hgweb/octave/rev/af611609c6a4

Thanks for moving this C++11 adoption along.

--
mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Requiring C++11 in configure.ac

Mike Miller-4
In reply to this post by Rik-4
On Tue, Jun 20, 2017 at 18:10:48 -0700, Rik wrote:
> Since ac_cv_prog_cxx_cxx11 will be unconditionally you won't need the
> x"..." syntax.

Its value may be empty. The definition of this variable is it is either
the option to be passed to the compiler (e.g. "-std=c++11"), or empty if
no option is required, or the word "no".

--
mike

Loading...