python-libtorrent 1.0.10 in qbittorrent ppa is broken #6383

Closed
cas-- opened this Issue Feb 14, 2017 · 15 comments

Projects

None yet

3 participants

@cas--
cas-- commented Feb 14, 2017

This is not an issue for qbittorrent but the build that is currently in your stable ppa contains a broken python-libtorrent and deluge users who also have your ppa added are being updated to your libtorrent 1.0.10 and then encountering the following error:

ImportError: /usr/lib/python2.7/dist-packages/libtorrent.so: undefined symbol: _ZN5boost4asio2ip10address_v4C1ERKNS_5arrayIhLm4EEE 

I did notice a mention of Use C++11 mode in build changelog.

References:
http://forum.deluge-torrent.org/viewtopic.php?f=7&t=54378
http://dev.deluge-torrent.org/ticket/2950
arvidn/libtorrent#1466

@sledgehammer999
Contributor

Thank you for reporting to us.

Let me explain in a few words what I did with the package, in case you can help me. I can't understand why you get that error.

For my pacakge, IIRC, I took debian's scripts for 1.0.9 and used them for 1.0.10. I also enabled c++11 in the compiler so libtorrent is compiled using that. Otherwise, linking qbt (which uses c++11 already) against a non-c++11 build of libtorrent doesn't work.

So in the debian\rules I just put "CXXFLAGS=-std=c++11" at the end of the CONFIGURE_ARGS.
For you convenience here are the contents of debian\rules

#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

export DEB_LDFLAGS_MAINT_APPEND  = -Wl,--as-needed

PYTHON2=$(shell pyversions -vr)
PYTHON3=$(shell py3versions -vr)
ALLPY=$(PYTHON2) $(PYTHON3) $(PYTHON2:%=%-dbg) $(PYTHON3:%=%-dbg)

CONFIGURE_ARGS = --with-libgeoip --with-libiconv --with-boost-system=boost_system CXXFLAGS=-std=c++11

%:
	dh $@ --parallel --with python2,python3

override_dh_auto_configure-nopy:
	dh_auto_configure --builddirectory build -- $(CONFIGURE_ARGS)

