glotzerlab / hoomd-blue

Molecular dynamics and Monte Carlo soft matter simulation on GPUs.
http://glotzerlab.engin.umich.edu/hoomd-blue
BSD 3-Clause "New" or "Revised" License
335 stars 131 forks source link

Build fails with gcc-5.4 and boost-1.56 #173

Closed joaander closed 8 years ago

joaander commented 8 years ago

Original report by Christoph Junghans (Bitbucket: junghans, GitHub: junghans).


FAILED: /usr/lib64/ccache/bin/x86_64-pc-linux-gnu-g++  -DEIGEN_MPL2_ONLY -DENABLE_HPMC_MIXED_PRECISION -DENABLE_MPI -DENABLE_SQLITE -DNO_IMPORT_ARRAY -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -DPY_ARRAY_UNIQUE_SYMBOL=PyArrayHandle -D_REENTRANT -D_md_EXPORTS   -DNDEBUG -O2 -pipe -march=native -fomit-frame-pointer  -fPIC -I/usr/include/python2.7 -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/var/tmp/portage/sci-physics/hoomd-blue-9999/work/hoomd-blue-9999 -Iinclude -MMD -MT hoomd/md/CMakeFiles/_md.dir/module-md.cc.o -MF hoomd/md/CMakeFiles/_md.dir/module-md.cc.o.d -o hoomd/md/CMakeFiles/_md.dir/module-md.cc.o -c /var/tmp/portage/sci-physics/hoomd-blue-9999/work/hoomd-blue-9999/hoomd/md/module-md.cc
In file included from /var/tmp/portage/sci-physics/hoomd-blue-9999/work/hoomd-blue-9999/hoomd/md/module-md.cc:39:0:
/var/tmp/portage/sci-physics/hoomd-blue-9999/work/hoomd-blue-9999/hoomd/md/PPPMForceCompute.h:150:14: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
         std::unique_ptr<CommunicatorGrid<kiss_fft_cpx> > m_grid_comm_forward; //!< Communicator for charge mesh
              ^
/var/tmp/portage/sci-physics/hoomd-blue-9999/work/hoomd-blue-9999/hoomd/md/PPPMForceCompute.h:151:14: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
         std::unique_ptr<CommunicatorGrid<kiss_fft_cpx> > m_grid_comm_reverse; //!< Communicator for inv fourier mesh
              ^
In file included from /var/tmp/portage/sci-physics/hoomd-blue-9999/work/hoomd-blue-9999/hoomd/md/module-md.cc:49:0:
/var/tmp/portage/sci-physics/hoomd-blue-9999/work/hoomd-blue-9999/hoomd/md/TwoStepNPTMTK.h:160:46: error: ‘>>’ should be ‘> >’ within a nested template argument list
         std::vector<boost::shared_ptr<Variant>> m_S;  //!< Stress matrix (upper diagonal, components [xx, yy, zz, yz, xz, xy])
                                              ^
/var/tmp/portage/sci-physics/hoomd-blue-9999/work/hoomd-blue-9999/hoomd/md/TwoStepNPTMTK.h: In member function ‘virtual void TwoStepNPTMTK::setS(boost::python::list)’:
/var/tmp/portage/sci-physics/hoomd-blue-9999/work/hoomd-blue-9999/hoomd/md/TwoStepNPTMTK.h:94:81: error: ‘>>’ should be ‘> >’ within a nested template argument list
                 swapS.push_back(boost::python::extract<boost::shared_ptr<Variant>>(S[i]));
                                                                                 ^
ninja: build stopped: subcommand failed.

Adding -std=c++11 to CXXFLAGS fixed that, I guess cmake should do that automatically.

joaander commented 8 years ago

HOOMD's cmake scripts already add -std=c++11: https://bitbucket.org/glotzer/hoomd-blue/src/41205072bddf8a2b1feca4399d258ce5db686fc5/CMake/hoomd/HOOMDCFlagsSetup.cmake?at=maint&fileviewer=file-view-default

Are you working in a clean build directory?

joaander commented 8 years ago

Original comment by Christoph Junghans (Bitbucket: junghans, GitHub: junghans).


Well, Gentoo's emerge (from which the error is taken) ignores force set CXXFLAGS to inject it own flags, e.g. -O2 -pipe -march=native -fomit-frame-pointer in my case. This is to avoid problematic flags like -march=${GCC_ARCH} in the package build. I guess due to that fact that hoomd-blue cannot be build without -std=c++11 it should always be appended and not be part of CMAKE_CXX_FLAGS, which are more for the user to set (even though good defaults, like hoomd-blue has, are nice.)

joaander commented 8 years ago

Always add -std=c++11 to CXX_FLAGS

refs #173

joaander commented 8 years ago

I thought it best to put in per compiler settings because other compilers may not use the same arguments to enable the standard. But whatever, if it is good enough for gentoo, then it must be good enough for everybody. This also forces users that compile plugins to modify hoomd's cmake if they wish to compile their plugin to a different C++ standard.

The reason that hoomd defaults to -march=native is because most users do not even consider setting this, and the majority of hoomd users build it themselves on a cluster. Thus, I want the majority of users to obtain the best performance, which requires an SSE or AVX enabled arch to enable the hand-optimized vector code paths in HOOMD.

pull request #220 implements the suggested fix.

joaander commented 8 years ago

Always add -std=c++11 to CXX_FLAGS

refs #173

joaander commented 8 years ago

Merged in always-add-cpp11 (pull request #220)

Always add -std=c++11 to CXX_FLAGS

fixes #173