mpicbg-scicomp / gearshifft

Benchmark Suite for Heterogenuous FFT Implementations
Apache License 2.0
34 stars 9 forks source link

Fixed static boost linkage #131

Closed emmenlau closed 5 years ago

emmenlau commented 5 years ago

The include of boost/test/included/unit_test.hpp fixes undefined symbol errors when linking boost_test statically. See http://boost.2283326.n4.nabble.com/Undefined-reference-to-main-with-Boost-Test-Why-td2576147.html for an original source.

emmenlau commented 5 years ago

So here is what I tried on Ubuntu Linux 18.04.2 with gcc-7.3:

  1. Current HEAD revision with no changes linked against static boost 1.68.0 produces errors:

    test/CMakeFiles/test_fftw.dir/test_fftw.cpp.o: In function `main'
    /data/Debug/include/boost/test/unit_test.hpp:63: undefined reference to `boost::unit_test::unit_test_main(bool (*)(), int, char**)
    [...] more such errors follow
  2. Changing the logic in CMakeLists.txt to not use BOOST_TEST_DYN_LINK in static linking: $<$<NOT:$>BOOL:Boost_USE_STATIC_LIBS>>:BOOST_TEST_DYN_LINK> produces errors:

    gearshifft/CMakeFiles/gearshifft_fftwwrappers.dir/benchmark.cpp.o: In function `int gearshifft::Benchmark<gearshifft::fftw::FftwContext>::run<std::integral_constant<bool, false>, boost::mpl::list<gearshifft::FFT<gearshifft::FFT_Inplace_Real, std::integral_constant<bool, false>, gearshifft::fftw::FftwImpl, gearshifft::Timer<gearshifft::TimerCPU_>>, gearshifft::FFT<gearshifft::FFT_Inplace_Complex, std::integral_constant<bool, false>, gearshifft::fftw::FftwImpl, gearshifft::Timer<gearshifft::TimerCPU_>>, gearshifft::FFT<gearshifft::FFT_Outplace_Real, std::integral_constant<bool, false>, gearshifft::fftw::FftwImpl, gearshifft::Timer<gearshifft::TimerCPU_>>, gearshifft::FFT<gearshifft::FFT_Outplace_Complex, std::integral_constant<bool, false>, gearshifft::fftw::FftwImpl, gearshifft::Timer<gearshifft::TimerCPU_>>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::list<float, double, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >()'
    /data/Source/GIT-gearshifft/inc/core/benchmark.hpp:63: undefined reference to `boost::unit_test::unit_test_main(bool (*)(), int, char**)'
  3. Same as 2. but removing the define BOOST_TEST_NO_MAIN from benchmark.hpp produces error:

    /data/Source/GIT-gearshifft/src/benchmark.cpp: In function ‘int main(int, char**)’
    /data/Source/GIT-gearshifft/src/benchmark.cpp:59:5: error: redefinition of ‘int main(int, char**)’
    /data/Debug/include/boost/test/impl/unit_test_main.ipp:290:1: note: ‘int main(int, char**)’ previously defined here
  4. Same as 2. but adding boost header boost/test/included/unit_test.hpp to benchmark.hpp works without errors

Therefore its my understanding that for static linking, the flag BOOST_TEST_DYN_LINK should be disabled?

tdd11235813 commented 5 years ago

thanks a lot for providing the different cases! The travis tests fail, so something still needs to be fixed, but I can't look at it more in depth until the end of the week. IIRC, I only checked the boost test header, how to enable the missing main function and the BOOST_TEST_DYN_LINK actually did it for the tests, as the benchmark.hpp is not included there. But it is not a real solution, just because of the weird logic. Sorry for not putting a comment on that line. It needs a better solution than that, especially when that workaround is not working. Hope, you can work on locally with your fix? I am happy that you test gearshifft. After the cmake refactoring a lot of things have changed, so this thing is still quite bleeding-edge ;)

tdd11235813 commented 5 years ago

@emmenlau , please test PR #133 and report there, if it is working for you now:

git checkout -b tdd11235813-boost168 master
git pull https://github.com/tdd11235813/gearshifft.git boost168
emmenlau commented 5 years ago

Dear @tdd11235813 , great work, I can confirm that PR #133 works for me! I get pretty good mileage on Ubuntu 16.04 x86_64 and i686, Ubuntu 18.04 x86_64 and macOS X 10.12. Thanks! Closing this PR as outdated.