override_dh_auto_configure-%:
	CPPFLAGS="$(CPPFLAGS) $(shell python$*-config --includes)" \
	PYTHON_LDFLAGS="$(shell python$*-config --libs)" \
	dh_auto_configure --builddirectory build-py$* -- \
		PYTHON=/usr/bin/python$* PYTHON_INSTALL_PARAMS="--root=$(CURDIR)/debian/tmp --install-layout=deb" \
		--enable-python-binding --with-boost-python=boost_python-py$(subst .,,$(subst -dbg,,$*)) \
		$(CONFIGURE_ARGS)
	mv build-py$*/bindings/python build/bindings/python$*
	cp -r bindings/python/* build/bindings/python$*

override_dh_auto_configure: override_dh_auto_configure-nopy $(ALLPY:%=override_dh_auto_configure-%)


override_dh_auto_build-nopy:
	dh_auto_build --builddirectory build
	$(MAKE) -C docs/ -f makefile

override_dh_auto_build-%:
	dh_auto_build --builddirectory build/bindings/python$*

override_dh_auto_build: override_dh_auto_build-nopy $(ALLPY:%=override_dh_auto_build-%)


override_dh_auto_install-nopy:
	dh_auto_install --builddirectory build

override_dh_auto_install-%:
	dh_auto_install --builddirectory build/bindings/python$*

override_dh_auto_install: override_dh_auto_install-nopy $(ALLPY:%=override_dh_auto_install-%)


override_dh_auto_clean:
	rm -rf build build-py*
	dh_auto_clean

override_dh_compress:
	dh_compress -Xcpp

override_dh_strip:
	dh_strip --dbg-package=libtorrent-rasterbar-dbg

override_dh_makeshlibs:
	dh_makeshlibs -V

override_dh_builddeb:
	dh_builddeb -- -Z xz
@evsh
Contributor
evsh commented Feb 14, 2017

My two cents: I pass -std=c++11 via environment variable CXXFLAGS (but not via configure parameter) and python bindings work fine. And

$ nm -D /usr/lib64/python3.5/site-packages/libtorrent.cpython-35m-x86_64-linux-gnu.so | grep _ZN5boost4asio2ip10address_ | c++filt 
                 U boost::asio::ip::address_v4::address_v4(std::array<unsigned char, 4ul> const&)
                 U boost::asio::ip::address_v6::address_v6(std::array<unsigned char, 16ul> const&, unsigned long)

Notice std::array, i.e. C++11 mode.

@cas--
cas-- commented Feb 14, 2017 edited

I imagine it's isolated to Ubuntu Trusty since those are the users that are reporting the issue.

Actually it's worse on Xenial, just an insta-crash...

Just to note that this is with Python 2 and I have updated our PPA to 1.0.11 in the meantime.

@sledgehammer999
Contributor
sledgehammer999 commented Feb 20, 2017 edited

I haven't tested my theory yet, but I think if I put -std=c++11 inside bindings/python/compile_flags.in it should fix the problem.
I think the bindings weren't being built in c++11 mode.

@cas--
cas-- commented Feb 21, 2017

That sounds likely as there were a few issues in master with passing compile flags. The alternative is to perhaps not provide the python-bindings?

@sledgehammer999
Contributor
sledgehammer999 commented Feb 21, 2017 edited

The alternative is to perhaps not provide the python-bindings?

Then I think that means I should put a "Conflicts" field in the deb for the bindings. And that conflicts will probably forbid users installing Deluge.

I'll do some tests today. I hope the crash happens as soon as I open Deluge and not needing anything else.

@sledgehammer999
Contributor

Then I think that means I should put a "Conflicts" field in the deb for the bindings. And that conflicts will probably forbid users installing Deluge.

I mean this: The libtorrent package will Conflict with the python bindings in such a case.

@cas--
cas-- commented Feb 21, 2017 edited

You don't even need to install Deluge, this should suffice:

python -c 'import libtorrent as lt; print(lt.__version__)' 

Yeah I'm not sure about setting conflicts in deb packages, I have never had much success in the past ;)

@sledgehammer999
Contributor

I can't verify the crash on a Debian Sid VM. So I'll install a xenial VM to test.

@evsh
Contributor
evsh commented Feb 21, 2017

I haven't tested my theory yet, but I think if I put -std=c++11 inside bindings/python/compile_flags.in it should fix the problem.

Isn't it simpler to keep them in the environment variable? For instance:

export DEB_LDFLAGS_MAINT_APPEND  = -Wl,--as-needed
export CXXFLAGS=-std=c++11
@sledgehammer999
Contributor

I don't know how to do that in the deb package nor I am sure that it will work for the bindings.

@evsh
Contributor
evsh commented Feb 21, 2017 edited

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed is a line from the makefile you've posted earlier.

Update:

nor I am sure that it will work for the bindings.

  1. bindings/python/compile_flags.in you refer to contains @CXXFLAGS@
  2. I do compile libtorrent like that and can assure you that the bindings are compiled correctly and work.
@sledgehammer999
Contributor

I can confirm the crash on xenial. Next step, to rebuilt it locally with the flag in compile_flags.in and test @evsh way too.

@sledgehammer999
Contributor

bindings/python/compile_flags.in you refer to contains @CXXFLAGS@

No it doesn't contain it. It exists only in libtorrent-master.

On another note, it still crashes after I put -std=c++11 in bindings/python/compile_flags.in directly. I don't know what is happening here.

@sledgehammer999
Contributor

Finally I found a solution. It seems that I need the following change in bindings/python/setup.py.
Change + target_specific(), to + target_specific() + ['-std=c++11'],.
This is for RC_1_0. RC_1_1 and master probably have a different setup.py/compile_flags.in setup.

I'll post new debs with v3.3.11 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment