bugGNU Octave - Bugs: bug #65327, configure adds wrong flags to CXX...

 
 

bug #65327: configure adds wrong flags to CXX if compiler is C++20 compliant

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Sun 18 Feb 2024 04:22:25 AM UTC
   
 
Category:  Configuration and Build System Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Build Failure
Status:  Ready For Test Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  9.1.0 Planned Release:  9.1.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 19 Mar 2024 11:45:09 PM UTC, comment #11: 

Marking as Fixed and closing report.

Rik <rik5>
Group administrator
Sun 03 Mar 2024 09:50:34 AM UTC, comment #10: 

Thank you for testing.

I agree that the build errors with Clang should be handled in a different report.

IIUC, the risk of applying the suggested patch is low. Maybe, it won't work with all versions of autoconf (I haven't tested, and future changes in autoconf might cause that the un-documented workaround might no longer work). So, I pushed the change to the stable branch:
https://hg.savannah.gnu.org/hgweb/octave/rev/fe201b17eb86

In a worst case scenario, we could still revert it for a patch release.

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Fri 01 Mar 2024 05:51:09 PM UTC, comment #9: 

This works for me. I see c++20 related warnings with gcc 12 and
clang-16 erros out with

In file included from /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/vector:64:
/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/stl_vector.h:367:35: error: arithmetic on a pointer to an incomplete type 'octave::symbol_scope'
                      _M_impl._M_end_of_storage - _M_impl._M_start);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~ ^


(but those are subject to a different bug report).

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 01 Mar 2024 05:22:18 PM UTC, comment #8: 

The attached patch skips the configure test that is broken for C++20.

If no one opposes, I'd like to push that to the stable branch to avoid potential issues during the next year (until Octave 10 will be released).

@Dmitri: Does that change work for you?


