I have two projects that failed with the latest version: one that uses tor as a library in process rather than as an independent executable/process, and one that uses tor as its own 'vanilla' independent binary/process. Both worked fine with 0.4.0.5 and lto on and --disable-module-dirauth set and both don't with 0.4.1.5
I tried the library without lto and it still failed
tor/src/core/libtor-app.a(main.o):main.c:function run_tor_main_loop: error: undefined reference to 'keypin_load_journal'tor/src/core/libtor-app.a(main.o):main.c:function run_tor_main_loop: error: undefined reference to 'keypin_open_journal'tor/src/core/libtor-app.a(main.o):main.c:function do_hup: error: undefined reference to 'dirserv_load_fingerprint_file'tor/src/core/libtor-app.a(connection_or.o):connection_or.c:function connection_or_client_learned_peer_id: error: undefined reference to 'dirserv_orconn_tls_done'tor/src/core/libtor-app.a(networkstatus.o):networkstatus.c:function routers_update_status_from_consensus_networkstatus: error: undefined reference to 'dirserv_should_launch_reachability_test'src/core/libtor-app.a(nodelist.o):nodelist.c:function nodelist_set_routerinfo: error: undefined reference to 'dirserv_router_get_status'tor/src/core/libtor-app.a(nodelist.o):nodelist.c:function nodelist_set_routerinfo: error: undefined reference to 'dirserv_set_node_flags_from_authoritative_status'tor/src/core/libtor-app.a(routerlist.o):routerlist.c:function router_add_to_routerlist: error: undefined reference to 'authdir_wants_to_reject_router'tor/src/core/libtor-app.a(routerlist.o):routerlist.c:function update_consensus_router_descriptor_downloads: error: undefined reference to 'dirserv_would_reject_router'tor/src/core/libtor-app.a(router.o):router.c:function init_keys: error: undefined reference to 'dirserv_add_own_fingerprint'tor/src/core/libtor-app.a(router.o):router.c:function init_keys: error: undefined reference to 'dirserv_add_descriptor'tor/src/core/libtor-app.a(router.o):router.c:function init_keys: error: undefined reference to 'dirserv_load_fingerprint_file'tor/src/core/libtor-app.a(dircache.o):dircache.c:function directory_handle_command_post: error: undefined reference to 'dirserv_add_multiple_descriptors' clang: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.
I used the following config (static openssl, static libevent, static zlib).
I suspect that the reason I can't reproduce this issue locally is that it has something to do with the behavior of LTO on the android toolchain specifically. This is confirmed by #31301 (moved), which might be the same issue.
Looking at the code: It seems that the functions that the compiler is complaining about are only called within blocks that, after compilation with --disable-module-dirauth, become "if (0) { ... }". So I can believe that they are totally removed before linking sometimes, but not all the time. The fix should be simple enough if this is the case.
I am not sure if the library failures are lto related or not but i tried to build my application which integrates with tor as a library on osx with lto off and the dirauth module disabled
Undefined symbols for architecture x86_64: "_dirserv_add_descriptor", referenced from: _init_keys in libtor-app.a(router.o) "_dirserv_add_multiple_descriptors", referenced from: _directory_handle_command_post in libtor-app.a(dircache.o) "_dirserv_add_own_fingerprint", referenced from: _init_keys in libtor-app.a(router.o) "_dirserv_load_fingerprint_file", referenced from: _do_hup in libtor-app.a(main.o) _init_keys in libtor-app.a(router.o) "_dirserv_orconn_tls_done", referenced from: _connection_or_client_learned_peer_id in libtor-app.a(connection_or.o) "_dirserv_router_get_status", referenced from: _nodelist_set_routerinfo in libtor-app.a(nodelist.o) "_dirserv_set_node_flags_from_authoritative_status", referenced from: _nodelist_set_routerinfo in libtor-app.a(nodelist.o) "_keypin_load_journal", referenced from: _run_tor_main_loop in libtor-app.a(main.o) "_keypin_open_journal", referenced from: _run_tor_main_loop in libtor-app.a(main.o)ld: symbol(s) not found for architecture x86_64
tested both as a library and as a standalone binary and with and without lto with the dirauth module disabled and everything builds correctly on linux/windows/osx/freebsd/android with both gcc/clang where available.