SpectrumIM / spectrum2

Spectrum 2 IM transports
https://spectrum.im
409 stars 91 forks source link

Compiling fails with boost >= 1.73 #368

Closed ConiKost closed 4 years ago

ConiKost commented 4 years ago

Compilation with newest boost will fail. This seems to be related to the newest bind changes.

FAILED: libtransport/CMakeFiles/transport.dir/ThreadPool.cpp.o 
/usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DBOOST_FILESYSTEM_VERSION=3 -DIRC_SHARED -DPURPLE_RUNTIME=0 -DSPECTRUM_VERSION=\"2.0.10\" -DSUPPORT_LEGACY_CAPS -DWITH_LIBEVENT -DWITH_LOG4CXX -DWITH_PROTOBUF -DWITH_SQLITE -Dtransport_EXPORTS -I/usr/include/jsoncpp -I/usr/include/libpurple -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/qt5/Communi/IrcCore -I/usr/include/qt5/Communi/IrcUtil -I/usr/include/qt5/Communi/IrcModel -I/var/tmp/portage/net-im/spectrum2-2.0.12-r2/work/spectrum2-2.0.12/include -I/var/tmp/portage/net-im/spectrum2-2.0.12-r2/work/spectrum2-2.0.12/libtransport/../spectrum/src/frontends/xmpp  -DNDEBUG -std=c++11 -march=native -mfpmath=sse,387 -mtune=intel -O3 -frecord-gcc-switches -fomit-frame-pointer -malign-data=abi -mtls-dialect=gnu2 -pipe -fvisibility-inlines-hidden -fPIC   -fPIC -MD -MT libtransport/CMakeFiles/transport.dir/ThreadPool.cpp.o -MF libtransport/CMakeFiles/transport.dir/ThreadPool.cpp.o.d -o libtransport/CMakeFiles/transport.dir/ThreadPool.cpp.o -c /var/tmp/portage/net-im/spectrum2-2.0.12-r2/work/spectrum2-2.0.12/libtransport/ThreadPool.cpp
/var/tmp/portage/net-im/spectrum2-2.0.12-r2/work/spectrum2-2.0.12/libtransport/ThreadPool.cpp: In member function ‘void Transport::ThreadPool::scheduleFromQueue()’:
/var/tmp/portage/net-im/spectrum2-2.0.12-r2/work/spectrum2-2.0.12/libtransport/ThreadPool.cpp:99:76: error: ‘_1’ was not declared in this scope
   99 |   worker[w] = new boost::thread(boost::bind(&ThreadPool::workerBody, this, _1, _2), t, w, loop);

I started with some updates, but this is leading to other compiling errors, so I have currently no clue, how to solve that. Current progress: https://github.com/ConiKost/spectrum2/commit/d8e4ae395b521b719ea8259ecabafe1219f41bce

vitalyster commented 4 years ago

Did you successfully build libswiften with that compiler/boost version?

ConiKost commented 4 years ago

Yes, compilation of libswiften works here with boost-1.73.

vitalyster commented 4 years ago

Can you show spectrum configuration log with swiften/boost version detection?

ConiKost commented 4 years ago

That?

cmake -C /var/tmp/portage/net-im/spectrum2-2.0.12-r2/work/spectrum2-2.0.12_build/gentoo_common_config.cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_DOCS=yes -DENABLE_FROTZ=yes -DENABLE_IRC=yes -DENABLE_MYSQL=yes -DENABLE_PQXX=yes -DENABLE_PURPLE=yes -DENABLE_QT4=OFF -DENABLE_SMSTOOLS3=yes -DENABLE_SQLITE3=yes -DENABLE_TESTS=no -DENABLE_TWITTER=yes -DENABLE_XMPP=yes -DLIB_INSTALL_DIR=lib64 -DCMAKE_BUILD_TYPE=Gentoo -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/net-im/spectrum2-2.0.12-r2/work/spectrum2-2.0.12_build/gentoo_toolchain.cmake  /var/tmp/portage/net-im/spectrum2-2.0.12-r2/work/spectrum2-2.0.12
loading initial cache file /var/tmp/portage/net-im/spectrum2-2.0.12-r2/work/spectrum2-2.0.12_build/gentoo_common_config.cmake
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/lib/ccache/bin/x86_64-pc-linux-gnu-gcc
-- Check for working C compiler: /usr/lib/ccache/bin/x86_64-pc-linux-gnu-gcc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++
-- Check for working CXX compiler: /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:6 (cmake_policy):
  The OLD behavior for policy CMP0037 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

