Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use and require C++17 instead of C++11 (in distro + sagelib) #37906

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

mkoeppe
Copy link
Contributor

@mkoeppe mkoeppe commented Apr 30, 2024

The compilers that we support have supported C++17 for a while (after scipy/numpy started to require this support; see #32074), but so far we have forced use of C++11.

Here we change it to forcing C++17.

The relevant m4 macros are updated from https://github.com/autoconf-archive/autoconf-archive/tree/master/m4

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@mkoeppe mkoeppe self-assigned this Apr 30, 2024
@mkoeppe mkoeppe marked this pull request as ready for review April 30, 2024 04:18
Copy link

github-actions bot commented Apr 30, 2024

Documentation preview for this PR (built with commit 49167d7; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 1, 2024

test / linux (ubuntu-focal, minimal) (and other platforms)

#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]     gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -g -O2 -g -O2 -fPIC -DUSE_THREADS=1 -DTHREAD_STACK_SIZE=4096 -Isage/rings -Isage/cpython -I/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/cysignals -I/sage/src -I/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/numpy/core/include -I/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11 -I/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11 -c sage/rings/bernmm/bern_rat.cpp -o build/temp.linux-x86_64-cpython-311/sage/rings/bernmm/bern_rat.o -std=c++17
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]     In file included from /usr/include/c++/9/set:60,
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]                      from sage/rings/bernmm/bern_rat.cpp:16:
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]     /usr/include/c++/9/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = bernmm::Item*; _Val = bernmm::Item*; _KeyOfValue = std::_Identity<bernmm::Item*>; _Compare = bernmm::Item_cmp; _Alloc = std::allocator<bernmm::Item*>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<bernmm::Item*>*]':
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]     /usr/include/c++/9/bits/stl_tree.h:2100:47:   required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = bernmm::Item*; _Val = bernmm::Item*; _KeyOfValue = std::_Identity<bernmm::Item*>; _Compare = bernmm::Item_cmp; _Alloc = std::allocator<bernmm::Item*>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = bernmm::Item*]'
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]     /usr/include/c++/9/bits/stl_tree.h:2153:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = bernmm::Item* const&; _Key = bernmm::Item*; _Val = bernmm::Item*; _KeyOfValue = std::_Identity<bernmm::Item*>; _Compare = bernmm::Item_cmp; _Alloc = std::allocator<bernmm::Item*>]'
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]     /usr/include/c++/9/bits/stl_set.h:511:48:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = bernmm::Item*; _Compare = bernmm::Item_cmp; _Alloc = std::allocator<bernmm::Item*>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<bernmm::Item*>; std::set<_Key, _Compare, _Alloc>::value_type = bernmm::Item*]'
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]     sage/rings/bernmm/bern_rat.cpp:204:33:   required from here
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]     /usr/include/c++/9/bits/stl_tree.h:785:8: error: static assertion failed: comparison object must be invocable as const
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]       785 |        is_invocable_v<const _Compare&, const _Key&, const _Key&>,
#24 3677.5   [sagelib-10.4.beta4]   [spkg-install]           |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 1, 2024

test / linux (fedora-30, minimal)

#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from /sage/local/include/lcalc/L.h:50,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from sage/libs/lcalc/lcalc_sage.h:1,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from sage/libs/lcalc/lcalc_Lfunction.cpp:1244:
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]     /sage/local/include/pari/paridecl.h:1878:19: error: return type specified for deduction guide
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]      1878 | long    rank(GEN x);
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]           |                   ^
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]     /sage/local/include/pari/paridecl.h:1878:1: error: decl-specifier in declaration of deduction guide
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]      1878 | long    rank(GEN x);
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]           | ^~~~
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]     /sage/local/include/pari/paridecl.h:1878:1: error: 'long' specified with 'rank<...auto...>'
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]     /sage/local/include/pari/paridecl.h:1878:9: error: deduction guide for 'std::rank< <template-parameter-1-1> >' must have trailing return type
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]      1878 | long    rank(GEN x);
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]           |         ^~~~
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]     In file included from /usr/include/c++/9/bits/move.h:55,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from /usr/include/c++/9/bits/stl_pair.h:59,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from /usr/include/c++/9/bits/stl_algobase.h:64,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from /usr/include/c++/9/bits/specfun.h:45,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from /usr/include/c++/9/cmath:1927,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from /usr/include/c++/9/math.h:36,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from /sage/local/var/lib/sage/venv-python3.11.1/include/python3.11/pyport.h:218,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from /sage/local/var/lib/sage/venv-python3.11.1/include/python3.11/Python.h:38,
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]                      from sage/libs/lcalc/lcalc_Lfunction.cpp:61:
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]     /usr/include/c++/9/type_traits:1257:12: note: 'template<class> struct std::rank' declared here
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]      1257 |     struct rank
#24 3437.9   [sagelib-10.4.beta4]   [spkg-install]           |            ^~~~

