openPMD / openPMD-api

:floppy_disk: C++ & Python API for Scientific I/O
https://openpmd-api.readthedocs.io
GNU Lesser General Public License v3.0
138 stars 51 forks source link

Problem installing 0.14.5 with GCC 8.1 #1317

Open denisbertini opened 1 year ago

denisbertini commented 1 year ago

Performed steps

try to install the new openpmd-api release:

config:

openPMD build configuration:
library Version: 0.14.5
openPMD Standard: 1.1.0
C++ Compiler: GNU 8.1.0 

led to the following output/problem during compilation

AbstractIOHandler.hpp:111:46: error: 'const openPMD::internal::FlushParams{InternalFlush}' is not a constant expression
     constexpr FlushParams defaultFlushParams{};
                                              ^

Could this be linked to a too old GNU (8.1) compiler ?

denisbertini commented 1 year ago

i changed constexpr to const and it now compiles. ctests are all passed OK.

franzpoeschel commented 1 year ago

This confuses me a bit, since the constexpr at that place is correct C++17 C++14 if I'm not severely mistaken, and our CI does cover even older GNU compilers than that. You did build the 0.14.5 tag, I assume? I also think it's unlikely that you are using the wrong C++ version, otherwise there would have been more issues building without error. Changing the constexpr to const here doesn't hurt, but it's still weird that it would be necessary..

franzpoeschel commented 1 year ago

make VERBOSE=1 would show the failing compiler invocation which might help

denisbertini commented 1 year ago
bertini@lxbk0596:~/softw/openpmd-build > make VERBOSE=1
/cvmfs/vae.gsi.de/centos7/spack-0.17/opt/linux-centos7-zen/gcc-8.1.0/cmake-3.21.4-hieqyppn4h646bts2yxllx4p2wi5njhq/bin/cmake -S/u/dbertini/softw/openpmd-api -B/u/dbertini/softw/openpmd-build --check-build-system CMakeFiles/Makefile.cmake 0
/cvmfs/vae.gsi.de/centos7/spack-0.17/opt/linux-centos7-zen/gcc-8.1.0/cmake-3.21.4-hieqyppn4h646bts2yxllx4p2wi5njhq/bin/cmake -E cmake_progress_start /u/dbertini/softw/openpmd-build/CMakeFiles /u/dbertini/softw/openpmd-build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/u/dbertini/softw/openpmd-build'
make  -f CMakeFiles/openPMD.dir/build.make CMakeFiles/openPMD.dir/depend
make[2]: Entering directory `/u/dbertini/softw/openpmd-build'
cd /u/dbertini/softw/openpmd-build && /cvmfs/vae.gsi.de/centos7/spack-0.17/opt/linux-centos7-zen/gcc-8.1.0/cmake-3.21.4-hieqyppn4h646bts2yxllx4p2wi5njhq/bin/cmake -E cmake_depends "Unix Makefiles" /u/dbertini/softw/openpmd-api /u/dbertini/softw/openpmd-api /u/dbertini/softw/openpmd-build /u/dbertini/softw/openpmd-build /u/dbertini/softw/openpmd-build/CMakeFiles/openPMD.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/u/dbertini/softw/openpmd-build'
make  -f CMakeFiles/openPMD.dir/build.make CMakeFiles/openPMD.dir/build
make[2]: Entering directory `/u/dbertini/softw/openpmd-build'
[  1%] Building CXX object CMakeFiles/openPMD.dir/src/Iteration.cpp.o
/cvmfs/vae.gsi.de/centos7/spack-0.17/opt/linux-centos7-x86_64/gcc-4.8.5/gcc-8.1.0-nswpump2zjkpne3ipmxkqt75dq6s2g7w/bin/g++ -DADIOS2_USE_MPI -DH5_BUILT_AS_DYNAMIC_LIB -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200809L -DopenPMD_EXPORTS -DopenPMD_USE_VERIFY=1 -I/u/dbertini/softw/openpmd-api/include -I/u/dbertini/softw/openpmd-build/include -isystem /u/dbertini/softw/openpmd-api/share/openPMD/thirdParty/json/single_include -isystem /cvmfs/vae.gsi.de/centos7/spack-0.17/opt/linux-centos7-zen/gcc-8.1.0/hdf5-1.10.7-yin6fo5fdgwhfjadyn25sbwqffo3j2h4/include -isystem /u/dbertini/softw/openpmd-api/share/openPMD/thirdParty/variant/include -isystem /cvmfs/vae.gsi.de/centos7/spack-0.17/opt/linux-centos7-zen/gcc-8.1.0/openmpi-3.1.6-mzgrfwlfj5it47wjcnz7el56ttf6rour/include -isystem /lustre/rz/dbertini/soft/adios2/include -Wall -Wextra -Wpedantic -Wshadow -Woverloaded-virtual -Wunreachable-code -Wsign-compare  -O3 -DNDEBUG -fPIC -fexceptions -pthread -MD -MT CMakeFiles/openPMD.dir/src/Iteration.cpp.o -MF CMakeFiles/openPMD.dir/src/Iteration.cpp.o.d -o CMakeFiles/openPMD.dir/src/Iteration.cpp.o -c /u/dbertini/softw/openpmd-api/src/Iteration.cpp
In file included from /u/dbertini/softw/openpmd-api/include/openPMD/backend/Attributable.hpp:23,
                 from /u/dbertini/softw/openpmd-api/include/openPMD/Mesh.hpp:23,
                 from /u/dbertini/softw/openpmd-api/include/openPMD/Iteration.hpp:24,
                 from /u/dbertini/softw/openpmd-api/src/Iteration.cpp:21:
/u/dbertini/softw/openpmd-api/include/openPMD/IO/AbstractIOHandler.hpp:112:45: error: 'const openPMD::internal::FlushParams{InternalFlush}' is not a constant expression
    constexpr FlushParams defaultFlushParams{};
                                             ^
make[2]: *** [CMakeFiles/openPMD.dir/src/Iteration.cpp.o] Error 1
make[2]: Leaving directory `/u/dbertini/softw/openpmd-build'
make[1]: *** [CMakeFiles/openPMD.dir/all] Error 2
make[1]: Leaving directory `/u/dbertini/softw/openpmd-build'
make: *** [all] Error 2
franzpoeschel commented 1 year ago

Ah, I forgot that our release is still C++14, making the wrong C++ version more likely. The definition of constexpr changed slightly from C++11 to C++14: Bildschirmfoto vom 2022-10-17 11-20-19 https://en.cppreference.com/w/cpp/language/aggregate_initialization#Definitions

For some reason, CMake does not set the C++ version in your build. You can try cmake . -DCMAKE_CXX_FLAGS=-std=c++14 in the build directory as a workaround, which I hope should fix it. Why using such a workaround is necessary in your case, I'm not sure

denisbertini commented 1 year ago

reinforcing compilation with cmake . -DCMAKE_CXX_FLAGS=-std=c++14 or c++17 does not help, always the same compilation error

franzpoeschel commented 1 year ago

The compiler path looks a bit weird? /cvmfs/vae.gsi.de/centos7/spack-0.17/opt/linux-centos7-x86_64/gcc-4.8.5/gcc-8.1.0-nswpump2zjkpne3ipmxkqt75dq6s2g7w/bin/g++. Is this gcc 4.8.5 or gcc 8.1.0? I can later try this out with the specific compiler version(s), but for now I would say that replacing constexpr with const seems to be a functional workaround? On dev, we have already replaced the constexpr with const for other reasons, so I see no direct need to fix anything right now.

denisbertini commented 1 year ago

It is gcc8.1.01 installed over a native centos7 OS with gcc4.8 as native compiler. Yes the replacement of constexpr to const solved the issue

franzpoeschel commented 1 year ago

The closest version that I had easily access to was gcc 8.5.0, which works without issue for me

[  1%] Building CXX object CMakeFiles/openPMD.dir/src/Iteration.cpp.o                                                        
/nix/store/qp28q00skk2wcsqvii3g47xbhz4sbq0b-gcc-wrapper-8.5.0/bin/g++ -DADIOS2_USE_MPI -DopenPMD_EXPORTS -DopenPMD_USE_VERIFY
=1 -I/home/franzpoeschel/git-repos/openPMD-api/include -I/home/franzpoeschel/git-repos/mynixpkgs/dev_shells/openpmd_dev_defau
lt/build/include -isystem /home/franzpoeschel/git-repos/openPMD-api/share/openPMD/thirdParty/json/single_include -isystem /ho
me/franzpoeschel/git-repos/openPMD-api/share/openPMD/thirdParty/variant/include -Wall -Wextra -Wpedantic -Wshadow -Woverloade
d-virtual -Wunreachable-code -Wsign-compare  -O3 -DNDEBUG -fPIC -MD -MT CMakeFiles/openPMD.dir/src/Iteration.cpp.o -MF CMakeF
iles/openPMD.dir/src/Iteration.cpp.o.d -o CMakeFiles/openPMD.dir/src/Iteration.cpp.o -c /home/franzpoeschel/git-repos/openPMD-api/src/Iteration.cpp
denisbertini commented 1 year ago

humm, do you think it is a problem linked to the GCC compiler, gcc 8.1 being too old ?

franzpoeschel commented 1 year ago

I don't really think so. Our CI also covers gcc 7.5.0. Maybe @ax3l has another idea?

denisbertini commented 1 year ago

Yes i also think so, then may be some cxx_flags are missing ?

franzpoeschel commented 1 year ago

It looks like a compiler bug, I just tried this again on godbolt.org: https://godbolt.org/z/GazbG8vss gcc 8.1 and 8.2 fail, with gcc 8.3 and greater it works gcc 7 also works

So, the easiest solution would indeed currently be to just stick with the workaround

PS: Also it is apparently linked with the constexpr change from C++11 to 14 that I mentioned above. If I remove the default param, it works without issue.

ax3l commented 1 year ago

Yes, I remember that GCC 8.1-8.2 actually has more than usual C++ frontend compiler bugs. Do you think you can get a newer version of GCC @denisbertini, e.g., 8.3, 8.4, 8.5 or any newer major release of GCC? If you update your spack 0.18.1 instead of 0.17, that should definitely know these patch releases of GCC.

GCC 7 should in general work as well for C++14 code (and most C++17 code even).

Yes i also think so, then may be some cxx_flags are missing ? ... For some reason, CMake does not set the C++ version in your build.

GCC 6 and newer default to C++14, which is all we need of this. Thus, CMake does not add superfluous flags, since we ask for C++14 in the 0.14.* release line. https://gist.github.com/ax3l/53db9fa8a4f4c21ecc5c4100c0d93c94