Hi Neels,
On 11/21/22 07:00, Neels Hofmeyr wrote:
I am having an automake / libtool problem and don't know how to solve it.
In libosmo-pfcp, there is the pfcp_test binary, which obviously requires linking libosmo-pfcp.so -- more precisely, it should NOT link the system installed libosmo-pfcp.so, but the locally built one, libosmo-pfcp.a.
there's actually two binaries generated during the build process:
* tests/libosmo-pfcp/.libs/pfcp_test (generated by `make`) * tests/libosmo-pfcp/.libs/lt-pfcp_test (generated by `make check`)
The key difference between them is the RPATH:
* $(readelf --dynamic ./tests/libosmo-pfcp/.libs/pfcp_test) gives me: ** /usr/lib
* $(readelf --dynamic ./tests/libosmo-pfcp/.libs/lt-pfcp_test) gives me: ** /usr/lib ** /home/fixeria/projects/osmocom/libosmo-pfcp/src/libosmo-pfcp/.libs ** /home/fixeria/projects/osmocom/libosmo-pfcp/src/libosmo-gtlv/.libs
The '.libs/pfcp_test' is a binary that can be installed during `make install` (in this case it's not going to be installed because it's listed in 'noinst_PROGRAMS'), while the '.libs/lt-pfcp_test' is a binary that *should* be executed from the build tree during `make check`.
BTW, we should be using 'check_PROGRAMS', not 'noinst_PROGRAMS':
https://gerrit.osmocom.org/c/libosmo-pfcp/+/30250
I am now adding a new optional IE to libosmo-pfcp, and I found that this does not work as expected! The pfcp_test binary is linked to the previously installed libosmo-pfcp.so in /usr/local/lib, instead of the proper, new version from the build tree. I found out by getting an obscure ABI corruption error, verified it by:
~/osmo-dev/make/libosmo-pfcp/tests/libosmo-pfcp $ ldd .libs/pfcp_test [...] libosmo-pfcp.so.0 => /usr/local/lib/libosmo-pfcp.so.0 (0x00007f1b6bc00000) libosmo-gtlv.so.0 => /usr/local/lib/libosmo-gtlv.so.0 (0x00007f1b6cc0a000) [...]
As I explained above, it's expected that the ELF loader picks system-installed libraries for the '.libs/pfcp_test'. You need to examine the '.libs/lt-pfcp_test' instead.
As soon as I 'make uninstall' in libosmo-pfcp.git's root dir, this changes to:
▶ ldd .libs/pfcp_test [...] libosmo-pfcp.so.0 => not found libosmo-gtlv.so.0 => not found [...]
and then the test succeeds (because './pfcp_test' is actually a shell script generated by libtool with linker magic referencing the libs built within the libosmo-pfcp.git tree).
This is indeed weird. You should probably examine the libtool generated script. It should be executing the '.libs/lt-pfcp_test':
program=lt-'pfcp_test' progdir="$thisdir/.libs"
...
exec "$progdir/$program" ${1+"$@"}
I suspect that we may have a similar pitfall in many other osmo source trees, because the Makefile.am*looks* like it takes care of this problem, but actually doesn't.
AFAIR, you already brought a similar problem up back in 2018:
https://gerrit.osmocom.org/c/libosmocore/+/5844
Best regards, Vadim.