Bug 239605

Summary: net-p2p/rtorrent: Build fails: undefined reference to inotify_add_watch/inotify_init
Product: Ports & Packages Reporter: Paul Boehmer <freebsd>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed Feedback Timeout    
Severity: Affects Only Me CC: linimon, sergey, w.schwarzenfeld
Priority: --- Keywords: needs-patch
Version: LatestFlags: dbaio: maintainer-feedback+
Hardware: amd64   
OS: Any   
URL: https://github.com/rakshasa/libtorrent/issues/199
Bug Depends on:    
Bug Blocks: 281479    
Attachments:
Description Flags
screenlog_before
none
screenlog_after
none
screenlog_before
none
screenlog_after none

Description Paul Boehmer 2019-08-02 16:04:59 UTC
Not sure if issue is libtorrent or rtorrent, but since libtorrent builds and rtorrent does not, I am submitting the bug here.  I have a fresh ports tree on 11.3-RELEASE-p1.  Have rebuilt libtorrent (0.13.8), curl (7.65.3), xmlrpc-c (1.51.03_1) ports and get the following build error that is repeatable on multiple boxes:

#################TRIMMED#################

--- rtorrent ---
/bin/sh ../libtool  --tag=CXX    --mode=link c++   -O2 -pipe -fstack-protector-strong -fno-strict-aliasing   -DNDEBUG -Wall -I/usr/local/include  -D_THREAD_SAFE    -I/usr/local/include  -I/usr/local/include  -lexecinfo -pthread -fstack-protector-strong -o rtorrent main.o libsub_root.a  ui/libsub_ui.a  core/libsub_core.a  display/libsub_display.a  input/libsub_input.a  rpc/libsub_rpc.a  utils/libsub_utils.a -lncursesw    -L/usr/local/lib -lcurl  -L/usr/local/lib -ltorrent   -L/usr/local/lib  -Wl,-rpath,/usr/local/lib  -lxmlrpc_server -lxmlrpc  -lxmlrpc_xmlparse -lxmlrpc_xmltok -lxmlrpc_util -lpthread
libtool: link: c++ -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -DNDEBUG -Wall -I/usr/local/include -D_THREAD_SAFE -I/usr/local/include -I/usr/local/include -pthread -fstack-protector-strong -o rtorrent main.o -Wl,-rpath -Wl,/usr/local/lib  -lexecinfo libsub_root.a ui/libsub_ui.a core/libsub_core.a display/libsub_display.a input/libsub_input.a rpc/libsub_rpc.a utils/libsub_utils.a -lncursesw -L/usr/local/lib -lcurl -ltorrent -lxmlrpc_server -lxmlrpc -lxmlrpc_xmlparse -lxmlrpc_xmltok -lxmlrpc_util -lpthread -pthread
/usr/local/lib/libtorrent.so: undefined reference to `inotify_add_watch'
/usr/local/lib/libtorrent.so: undefined reference to `inotify_init'
c++: error: linker command failed with exit code 1 (use -v to see invocation)
*** [rtorrent] Error code 1

make[5]: stopped in /usr/ports/net-p2p/rtorrent/work/rtorrent-0.9.8/src
1 error

make[5]: stopped in /usr/ports/net-p2p/rtorrent/work/rtorrent-0.9.8/src
*** [all-recursive] Error code 1

make[4]: stopped in /usr/ports/net-p2p/rtorrent/work/rtorrent-0.9.8/src
1 error

make[4]: stopped in /usr/ports/net-p2p/rtorrent/work/rtorrent-0.9.8/src
*** [all-recursive] Error code 1

make[3]: stopped in /usr/ports/net-p2p/rtorrent/work/rtorrent-0.9.8
1 error

make[3]: stopped in /usr/ports/net-p2p/rtorrent/work/rtorrent-0.9.8
*** [all] Error code 2

make[2]: stopped in /usr/ports/net-p2p/rtorrent/work/rtorrent-0.9.8
1 error

make[2]: stopped in /usr/ports/net-p2p/rtorrent/work/rtorrent-0.9.8
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/net-p2p/rtorrent
*** Error code 1