-- Variables to override default places where to find libraries:
-- |- cppunit : -DCPPUNIT_INCLUDE_DIR,  -DCPPUNIT_LIBRARY
-- |- swiften : -DSWIFTEN_INCLUDE_DIR,  -DSWIFTEN_LIBRARY
--   |- zlib  :                         -DZLIB_LIBRARY
--   |- expat :                         -DEXPAT_LIBRARY
--   |-libidn :                         -DLIBIDN_LIBRARY
--   |-libxml :                         -DLIBXML_LIBRARY
-- |- boost   : -DBOOST_INCLUDEDIR,     -DBOOST_LIBRARYDIR
-- |- protobuf: -DPROTOBUF_INCLUDE_DIR, -DPROTOBUF_LIBRARY
--            : -DPROTOBUF_PROTOC_EXECUTABLE
-- |- log4cxx : -DLOG4CXX_INCLUDE_DIR,  -DLOG4CXX_LIBRARY
-- |- purple  : -DPURPLE_INCLUDE_DIR,   -DPURPLE_LIBRARY
--            : -DPURPLE_NOT_RUNTIME - enables compilation with libpurple.lib
-- Found Swiften > 4 requesting C++11
-- Found libSwiften: -L/usr/bin/../lib;-lSwiften;-lboost_system;-lboost_thread;-lboost_regex;-lboost_program_options;-lboost_filesystem;-lboost_serialization;-lboost_date_time;-licuuc;-lz;-lssl;-lcrypto;-lxml2;-lminiupnpc;-lnatpmp;-lresolv;-lpthread;-ldl;-lm;-lc;-lstdc++, /usr/include
-- Found Boost: /usr/lib64/libboost_program_options-mt.so;/usr/lib64/libboost_date_time-mt.so;/usr/lib64/libboost_system-mt.so;/usr/lib64/libboost_filesystem-mt.so;/usr/lib64/libboost_regex-mt.so;/usr/lib64/libboost_thread-mt.so;/usr/lib64/libboost_locale-mt.so, /usr/include
-- Found Boost: 107300, /usr/lib64/libboost_program_options-mt.so;/usr/lib64/libboost_date_time-mt.so;/usr/lib64/libboost_system-mt.so;/usr/lib64/libboost_filesystem-mt.so;/usr/lib64/libboost_regex-mt.so;/usr/lib64/libboost_thread-mt.so;/usr/lib64/libboost_locale-mt.so, /usr/include
-- Using BOOST_FILESYSTEM_VERSION=3
-- Found popt: /usr/lib64/libpopt.so, /usr/include
-- Found Sqlite3 header file in /usr/include
-- Found Sqlite3 libraries: optimized;/usr/lib64/libsqlite3.so;debug;/usr/lib64/libsqlite3.so
-- Found MySQL: /usr/lib64/libmysqlclient.so, /usr/include/mysql
-- Found pqxx: /usr/lib64/libpqxx.so, /usr/lib64/libpq.so, /usr/include
-- Found libpurple: /usr/lib64/libpurple.so, /usr/include/libpurple
-- Found Event: /usr/lib64/libev.so /usr/include
-- Found PkgConfig: x86_64-pc-linux-gnu-pkg-config (found version "0.29.2") 
-- Checking for module 'glib-2.0'
--   Found glib-2.0, version 2.64.2
CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
  The package name passed to `find_package_handle_standard_args` (GLIB2) does
  not match the name of the calling package (glib).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake_modules/Findglib.cmake:53 (find_package_handle_standard_args)
  CMakeLists.txt:155 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found GLIB2: /usr/lib64/libglib-2.0.so;/usr/lib64/libgthread-2.0.so;/usr/lib64/libgmodule-2.0.so;/usr/lib64/libgobject-2.0.so  
CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
  The package name passed to `find_package_handle_standard_args` (PROTOBUF)
  does not match the name of the calling package (Protobuf).  This can lead
  to problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake_modules/FindProtobuf.cmake:145 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:163 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PROTOBUF: /usr/lib64/libprotobuf.so  
CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
  The package name passed to `find_package_handle_standard_args` (JsonCpp)
  does not match the name of the calling package (jsoncpp).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake_modules/Findjsoncpp.cmake:354 (find_package_handle_standard_args)
  CMakeLists.txt:175 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found JsonCpp: /usr/include/jsoncpp  
