openPMD-api icon indicating copy to clipboard operation
openPMD-api copied to clipboard

Problem installing 0.14.5 with GCC 8.1

Open denisbertini opened this issue 3 years ago • 14 comments

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 avatar Oct 17 '22 08:10 denisbertini

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

denisbertini avatar Oct 17 '22 08:10 denisbertini

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 avatar Oct 17 '22 09:10 franzpoeschel

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

franzpoeschel avatar Oct 17 '22 09:10 franzpoeschel

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

denisbertini avatar Oct 17 '22 09:10 denisbertini

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

franzpoeschel avatar Oct 17 '22 09:10 franzpoeschel

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

denisbertini avatar Oct 17 '22 11:10 denisbertini

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.

franzpoeschel avatar Oct 17 '22 11:10 franzpoeschel

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

denisbertini avatar Oct 17 '22 11:10 denisbertini

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

franzpoeschel avatar Oct 17 '22 15:10 franzpoeschel

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

denisbertini avatar Oct 17 '22 15:10 denisbertini

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

franzpoeschel avatar Oct 17 '22 15:10 franzpoeschel

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

denisbertini avatar Oct 17 '22 15:10 denisbertini

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.

franzpoeschel avatar Oct 17 '22 16:10 franzpoeschel

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

ax3l avatar Oct 17 '22 21:10 ax3l