Stop.
make: stopped in /usr/ports/net-p2p/rtorrent
Comment 1 Danilo G. Baio freebsd_committer freebsd_triage 2019-08-03 18:16:19 UTC
Thanks for the report.

Are you using the default options?
Could you share the full build log of libtorrent and rtorrent?

I couldn't reproduce this issue with poudriere on:
 - 11.3 (i386|amd64)
 - 12.0-RELEASE (i386|amd64)
 - 13.0-CURRENT 1300036 (i386|amd64)

I'm interested in finding what is happening.

Regards.
Comment 2 Walter Schwarzenfeld 2019-08-03 18:53:11 UTC
Same error here (11.2-amd64).
Comment 3 Walter Schwarzenfeld 2019-08-03 19:01:31 UTC
I tried on the commandline with  make CXXFLAGS+=-linotify, and this works.
Comment 4 Walter Schwarzenfeld 2019-08-03 19:07:51 UTC
I changed

USES=           compiler:c++11-lang ncurses pkgconfig localbase
and
LDFLAGS+=       -lexecinfo -pthread -linotify
Comment 5 Danilo G. Baio freebsd_committer freebsd_triage 2019-08-03 19:12:24 UTC
(In reply to w.schwarzenfeld from comment #3)

Could you share the build logs from before and after?

I want to understand why this is not breaking on poudriere.
Comment 6 Walter Schwarzenfeld 2019-08-03 19:19:04 UTC
Created attachment 206245 [details]
screenlog_before

I tried only in the port.
Comment 7 Walter Schwarzenfeld 2019-08-03 19:19:33 UTC
Created attachment 206246 [details]
screenlog_after
Comment 8 Walter Schwarzenfeld 2019-08-03 19:23:19 UTC
Comment on attachment 206246 [details]
screenlog_after

Sorry, something went wrong.
Comment 9 Walter Schwarzenfeld 2019-08-03 19:30:21 UTC
Created attachment 206247 [details]
screenlog_before
Comment 10 Walter Schwarzenfeld 2019-08-03 19:30:59 UTC
Created attachment 206248 [details]
screenlog_after
Comment 11 Paul Boehmer 2019-08-05 12:38:44 UTC
Confirm w.schwarzenfeld's changes to Makefile resolve the problem on my end.  I performed "make rmconfig" and used the port defaults with a new build which resulted in the same errors in my original report.  

I can build logs using the un-altered Makefile if needed.
Comment 12 Walter Schwarzenfeld 2019-08-05 12:43:06 UTC
Sorry, is not clear.

> I performed "make rmconfig" and used the port defaults with a new build which resulted in the 
> same errors in my original report.  

Does it work or does it not work?
Comment 13 Paul Boehmer 2019-08-05 12:47:27 UTC
Using the un-altered Makefile and building using the port default configs on both libtorrent and rtorrent, the rtorrent build fails.,

Using your changes to Makefile for rtorrent, the build completes successfully.
Comment 14 Walter Schwarzenfeld 2019-08-05 12:51:35 UTC
Ok, clear now.
Comment 15 Danilo G. Baio freebsd_committer freebsd_triage 2019-08-10 13:38:09 UTC
(In reply to Walter Schwarzenfeld from comment #4)

Thank you all for the information/patch.

I noted that this issue happens only when you have libinotify installed in your system (a Samba dependency).

And this approach won't work when you don't have it.

I reported this upstream to check if inotify is mandatory or optional and asked for the best approach to enable/disable it if it's not mandatory, because we don't have a configure option for doing that.

https://github.com/rakshasa/libtorrent/issues/199
Comment 16 sergey 2022-11-13 08:35:44 UTC
(In reply to Walter Schwarzenfeld from comment #4)

at 13.1-RELEASE-p3 GENERIC amd64

your advice worked. thank you!
Comment 17 Mark Linimon freebsd_committer freebsd_triage 2024-01-05 03:34:35 UTC
^Triage: canonicalize assignment.

To submitter: is this problem now fixed?
Comment 18 Mark Linimon freebsd_committer freebsd_triage 2024-09-29 09:09:07 UTC
^Triage: feedback timeout (> 6 months).