(This looks similar to JohnCremona/eclib#45)

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 1, 2024

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 1, 2024

Indeed already building lcalc gives (on standard-pre / linux (ubuntu-bionic-gcc_8, standard), standard-pre / linux (fedora-30, standard), standard-pre / linux (fedora-31, standard))

#24 4483.7   [lcalc-2.0.5] error installing, exit status 1. End of log file:
#24 4483.7   [lcalc-2.0.5]   [spkg-build]                  from Lcommandline_twist.cc:25:
#24 4483.7   [lcalc-2.0.5]   [spkg-build] /sage/local/include/pari/paridecl.h:1878:19: error: return type specified for deduction guide
#24 4483.7   [lcalc-2.0.5]   [spkg-build]  long    rank(GEN x);
#24 4483.7   [lcalc-2.0.5]   [spkg-build]                    ^
#24 4483.7   [lcalc-2.0.5]   [spkg-build] /sage/local/include/pari/paridecl.h:1878:1: error: decl-specifier in declaration of deduction guide
#24 4483.7   [lcalc-2.0.5]   [spkg-build]  long    rank(GEN x);
#24 4483.7   [lcalc-2.0.5]   [spkg-build]  ^~~~

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 1, 2024

conda-forge has a workaround for this https://github.com/conda-forge/lcalc-feedstock/blob/main/recipe/build.sh#L6

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 1, 2024

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 1, 2024

On stage-1 / local-macos (12, homebrew-macos-usrlocal-standard)

  [givaro-4.1.1]   [spkg-install] /bin/bash ../../../libtool  --tag=CXX   --mode=compile g++ -std=gnu++11 -std=gnu++17 -DHAVE_CONFIG_H -I. -I../../..  -I../../..  -I../../../src/kernel/integer -I../../../src/kernel -I../../../src/kernel/system -I../../../src/kernel/memory -I../../../src/kernel/ring -I../../../src/kernel  -O2 -Wall -DNDEBUG -UGIVARO_DEBUG -UDEBUG -g -O2     -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -c -o givratreconstruct.lo givratreconstruct.C
  [givaro-4.1.1]   [spkg-install] libtool: compile:  g++ -std=gnu++11 -std=gnu++17 -DHAVE_CONFIG_H -I. -I../../.. -I../../.. -I../../../src/kernel/integer -I../../../src/kernel -I../../../src/kernel/system -I../../../src/kernel/memory -I../../../src/kernel/ring -I../../../src/kernel -O2 -Wall -DNDEBUG -UGIVARO_DEBUG -UDEBUG -g -O2 -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -c givratreconstruct.C  -fno-common -DPIC -o .libs/givratreconstruct.o
  [givaro-4.1.1]   [spkg-install] In file included from givratreconstruct.C:13:
  [givaro-4.1.1]   [spkg-install] In file included from ./givaro/givrational.h:22:
  [givaro-4.1.1]   [spkg-install] In file included from ../../../src/kernel/integer/givaro/givinteger.h:24:
  [givaro-4.1.1]   [spkg-install] ../../../src/kernel/integer/givaro/random-integer.h:38:14: error: reference to 'bool_constant' is ambiguous
  [givaro-4.1.1]   [spkg-install]         std::bool_constant<_Exact_Size>::type _Exact_Size_t;
  [givaro-4.1.1]   [spkg-install]              ^
  [givaro-4.1.1]   [spkg-install] /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:452:1: note: candidate found by name lookup is 'std::__1::bool_constant'
  [givaro-4.1.1]   [spkg-install] using bool_constant = integral_constant<bool, __b>;
  [givaro-4.1.1]   [spkg-install] ^
  [givaro-4.1.1]   [spkg-install] ../../../src/kernel/integer/givaro/random-integer.h:16:5: note: candidate found by name lookup is 'std::bool_constant'
  [givaro-4.1.1]   [spkg-install]     using bool_constant = integral_constant<bool, B>;
  [givaro-4.1.1]   [spkg-install]     ^

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 1, 2024

Also ppl on stage-1 / local-macos (12, homebrew-macos-usrlocal-standard)

  [spkg-install] PIP_Tree.cc:1105:8: error: no member named 'auto_ptr' in namespace 'std'
  [spkg-install]   std::auto_ptr<PIP_Tree_Node> wrapped_node(false_child);
  [spkg-install]   ~~~~~^
  [spkg-install] PIP_Tree.cc:1105:17: error: 'PIP_Tree_Node' does not refer to a value
  [spkg-install]   std::auto_ptr<PIP_Tree_Node> wrapped_node(false_child);
  [spkg-install]                 ^
  [spkg-install] ./PIP_Tree_defs.hh:50:7: note: declared here
  [spkg-install] class PIP_Tree_Node {
  [spkg-install]       ^
  [spkg-install] PIP_Tree.cc:1105:32: error: use of undeclared identifier 'wrapped_node'
  [spkg-install]   std::auto_ptr<PIP_Tree_Node> wrapped_node(false_child);
  [spkg-install]                                ^
  [spkg-install] PIP_Tree.cc:1106:23: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
  [spkg-install]   if (y.true_child != 0) {
  [spkg-install]                       ^
  [spkg-install]                       nullptr
  [spkg-install] PIP_Tree.cc:1111:3: error: use of undeclared identifier 'wrapped_node'

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 1, 2024

Also

  [brial-1.2.8]   [spkg-install] In file included from ReductionStrategy.cc:18:
  [brial-1.2.8]   [spkg-install] In file included from ../../groebner/include/polybori/groebner/ReductionStrategy.h:20:
  [brial-1.2.8]   [spkg-install] In file included from ../../groebner/include/polybori/groebner/groebner_defs.h:10:
  [brial-1.2.8]   [spkg-install] In file included from ../../libbrial/include/polybori/polybori.h:19:
  [brial-1.2.8]   [spkg-install] In file included from ../../libbrial/include/polybori/BooleSet.h:23:
  [brial-1.2.8]   [spkg-install] ../../libbrial/include/polybori/routines/pbori_func.h:484:15: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
  [brial-1.2.8]   [spkg-install]   public std::binary_function<RhsType&, const LhsType&, RhsType&> {
  [brial-1.2.8]   [spkg-install]          ~~~~~^~~~~~~~~~~~~~~
  [brial-1.2.8]   [spkg-install]               __binary_function
  [brial-1.2.8]   [spkg-install] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
  [brial-1.2.8]   [spkg-install] using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;

@JohnCremona
Copy link
Member

Re eclib: the last release was asked for C++-11 (or later) and I recently changed to to C++-14, as I was not sure if it would make for difficulties if C++-17 was required. If not, I will change eclib's configure.ac to require C++-17 (some features of which I have avoided uusing up to now, for this reason).

@mkoeppe
Copy link
Contributor Author

mkoeppe commented May 13, 2024

@JohnCremona For the platforms that Sage supports, using C++ 17 in eclib will be fine. Note that we use specific compiler packages for some of the oldest platforms though, as indicated in the platform list in https://github.com/sagemath/sage/wiki/Sage-10.4-Release-Tour#sources

@JohnCremona
Copy link
Member

@JohnCremona For the platforms that Sage supports, using C++ 17 in eclib will be fine. Note that we use specific compiler packages for some of the oldest platforms though, as indicated in the platform list in https://github.com/sagemath/sage/wiki/Sage-10.4-Release-Tour#sources

Thanks

@mkoeppe mkoeppe added this to the sage-10.5 milestone May 31, 2024
@mkoeppe mkoeppe marked this pull request as draft August 12, 2024 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants