abcorrea / powerlifted

Powerlifted Planner
GNU General Public License v3.0
28 stars 12 forks source link

Boost related build failure and outdated singularity file #53

Closed ryanxwang closed 3 months ago

ryanxwang commented 3 months ago

Hey Augusto,

I can't seem to build powerlifted with (python3 build.py) due to the following warning and then error:

-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0

...

CMake Warning at /apps/boost/1.72.0/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant-shared.cmake:64 (message):
  Target Boost::program_options already has an imported location
  '/apps/boost/1.72.0/lib/libboost_program_options-mt-x64.so.1.72.0', which
  will be overwritten with
  '/apps/boost/1.72.0/lib/libboost_program_options.so.1.72.0'
Call Stack (most recent call first):
  /apps/boost/1.72.0/lib/cmake/boost_program_options-1.72.0/boost_program_options-config.cmake:57 (include)
  /apps/boost/1.72.0/lib/cmake/Boost-1.72.0/BoostConfig.cmake:120 (find_package)
  /apps/boost/1.72.0/lib/cmake/Boost-1.72.0/BoostConfig.cmake:185 (boost_find_component)
  /half-root/usr/share/cmake/Modules/FindBoost.cmake:594 (find_package)
  CMakeLists.txt:11 (find_package)

...

[ 96%] Building CXX object CMakeFiles/search.dir/heuristics/utils.cc.o
make[2]: *** No rule to make target '/apps/boost/1.72.0/lib/libboost_program_options.so.1.72.0', needed by 'search'.  Stop.
make[2]: *** Waiting for unfinished jobs....
[ 98%] Building CXX object CMakeFiles/search.dir/heuristics/hmax_heuristic.cc.o
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/search.dir/all] Error 2

It seems that cmake detects boost fine, but has some trouble due to the co-existing multithreaded (mt) and single threaded version of boost program options. I've read this discussion on a similar issue but following their advice doesn't change anything.

Unfortunately I don't have much control over this environment. I can only choose from a set of boost versions. Using higher versions than 1.72.0 leads to the initial warning becoming an error, and using a lower version leads to cmake not finding program options. Do you have any idea what I might be able to do here?

Alternatively, I've also tried to build the singularity image, but it seems outdated and I was unable to build the image using singularity version 3.11.3. image

Really appreciate your help!

PLauerRocks commented 3 months ago

Hi, Augusto pinged me since I had to go through some painful Boost dependency troubleshooting already. Maybe we can figure out a solution together. Let me start with two follow-up questions:

(1) The post also suggest that simply enabling set(Boost_NO_BOOST_CMAKE ON) before find_package resolves the problem with your current version (as the problem is caused in BoostConfig.cmake), did you try that?

(2) When you were trying a newer Boost version (above 1.72) did you set set(Boost_USE_MULTITHREADED OFF) before you call find_package for Boost? According to a Stack Overflow post, this is the key step. If this flag wasn't set, to the right value this could explain why it became an error. ( This is a problem in the specific boost version, which is documented in the second to last reply here: https://gitlab.kitware.com/cmake/cmake/-/issues/19714 )

abcorrea commented 3 months ago

Hi all,

I will have a look at that, but I haven't reproduced the boost problem yet.

In the meantime, @ryanxwang, I pushed a new version of the container scripts. Now it uses Apptainer, instead of Singularity. You can run

 apptainer build powerlifted.sif Apptainer.powerlifted

and then use powerlifted.sif as a replacement for powerlifted.py. There are some caveats though: you need to call VAL or/and CPDDL outside of the image, in case you need them. (In other words, flags --validate- and --preprocess-task no longer work with this.)

This should be a short-term solution to make the planner usable for now. Could you try again and let me know if it worked?

I will continue trying to solve the boost compilation issue.

@PLauerRocks: thank you for the help and the pointers!

Cheers, ABC

abcorrea commented 3 months ago

Also, can you check if the pull request #52 helps with your problem, @ryanxwang?

ryanxwang commented 3 months ago

Thanks @PLauerRocks and @abcorrea!

@PLauerRocks: re the set(Boost_NO_BOOST_CMAKE ON) option, setting it for all the boost versions I tried (1.71.0, 1.72.0, 1.77.0) results in the following error

CMake Error at /half-root/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: program_options) (found version "1.72.0")

I've also tried setting Boost_USE_MULTITHREADED to OFF for various versions. They all resulted in some variation of messages saying "cannot find boost". The PR also didn't work.

However, I've been able to build powerlifted now by including it using CPM, based on this example. It takes a while as it needs to build boost, but things work now.

The precise set of changes I've made in CMakeLists.txt is removing the existing lines for linking boost, and replacing the target_link_libraries line in the end with

include(../cmake/CPM.cmake)

CPMAddPackage(
  NAME Boost
  VERSION 1.84.0
  GITHUB_REPOSITORY boostorg/boost
  GIT_TAG "boost-1.84.0"
  OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES program_options\\\;algorithm\\\;dynamic_bitset"
)

target_link_libraries(search LINK_PUBLIC Boost::program_options Boost::algorithm Boost::dynamic_bitset)

I will also test out the updated apptainer solution soon.