TRIQS / triqs

a Toolbox for Research on Interacting Quantum Systems
https://triqs.github.io
GNU General Public License v3.0
135 stars 71 forks source link

Compilation with GCC 13.2 fails #915

Closed maxamsler closed 7 months ago

maxamsler commented 11 months ago

There seem to be issues with compiling TRIQS 3.2 with GCC 13.x

TRIQS compilation fails with GCC 13.2.0 with following error message:

triqs.src/c++/triqs/mc_tools/random_generator.hpp:51:64: error: ‘uint32_t’ has not been declared
   51 |       random_generator(std::string const &RandomGeneratorName, uint32_t seed_);
      |                                                                ^~~~~~~~
triqs.src/c++/triqs/mc_tools/random_generator.cpp:41:5: error: no declaration matches ‘triqs::mc_tools::random_generator::random_generator(const std::string&, uint32_t)’
   41 |     random_generator::random_generator(std::string const &RandomGeneratorName, uint32_t seed_) {
      |     ^~~~~~~~~~~~~~~~

Seems to be related to GNU 13.2.0: https://gcc.gnu.org/gcc-13/porting_to.html#header-dep-changes . Can be fixed by adding #include <cstdint> to triqs.src/c++/triqs/mc_tools/random_generator.hpp.

Further errors occur, e.g.,

triqs.src/c++/triqs/utility/legendre.cpp:20:
/bin/gnu/13.2.0/include/c++/13.2.0/utility:98:21: error: ‘is_nothrow_move_constructible’ was not declared in this scope; did you mean ‘std::is_nothrow_move_constructible’?
   98 |     noexcept(__and_<is_nothrow_move_constructible<_Tp>,
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                     std::is_nothrow_move_constructible

Seems to be related to https://eel.is/c++draft/requirements#using.headers-3, but I don't know how to fix it. Sorry.

Wentzell commented 11 months ago

Dear @maxamsler,

I am not able to reproduce the build failures with gcc 13.2

Which linux distribution are you building on?

the-hampel commented 11 months ago

Hi @maxamsler,

I was able to reproduce your problem on arch linux x86 with gcc 13.2. Indeed the include statement is not only missing in the random_generator.hpp but also in one of h5 package header files! So as a hotfix you can add the include statement in

triqs/c++/triqs/mc_tools/random_generator.hpp

and

triqs/build/deps/h5_src/c++/h5/object.hpp

Note that triqs will automatically pull the h5 src when running cmake / make. So run it once until you hit the error and then fix the source file.

After adding these two includes I was able to compile with gcc 13.2.1 and all tests are passing. Let me know if that solves your problem.

I will push a fix to the unstable branch later today and we will run it through the CI first before applying it to 3.2.x.

Best, Alex

Wentzell commented 10 months ago

@maxamsler Can you confirm that the first issue is resolved for you?

The second issue you point out looks to be unrelated to triqs, but rather like a standard library issue. Are you still seeing this problem?

maxamsler commented 8 months ago

@Wentzell and @the-hampel, I can confirm that the first issue was indeed fixed with the relevant commits. Thanks a lot!

The second error however still persists. I am on Red Hat Enterprise Linux 8.5. I also tried to compile with GCC 12.3.0 with the same outcome.

the-hampel commented 8 months ago

Hi @maxamsler, we are having trouble reproducing the error here. Could you please compile triqs in verbose mode:

VERBOSE=1 make -j1

(make sure to compile from scratch with make clean beforehand) and attach the full output, i.e. store the output in a file and upload?

The problem is quite certainly not in TRIQS and rather in some external library that your compiler tries to use.

maxamsler commented 8 months ago

Hi @the-hampel , Thanks for your help. I think I found the issue. Following your advice I checked all libraries, and I installed the latest Boost libraries (1.83.0), which solved the problem! Previously I was using 1.73.0. I was under the impression that minimum required is 1.53.x.

The tests are running mostly (3 failing, currently investigating the issues there):

99% tests passed, 3 tests failed out of 277

Total Test time (real) = 145.45 sec

The following tests FAILED:
    245 - py_gf_init (SEGFAULT)
    251 - py_gf_dlr (SEGFAULT)
    275 - py_g_k_iw (SEGFAULT)
the-hampel commented 8 months ago

Ah interesting, In ubuntu 22.04 we are using Boost 1.74 in the testing CI, which works fine. I checked the changelog of boost (https://www.boost.org/users/history/version_1_74_0.html) but could not find anything related. But maybe they changed something. The is_move_constructible functionality etc. was part of boost (I think). So maybe newer compilers have problems with old boost versions. I will try to test an older boost version and change the official requirement. Those things are always hard to find, glad it works now.

the-hampel commented 8 months ago

@Wentzell I propose to just raise the boost requirement to ver 1.74 , since this is the boost version shipped with Ubuntu 22.04. The version was released over 3 years ago. I think it is unnecessary to find out if older versions are supported at this point.

Wentzell commented 8 months ago

@the-hampel I checked explicitly the bessel function include with gcc 13.2 and boost version 1.73, see https://godbolt.org/z/65xEc6jTM

It compiles without Problems.

the-hampel commented 8 months ago

Okay yes I can confirm this. I build now triqs 3.2.x successfully on Ubuntu 23.10, gcc-13.2 python-3.11, boost-1.73 with all tests passing. Relevant cmake output:

Installation directory will be /triqs                                                  
The C compiler identification is GNU 13.2.0                                            
The CXX compiler identification is GNU 13.2.0                                          
...
-------- Python detection -------------                                                
Python interpreter /.venv/py311/bin/python3                                            
Python interpreter and modules are ok : version 3.11.6                                 
PYTHON_INCLUDE_DIRS = /usr/include/python3.11                                          
PYTHON_NUMPY_INCLUDE_DIR = /.venv/py311/lib/python3.11/site-packages/numpy/core/include
PYTHON_NUMPY_VERSION = 1.26.2                                                          
PYTHON_SITE_PKG = /.venv/py311/lib/python3.11/site-packages                            
PYTHON_LIBRARY = /usr/lib/x86_64-linux-gnu/libpython3.11.so                            
...
-------- MPI detection -------------                                                   
Found MPI_CXX: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so (found version "3.1")        
Found MPI: TRUE (found version "3.1") found components: CXX                                     
Found OpenMP_CXX: -fopenmp (found version "4.5")                                                
Found OpenMP: TRUE (found version "4.5") found components: CXX                                  
...
 =============== Configuring Dependency nda ===============                                     
...
-------- Lapack detection -------------                                                         
Found BLAS: /usr/lib/x86_64-linux-gnu/libopenblas.so                                            
Found LAPACK: /usr/lib/x86_64-linux-gnu/libopenblas.so;/usr/lib/x86_64-linux-gnu/libopenblas.so 
...                                 
-------- Boost detection -------------                                                          
Found Boost: /usr/local/include (found suitable version "1.73.0", minimum required is "1.53")   
Boost include dir: /usr/local/include                                                           
...

I am not sure what went wrong in your case @maxamsler . Since I have a working setup right now I will try no with the minimum 1.53 to check if the requirement is still good on the doc. I will share my dockerfile to build later.

the-hampel commented 8 months ago

So I tried now and boost version 1.63 is the oldest version that still works with gcc 13.2. For earlier versions I get:

In file included from /usr/local/include/boost/format/alt_sstream.hpp:173,                                                                                                                                                                                                                 
                 from /usr/local/include/boost/format/internals.hpp:23,                                                                                                                                                                                                                    
                 from /usr/local/include/boost/format.hpp:38,                                                                                                                                                                                                                              
                 from /usr/local/include/boost/math/policies/error_handling.hpp:31,                                                                                                                                                                                                        
                 from /usr/local/include/boost/math/special_functions/gamma.hpp:23,                                                           
                 from /usr/local/include/boost/math/special_functions/detail/bessel_jy.hpp:14,                                                
                 from /usr/local/include/boost/math/special_functions/bessel.hpp:20,                                                          
                 from /source/triqs.src/c++/triqs/utility/legendre.cpp:20:                                                                    
/usr/local/include/boost/format/alt_sstream_impl.hpp: In instantiation of 'boost::io::basic_altstringbuf<Ch, Tr, Alloc>::int_type boost::io::basic_altstringbuf<Ch, Tr, Alloc>::overflow(int_type) [with Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; int_type = i

/usr/local/include/boost/format/alt_sstream_impl.hpp:227:9:   required from here                                                              
/usr/local/include/boost/format/alt_sstream_impl.hpp:261:45: error: no matching function for call to 'std::allocator<char>::allocate(std::size_t&, char*)'
  261 |                     newptr = alloc_.allocate(new_size, is_allocated_? oldptr : 0);                                                    
      |                              ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                     
In file included from /usr/include/c++/13/string:43,                                                                                          
                 from /usr/include/c++/13/bits/locale_classes.h:40,                                                                           
                 from /usr/include/c++/13/bits/ios_base.h:41,                                                                                 
                 from /usr/include/c++/13/ios:44,                                                                                             
                 from /usr/include/c++/13/istream:40,                                                                                         
                 from /usr/include/c++/13/sstream:40,                                                                                         
                 from /usr/include/c++/13/complex:45,                                                                                         
                 from /source/triqs.src/c++/triqs/utility/legendre.hpp:22,                                                                    
                 from /source/triqs.src/c++/triqs/utility/legendre.cpp:18:                                                                    
/usr/include/c++/13/bits/allocator.h:189:7: note: candidate: 'constexpr _Tp* std::allocator< <template-parameter-1-1> >::allocate(std::size_t) [with _Tp = char; std::size_t = long unsigned int]'
  189 |       allocate(size_t __n)                                                                                                            
      |       ^~~~~~~~                                                                                                                        
/usr/include/c++/13/bits/allocator.h:189:7: note:   candidate expects 1 argument, 2 provided                                                  
make[2]: *** [c++/triqs/CMakeFiles/triqs.dir/build.make:370: c++/triqs/CMakeFiles/triqs.dir/utility/legendre.cpp.o] Error 1                   

I think earlier version are not compatible with the c++ standard we are requiring. Here is the dockerfile for testing. The variable BVER sets the minor boost version - in case you want to reproduce the problem. Maybe one can fiddle around with the boost compile option to make it work, but I would say we should raise the version requirement to 1.63 .

Dockerfile_triqs_boost_test.txt

maxamsler commented 8 months ago

@the-hampel OK, perhaps my earlier compilation of Boost was faulty. Now all is working as expected. Thanks for your support!