NWChemEx / .github

GitHub Settings for the NWChemEx Organization
https://nwchemex.github.io/.github/
Apache License 2.0
1 stars 2 forks source link

C++-compiler/Cppyy compatability #29

Open ryanmrichard opened 2 years ago

ryanmrichard commented 2 years ago

My newest problem when trying to run the test_python executable in the NWChemEx repo:

Test command: /home/ryan/workspaces/NWX/NWChemEx/venv/bin/python3 "/home/ryan/workspaces/NWX/NWChemEx/tests/test_python.py"
2: Environment variables: 
2:  PYTHONPATH=/home/ryan/workspaces/NWX/NWChemEx/build/Python
2: Test timeout computed to be: 1500
2: Traceback (most recent call last):
2:   File "/home/ryan/workspaces/NWX/NWChemEx/tests/test_python.py", line 2, in <module>
2:     from nwchemex import *
2:   File "/home/ryan/workspaces/NWX/NWChemEx/build/Python/nwchemex/__init__.py", line 3, in <module>
2:     from integrals import *
2:   File "/home/ryan/workspaces/NWX/NWChemEx/build/Python/integrals/__init__.py", line 3, in <module>
2:     from simde import *
2:   File "/home/ryan/workspaces/NWX/NWChemEx/build/Python/simde/__init__.py", line 3, in <module>
2:     from chemist import *
2:   File "/home/ryan/workspaces/NWX/NWChemEx/build/Python/chemist/__init__.py", line 3, in <module>
2:     from tensorwrapper import *
2:   File "/home/ryan/workspaces/NWX/NWChemEx/build/Python/tensorwrapper/__init__.py", line 3, in <module>
2:     from parallelzone import *
2:   File "/home/ryan/workspaces/NWX/NWChemEx/build/Python/parallelzone/__init__.py", line 17, in <module>
2:     cppyy.include(inc)
2:   File "/home/ryan/workspaces/NWX/NWChemEx/venv/lib/python3.8/site-packages/cppyy/__init__.py", line 245, in include
2:     raise ImportError('Failed to load header file "%s"%s' % (header, err.err))
2: ImportError: Failed to load header file "/home/ryan/workspaces/NWX/ParallelZone/include/parallelzone/archive_wrapper.hpp"
2: In file included from input_line_20:1:
2: In file included from /home/ryan/workspaces/NWX/ParallelZone/include/parallelzone/archive_wrapper.hpp:2:
2: In file included from /home/ryan/workspaces/NWX/ParallelZone/include/parallelzone/serialization.hpp:26:
2: In file included from /home/ryan/workspaces/NWX/NWChemEx/build/_deps/cereal-src/include/cereal/types/valarray.hpp:36:
2: /usr/include/c++/9/valarray:1214:5: error: exception specification in declaration does not match previous declaration
2:     begin(valarray<_Tp>& __va) noexcept
2:     ^
2: /usr/include/c++/9/bits/range_access.h:104:31: note: previous declaration is here
2:   template<typename _Tp> _Tp* begin(valarray<_Tp>&);                                   ^

The test_nwchemex executable builds fine and runs correctly. I'm not 100% sure what the problem is here, but I'm guess it has something to do with the build settings of the C++-compiler used to build Cppyy being incompatible with those used to build NWChemEx. I will update as I figure out more.

So why is this issue in this repo? Assuming this is somehow a compiler compatibility issue the FindCppyy.cmake script should be testing for compatibility. Alternatively, if Cppyy is going to be this tightly coupled to the compiler used to build NWChemEx, Cppyy should be built by NWChemEx as

ryanmrichard commented 2 years ago

@wadejong do you have any suggestions? I'm out of ideas and this is holding me back. I tried setting the environment variables CC and CXX respectively to the C and C++ compiler I want Cppyy to use before pip install -no-cache-dir cppyy, but that didn't fix it.

evaleev commented 2 years ago

@ryanmrichard sounds like a bug in the standard library implementation ... mismatch between function declaration and definition, perhaps it's been fixed since 9 (I mean gcc 12 is out now)... though valarray is not the most popular part of C++

ryanmrichard commented 2 years ago

@evaleev trying a new version is a good idea. That said, I don't think this is C++ problem since the C++ side of things compiles just fine.

ryanmrichard commented 2 years ago

@evaleev I also think the error is weird because those aren't the same declarations (one's the begin method of the valarray class and the other is the begin free function overloaded for valarray).

evaleev commented 2 years ago

@ryanmrichard the C++ code compiles because its compiler is lax (gcc 9? I'd imagine cppyy uses libclang, diff and probably better frontend overall) ... this is an error. P.S. since /usr/include/c++/9/valarray's begin takes an argument it's not a member function of valarray ... please show what the code around /usr/include/c++/9/valarray:1214 looks like.

ryanmrichard commented 2 years ago

:facepalm: @evaleev you're right (that's a free function in the valarray file too). You also called it on the version problem. Switching the version to GCC11 seems to have worked.

Sigh, I swear we established that GCC 9 and 11 worked for NWX and it was 10 that didn't...

I'm going to leave this issue open because if GCC 9 doesn't work then the configuration should crash.

wadejong commented 2 years ago

I run gcc 9.4, no issues. Let me see what is going on. Also, I will tests cppyy 2.4.0, this one should have some cleanups that would help.