tor-0.2.3.x: enabling upnp or nat-pmp with LDFLAGS += --as-needed fails to link
The final error is
86_64-pc-linux-gnu-gcc -Wall -fno-strict-aliasing -march=native -O2 -pipe
-Wl,--as-needed -Wl,-O1 -o tor-fw-helper tor_fw_helper-tor-fw-helper.o
tor_fw_helper-tor-fw-helper-natpmp.o tor_fw_helper-tor-fw-helper-upnp.o
-lminiupnpc -lm ../../common/libor.a -lpthread -ldl
../../common/libor.a(util.o): In function tor_mathlog': util.c:(.text+0x8e1): undefined reference to
log'
../../common/libor.a(util.o): In function tor_lround': util.c:(.text+0x8f1): undefined reference to
lround'
collect2: ld returned 1 exit status
make[4]: *** [tor-fw-helper] Error 1
make[4]: Leaving directory
/var/tmp/portage/net-misc/tor-0.2.3.2_alpha-r1/work/tor-0.2.3.2-alpha/src/tools/tor-fw-helper' make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory
/var/tmp/portage/net-misc/tor-0.2.3.2_alpha-r1/work/tor-0.2.3.2-alpha/src/tools'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory
/var/tmp/portage/net-misc/tor-0.2.3.2_alpha-r1/work/tor-0.2.3.2-alpha/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory
/var/tmp/portage/net-misc/tor-0.2.3.2_alpha-r1/work/tor-0.2.3.2-alpha'
make: *** [all] Error 2
- ERROR: net-misc/tor-0.2.3.2_alpha-r1 failed (compile phase):
- emake failed
This is fixed by reordering tor_fw_helper_LDADD in rc/tools/tor-fw-helper/Makefile.am. See the attached patch.