-- Found jsoncpp: /usr/include/jsoncpp /usr/lib64/libjsoncpp.so, shared: 
-- Checking for module 'openssl'
--   Found openssl, version 1.1.1g
-- Found OpenSSL: /usr/include, /usr/lib64/libssl.so/usr/lib64/libcrypto.so
-- Found libCommuni /usr/lib64/libIrcCore.so;/usr/lib64/libIrcModel.so, /usr/include/qt5/Communi/IrcCore;/usr/include/qt5/Communi/IrcUtil;/usr/include/qt5/Communi/IrcModel
-- Found Event: /usr/lib64/libev.so /usr/include
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.17") found components: doxygen dot 
-- Found log4cxx: /usr/lib64/liblog4cxx.so, /usr/include/usr/include
  Supported features
-----------------------
Version           : 2.0.10
SQLite3           : yes
MySQL             : yes
PostgreSQL        : yes
Network plugins   : yes
Libpurple plugin  : yes
  libev eventloop : yes
IRC plugin        : yes
Twitter plugin    : yes
Frotz plugin      : yes
SMSTools3 plugin  : yes
Swiften plugin    : yes
Log4cxx           : yes
Debug             : no (run "cmake . -DCMAKE_BUILD_TYPE=Debug")
-- Found CURL: /usr/lib64/libcurl.so (found version "7.70.0")  
-- Using curl 7.70.0: /usr/include /usr/lib64/libcurl.so
Tests             : no (user disabled)
Documentation     : yes
----------------------
-- <<< Gentoo configuration >>>
Build type      Gentoo
Install path    /usr
Compiler flags:
C               -march=native -mfpmath=sse,387 -mtune=intel -O3 -frecord-gcc-switches -fomit-frame-pointer -malign-data=abi -mtls-dialect=gnu2 -pipe
C++             -std=c++11 -march=native -mfpmath=sse,387 -mtune=intel -O3 -frecord-gcc-switches -fomit-frame-pointer -malign-data=abi -mtls-dialect=gnu2 -pipe -fvisibility-inlines-hidden
Linker flags:
Executable      -Wl,--as-needed -Wl,-O1 -Wl,--sort-common -Wl,-z,now
Module          -Wl,--as-needed -Wl,-O1 -Wl,--sort-common -Wl,-z,now
Shared          -Wl,--as-needed -Wl,-O1 -Wl,--sort-common -Wl,-z,now
ConiKost commented 4 years ago

config.log from swiften: https://pastebin.com/3B0akPCL

scons -j9 ar=x86_64-pc-linux-gnu-ar allow_warnings=yes assertions=no build_examples=yes boost_bundled_enable=false boost_force_bundled=false cc=x86_64-pc-linux-gnu-gcc ccache=no ccflags=-march=native -mfpmath=sse,387 -mtune=intel -O3 -frecord-gcc-switches -fomit-frame-pointer -malign-data=abi -mtls-dialect=gnu2 -pipe coverage=no cxx=x86_64-pc-linux-gnu-g++ cxxflags=-march=native -mfpmath=sse,387 -mtune=intel -O3 -frecord-gcc-switches -fomit-frame-pointer -malign-data=abi -mtls-dialect=gnu2 -pipe -fvisibility-inlines-hidden debug=no distcc=no experimental=no experimental_ft=yes hunspell_enable=no icu=yes install_git_hooks=no libidn_bundled_enable=false libminiupnpc_force_bundled=false libnatpmp_force_bundled=false link=x86_64-pc-linux-gnu-g++ linkflags=-Wl,--as-needed -Wl,-O1 -Wl,--sort-common -Wl,-z,now max_jobs=no optimize=no qt=/var/tmp/portage/net-im/swift-4.0.2-r1/temp/qt qt5=no swiften_dll=true swift_mobile=no target=native test=none try_avahi=no try_expat=no try_gconf=no try_libidn=yes try_libxml=yes tls_backend=openssl unbound=no V=1 valgrind=no zlib_bundled_enable=false Swiften Sluift Limber
scons: Reading SConscript files ...
Checking whether the C++ compiler works... yes
Checking whether the C compiler works... yes
Checking whether the C++ compiler supports C++11... yes
Checking for C library z... yes
Checking for C library resolv... yes
Checking for C library pthread... yes
Checking for C library dl... yes
Checking for C library m... yes
Checking for C library c... yes
Checking for C++ library stdc++... yes
Checking for C++ header file boost/signals2.hpp... yes
Checking for C++ header file boost/system/system_error.hpp... yes
Checking for C++ library boost_system... yes
Checking for C++ header file boost/thread.hpp... yes
Checking for C++ library boost_thread... yes
Checking for C++ header file boost/regex.hpp... yes
Checking for C++ library boost_regex... yes
Checking for C++ header file boost/program_options.hpp... yes
Checking for C++ library boost_program_options... yes
Checking for C++ header file boost/filesystem.hpp... yes
Checking for C++ library boost_filesystem... yes
Checking for C++ header file boost/archive/text_oarchive.hpp... yes
Checking for C++ library boost_serialization... yes
Checking for C++ header file boost/date_time/date.hpp... yes
Checking for C++ library boost_date_time... yes
Checking for C++ header file boost/uuid/uuid.hpp... yes
Checking for C function XScreenSaverQueryExtension()... yes
Checking for C header file libxml/parser.h... no
Checking for C header file libxml/parser.h... yes
Checking for C library xml2... yes
Checking for C header file unicode/usprep.h... yes
Checking for C header file miniupnpc.h... yes
Checking for C library miniupnpc... yes
Checking for C header file natpmp.h... yes
Checking for C library natpmp... yes
Checking for C++ library lua... yes
Checking for C library edit... no
Checking for C header file openssl/ssl.h... yes

  Build Configuration
  -------------------
  Projects: Swiften Limber Sluift

  XML Parsers: LibXML
  TLS Support: OpenSSL
  DNSSD Support: Disabled

