memilio icon indicating copy to clipboard operation
memilio copied to clipboard

Boost headers conflict with install boost library

Open dabele opened this issue 2 years ago • 2 comments

Bug description

On the SC HPDA Cluster, the build fails with an error in boost libraries if the boost module is loaded.

Version

Linux

To reproduce

  • module load PrgEnv/gcc11-openmpi (loads compiler, etc. but also boost libraries)
  • build memilio as normal

Relevant log output

error: declaration of 'const boost::system::error_category& boost::filesystem::codecvt_error_category()' has a different exception specifier
   70 |     BOOST_FILESYSTEM_DECL const boost::system::error_category& codecvt_error_category()
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/abel_da/memilio/cpp/build/boost_1_75_0/libs/filesystem/src/codecvt_error_category.cpp:16:
/scratch/spack-22.2/opt/spack/linux-ubuntu20.04-skylake_avx512/gcc-11.3.0/boost-1.79.0-44fkepcperfvnjfzugsukpqidlsmmyfh/include/boost/filesystem/path_traits.hpp:32:53: note: from previous declaration 'const boost::system::error_category& boost::filesystem::codecvt_error_category() noexcept'
   32 | BOOST_FILESYSTEM_DECL system::error_category const& codecvt_error_category() BOOST_NOEXCEPT;
      |                                                     ^~~~~~~~~~~~~~~~~~~~~~

Add any relevant information, e.g. used compiler, screenshots.

No response

Checklist

  • [X] Attached labels, especially loc:: or model:: labels.
  • [X] Linked to project

dabele avatar Nov 29 '23 11:11 dabele

This happens because the headers from the boost module are used ahead of the boost headers included with memilio. Note the two different boost include paths in the error message.

Workaround:

  • remove the SYSTEM flag from target_include_directories(boost SYSTEM INTERFACE in cpp/cmake/BuildBoost.cmake that we added in #787
  • disable compiler warnings by commenting out the area around MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS in cpp/CMakeLists.txt

Explanation: The boost module sets the CPATH environment variable. CPATH is equivalent to the -I compile flag, whereas target_include_directories(... SYSTEM) adds -isystem. -I has a higher priority than -isystem, so the module headers are found.

Real Solutions?:

  1. maybe this should not be considered a bug of memilio? It's only on some systems and there is a workaround, so may be safe to ignore.
  2. don't set the SYSTEM flag in CMake, treat warnings from boost manually?
  3. change the modulefiles to not set the CPATH variable? May have sideeffects for other users of the modules. There is an option in spack to not set CPATH or to set C_INCLUDE_PATH and CPLUS_INCLUDE_PATH instead of CPATH. the latter two variables are treated as -isystem unlike CPATH. (https://spack.readthedocs.io/en/latest/module_file_support.html#)

dabele avatar Nov 29 '23 11:11 dabele

Disabling the compiler warnings seems not enough, it still results in the error.

charlie0614 avatar Mar 19 '24 13:03 charlie0614