(file #55761)

Markus Mützel <mmuetzel>
Group administrator
Mon 19 Feb 2024 06:19:03 PM UTC, comment #7: 

As a work-around, you could try to add `ac_cv_prog_cxx_11=yes` to the configure flags.

Markus Mützel <mmuetzel>
Group administrator
Mon 19 Feb 2024 06:18:21 PM UTC, comment #6: 

Googling around -- it looks like there are some c++20 incompatibilities with c++17 (and before).


const char* blah = u8"Foo 😀 Bar" // fine in c++17, error in c++20


cited as one of them.

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>
Mon 19 Feb 2024 06:06:44 PM UTC, comment #5: 

IIUC, that is an issue with the autoconf macro AC_PROG_CXX. Specifically, it's caused by a "feature" that was added here:
https://lists.gnu.org/archive/html/autoconf/2013-01/msg00016.html

That change added some code in a feature test for C++11 that is incompatible with C++20:
https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob;f=lib/autoconf/c.m4;h=d8eab7bbd6775b89c06b1ba19349ba3946cd7095;hb=HEAD#l2642

Thus, `-std=gnu++11` is added to your `CXX` variable, and it goes downhill from there.

Tbh, I don't understand the logic for why that was added in the first place.

I also don't know if there is an option to ask autoconf for a working C++ compiler without it (arbitrarily) adding some unnecessary (and in this case detrimental) flags.

We are already using the macro `AX_CXX_COMPILE_STDCXX` for getting potentially necessary `-std` flags (which after the first test result adds another `-std=gnu++17` in your case).

Maybe, try and report the issue to the autoconf developers?

Markus Mützel <mmuetzel>
Group administrator
Mon 19 Feb 2024 05:19:24 PM UTC, comment #4: 


> First, if multiple "-std=..." options are present, what does GCC > do?  What would clang++ or any other compiler do?


I think the last one (on the right) overwrites the previous ones.
So for some reason "g++ -std=gnu++20" fails the C++11 test:

configure:11200: checking for g++ -std=gnu++20 option to enable C++11 features
configure:11436: g++ -std=gnu++20  -c -Wall -ggdb3 -O2 -march=native -mtune=native -mavx -mavx2 -flto=auto  conftest.cpp >&5
conftest.cpp: In function 'int main()':
conftest.cpp:173:8: warning: unused variable 'a1' [-Wunused-variable]
  173 |   auto a1 = 6538;
      |        ^~
conftest.cpp:175:8: warning: unused variable 'a3' [-Wunused-variable]
  175 |   auto a3 = "String literal";
      |        ^~
conftest.cpp:177:16: warning: unused variable 'a4' [-Wunused-variable]
  177 |   decltype(a2) a4 = 34895.034;
      |                ^~
conftest.cpp:181:9: warning: unused variable 'sa' [-Wunused-variable]
  181 |   short sa[cxx11test::get_val()] = { 0 };
      |         ^~
conftest.cpp:185:23: warning: unused variable 'il' [-Wunused-variable]
  185 |   cxx11test::testinit il = { 4323, 435234.23544 };
      |                       ^~
conftest.cpp:211:8: warning: unused variable 'match' [-Wunused-variable]
  211 |   bool match = std::regex_search(testmatch, filename_regex);
      |        ^~~~~
conftest.cpp:215:35: warning: unused variable 'size' [-Wunused-variable]
  215 |   cxx11test::int_array::size_type size = array.size();
      |                                   ^~~~
conftest.cpp:220:25: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  220 |   cxx11test::delegate d2();
      |                         ^~
conftest.cpp:220:25: note: remove parentheses to default-initialize a variable
  220 |   cxx11test::delegate d2();
      |                         ^~
      |                         --
conftest.cpp:220:25: note: or replace parentheses with braces to value-initialize a variable
conftest.cpp:229:9: warning: unused variable 'c' [-Wunused-variable]
  229 |   char *c = nullptr;
      |         ^
conftest.cpp:237:22: error: invalid conversion from 'const char8_t*' to 'const char*' [-fpermissive]
  237 |   char const *utf8 = u8"UTF-8 string \u2500";
      |                      ^~~~~~~~~~~~~~~~~~~~~~~
      |                      |
      |                      const char8_t*
conftest.cpp:237:15: warning: unused variable 'utf8' [-Wunused-variable]
  237 |   char const *utf8 = u8"UTF-8 string \u2500";
      |               ^~~~
conftest.cpp:238:19: warning: unused variable 'utf16' [-Wunused-variable]
  238 |   char16_t const *utf16 = u"UTF-8 string \u2500";
      |                   ^~~~~
conftest.cpp:239:19: warning: unused variable 'utf32' [-Wunused-variable]
  239 |   char32_t const *utf32 = U"UTF-32 string \u2500";
      |                   ^~~~~
configure:11436: $? = 1
configure: failed program was:


So it adds "-std=c++11" which later would require "-std=c++17"
because of the pmr.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 19 Feb 2024 05:08:20 PM UTC, comment #3: 

The version of autoconf installed on my system is 2.71.  The latest is 2.72, released in December 2023 and it appears to do the same thing when adding flags to the C++ compiler variable CXX.  If I add "echo CXX: $CXX" before and after the AC_PROG_CXX macro in configure.ac, regenerate the configure script, and run configure with CXX="g++ -std=gnu++20", I see the following output:


CXX: g++ -std=gnu++20
checking whether the compiler supports GNU C++... yes
checking whether g++ -std=gnu++20 accepts -g... yes
checking for g++ -std=gnu++20 option to enable C++11 features... -std=gnu++11
checking dependency style of g++ -std=gnu++20 -std=gnu++11... gcc3
CXX: g++ -std=gnu++20 -std=gnu++11


So it is the autoconf AC_PROG_CXX macro that is adding the -std=gnu++11 option.  I haven't tried to decipher exactly what tests it is doing to decide that it needs to add "-std=gnu++11" but the documentation for AC_PROG_CXX says it will try to find options "to enable support for ISO Standard C++ features with extensions, preferring the newest edition of the C++ standard that is supported"

https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/html_node/C_002b_002b-Compiler.html#index-AC_005fPROG_005fCXX

Then, later in the configure script when we use


AX_CXX_COMPILE_STDCXX(17, [], [])


that macro is adding the -std=gnu++17 option to CXX.  Surrounded by "echo CXX: $CXX" statements, it reports:


CXX: g++ -std=gnu++20 -std=gnu++11
checking whether g++ -std=gnu++20 -std=gnu++11 supports C++17 features by default... no
checking whether g++ -std=gnu++20 -std=gnu++11 supports C++17 features with -std=gnu++17... yes
CXX: g++ -std=gnu++20 -std=gnu++11 -std=gnu++17


I also haven't tried to understand why it rejects "g++ -std=gnu++20 -std=gnu++11" but accepts "g++ -std=gnu++20 -std=gnu++11 -std=gnu++17".

First, if multiple "-std=..." options are present, what does GCC do?  What would clang++ or any other compiler do?

Anyway, these macros seem a bit broken for our purposes, unfortunately.

John W. Eaton <jwe>
Group administrator
Mon 19 Feb 2024 02:30:47 PM UTC, comment #2: 

Attached.

Dmitri.
--


(file #55718)

Dmitri A. Sergatskov <dasergatskov>
Mon 19 Feb 2024 09:48:29 AM UTC, comment #1: 

Could you show your config.log please?

Markus Mützel <mmuetzel>
Group administrator
Sun 18 Feb 2024 04:22:25 AM UTC, original submission:  

I compiled octave 10 (hgid 359f922209d4) with 'CXX=g++ -std=gnu++20', yet
+verbose+
octave:4> _octave_config_info_("CXX")
ans = g++ -std=gnu++20 -std=gnu++11 -std=gnu++17
-verbose-

That looks wrong.

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #55718:  config.log.gz added by dasergatskov (190KiB - application/gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by dasergatskov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-03-19 rik5 Open/ClosedOpen Closed
        Fixed ReleaseNone 9.1.0
    2024-03-03 mmuetzel StatusNone Ready For Test
    2024-03-01 mmuetzel Attached File- Added bug65327-configure-skip-c++11.patch, #55761
        Item GroupNone Build Failure
        Operating SystemGNU/Linux Any
        Planned ReleaseNone 9.1.0
        Summaryoctave 10 stores sets CXX wrong configure adds wrong flags to CXX if compiler is C++20 compliant
    2024-02-19 dasergatskov Attached File- Added config.log.gz, #55718

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code