Hm. The "evthread_use_pthreads" is wrong; Tor only uses libevent from the main thread, except when windows bufferevents are in use. (That could be a comment instead.)
Has anybody tested this with older (pre-2.0) versions of Libevent, to make sure it doesn't break them?
Trac: Status: new to needs_review Keywords: bsd deleted, bsd 026-backport libevent added
Hm. The "evthread_use_pthreads" is wrong; Tor only uses libevent from the main thread, except when windows bufferevents are in use. (That could be a comment instead.)
Has anybody tested this with older (pre-2.0) versions of Libevent, to make sure it doesn't break them?
You are correct, the original patch and several mods that were tossed around
on the tor-bsd mailing list were all subtly wrong. I have attached a patch
that I think is correct: only compiled in w/libevent2 and --enable-bufferevents
turned on. Works for me under OpenBSD/i386:
Jul 28 09:55:44.277 [notice] Tor v0.2.7.1-alpha-dev (git-aeeb6376aab186fd) (with bufferevents) running on OpenBSD with Libevent 2.0.22-stable, OpenSSL LibreSSL 2.2 and Zlib 1.2.3.
Successfully builds circuits and otherwise seems to work. Most of the test suite
passes but there are four tests that have never passed for me under OpenBSD,
patch notwithstanding... that can be a separate ticket.
Used this patch on the Tor 0.2.6.10 source on an OpenBSD 5.7 system with libevent 2.0.22 installed from ports. Command './configure --enable-bufferevents' fails as per below. Same error when trying to configure the 0.2.7.2-alpha.
configure: error: You've asked for bufferevent support, but you're using a version of Libevent without SSL support. This won't work. We need Libevent 2.0.8-rc or later, and you don't seem to even have Libevent 2.0.3-alpha.
Using freshly extracted tor 0.2.7.2-alpha archive and the commands below it got bit further this time, before failing as per below. System is updated with LibreSSL 2.2.1 and platform is amd64.
src/common/libor-event.a(procmon.o)(.text+0x256): In function `tor_process_monitor_new':
: undefined reference to `event_new'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_get_write_max'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_init_common'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_generic_adj_timeouts'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_add_event'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_run_eventcb'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_get_read_max'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_unsuspend_read'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_incref_and_lock'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_incref'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `event_mm_calloc_'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_run_readcb'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `evutil_closesocket'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_decref_and_unlock'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_suspend_read'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_evthread_lock_fns'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_decrement_write_buckets'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_enable_locking'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `event_assign'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `event_get_fd'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_run_writecb'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_decrement_read_buckets'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_del_generic_timeout_cbs'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_init_generic_timeout_cbs'
collect2: ld returned 1 exit status
* Error 1 in /usr/local/src/tor-0.2.7.2-alpha (Makefile:2656 'src/or/tor': @echo " CCLD " src/or/tor;gcc -std=gnu99 -I/usr/local/incl...)
Using freshly extracted tor 0.2.7.2-alpha archive and the commands below it got bit further this time, before failing as per below. System is updated with LibreSSL 2.2.1 and platform is amd64.
src/common/libor-event.a(procmon.o)(.text+0x256): In function `tor_process_monitor_new':
: undefined reference to `event_new'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_get_write_max'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_init_common'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_generic_adj_timeouts'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_add_event'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_run_eventcb'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_get_read_max'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_unsuspend_read'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_incref_and_lock'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_incref'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `event_mm_calloc_'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_run_readcb'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `evutil_closesocket'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_decref_and_unlock'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_suspend_read'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_evthread_lock_fns'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_decrement_write_buckets'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `bufferevent_enable_locking'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `event_assign'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `event_get_fd'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_run_writecb'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_decrement_read_buckets'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_del_generic_timeout_cbs'
/usr/local/lib/libevent_openssl.so.0.0: undefined reference to `_bufferevent_init_generic_timeout_cbs'
collect2: ld returned 1 exit status
* Error 1 in /usr/local/src/tor-0.2.7.2-alpha (Makefile:2656 'src/or/tor': @echo " CCLD " src/or/tor;gcc -std=gnu99 -I/usr/local/incl...)
The patch has two parts, one to configure.ac and one to compat_libevent.c. It looks like
perhaps you didn't regenerate configure after patching configure.ac.
Also, to be sure: you're running -current, right? What does the first line of your
dmesg output look like? Here's the one from the machine where this worked:
$ dmesg | head -1OpenBSD 5.8-beta (GENERIC) #987: Sat Jul 11 00:10:38 MDT 2015
That's actually not that recent a snap... I'll try it with the latest today once my
new machine is up to snuff. This might all work on -stable as well but I don't have
anything but -current to test with at the moment.
I tried this again on an OpenBSD 5.8 amd64 current snapshot against the latest Tor source from the git repository. Build crapped again, commands and build error output below.
$ git clone https://git.torproject.org/git/tor$ cd tor$ ftp https://trac.torproject.org/projects/tor/raw-attachment/ticket/16651/tor-libevent2-4.patch$ patch < tor-libevent2-4.patch $ env AUTOMAKE_VERSION=1.15 AUTOCONF_VERSION=2.69 ./autogen.sh$ env CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure --with-ssl-dir=/usr --disable-gcc-hardening --disable-asciidoc$ env AUTOMAKE_VERSION=1.15 AUTOCONF_VERSION=2.69 gmakecompat_libevent.c:(.text+0x88e): undefined reference to `event_new'src/common/libor-event.a(procmon.o): In function `tor_process_monitor_new':procmon.c:(.text+0x256): undefined reference to `event_new'collect2: ld returned 1 exit statusMakefile:2655: recipe for target 'src/or/tor' failedgmake[1]: *** [src/or/tor] Error 1gmake[1]: Leaving directory '/usr/local/src/tor'Makefile:1864: recipe for target 'all' failedgmake: *** [all] Error 2
I tried this again on an OpenBSD 5.8 amd64 current snapshot against the latest Tor source from the git repository. Build crapped again, commands and build error output below.
I get the same when building without bufferevents. With bufferevents it builds fine on both 5.7-release and a -current snapshot.