scons: done reading SConscript files.
vitalyster commented 4 years ago

Build type Gentoo

I saw issue with that "build type" before, can you try to use exactly "Debug", "Release" or "RelWithDebInfo" build types? There was something missing in Gentoo configuration last time it was reported

vitalyster commented 4 years ago

See https://github.com/SpectrumIM/spectrum2/issues/300

ConiKost commented 4 years ago

As you wish, I've run now a test and set that to "Release". Same error persists. Output is basically the same. I am pretty sure, this one not related to that ;-) Btw, I am the maintainer of that package in Gentoo :-P

Build type      Release
Install path    /usr
vitalyster commented 4 years ago

OK, now I see the problem. Boost 1.73 moved placeholders to boost::placeholders namespace. In default configuration in show warning:

BOOST_PRAGMA_MESSAGE(
  "The practice of declaring the Bind placeholders (_1, _2, ...) "
  "in the global namespace is deprecated. Please use "
  "<boost/bind/bind.hpp> + using namespace boost::placeholders, "
  "or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior."
)

So it looks like you have -DBOOST_BIND_NO_PLACEHOLDERS defined somewhere and that it why you did not receive such message. About your changes - correct changes should still use boost placeholders and not standard ones to be backward compatible with previous versions. And it should still compile without changes with BOOST_BIND_GLOBAL_PLACEHOLDERS

ConiKost commented 4 years ago

Since I am getting this warning too (and not only one, but a lot of), I would assume, this is the default behavior in 1.73, since I did not set -DBOOST_BIND_NO_PLACEHOLDERS.

vitalyster commented 4 years ago

If you get this warning then it should be compiled because right after this warning boost placeholders are imported in global namespace, so your first error output looks incorrect and maybe done after some changes

ConiKost commented 4 years ago

I am not sure here, since other projects have such errors messages about compilation also with boost-1.73: For example here: https://github.com/PowerDNS/pdns/pull/9070/files

I can clearly say, if I downgrade to boost-1.72, compilation just works, with boost-1.73, it will fail. I will give a run for a complete build.log and report back.

vitalyster commented 4 years ago

Yes, let me check full build log, maybe the problem in different issue

ConiKost commented 4 years ago

Hi! Here are my full logs.

1) Boost-1.72 and compiled with "emerge": https://pastebin.com/TyFYFkVX 2) Boost-1.72 and manually compiled (without "emerge"): https://pastebin.com/6hjqtBsM

As you can see, everything is fine and correct with Boost-1.72.

1) Boost-1.73 and compiled with "emerge": https://pastebin.com/CN8C00QG 2) Boost-1.73 and manually compiled (without "emerge"): https://pastebin.com/xTuWRUmB

Both cases fail with the same error and it's the one I mentioned in my first post.

vitalyster commented 4 years ago

This is solved by including boost/bind.hpp into ThreadPool.h and other files which does not include it explicitly

ConiKost commented 4 years ago

Yep, you are right. After including, compiling works with boost-1.73. Thanks!

vitalyster commented 4 years ago

Fixed in db9e50f6ea36cdf4a1b480b300047ed07089b247