From ec6fdbb128361fb374c8c21843c9f8223ac7a39d Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 17 Jan 2018 13:07:16 +0100 Subject: fix tests linking: don't use system installed libs Do not link against the system-wide installed libosmo* libs when building the regression test programs. Always use the locally built ones. Linking some libosmo libraries causes libtool to pull in other libosmo libs even though they were not explicitly named. For example, ctrl_test explicitly links libosmoctrl, but this also has dependencies to libosmovty and libosmogsm: ldd src/ctrl/.libs/libosmoctrl.so | grep osmo libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f26c26d4000) libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f26c22bb000) libosmovty.so.4 => /usr/local/lib/libosmovty.so.4 (0x00007f26c2171000) If we omit explicit LDADD of these dependencies in the Makefile.am, libtool will take the first canonical place to find them, which may just be the already installed older versions of the same libs, which may or may not be compatible with the current build. In any case, it is never intended to link installed libs. All library dependencies are listed by this quick script: cd libosmocore for l in $(find . -name "*.so") ; do echo; echo "$l"; ldd $l | grep libosmo; done ./.libs/libosmocore.so ./coding/.libs/libosmocoding.so libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f25fc3c2000) libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f25fbfa9000) libosmocodec.so.0 => /usr/local/lib/libosmocodec.so.0 (0x00007f25fbf9b000) ./codec/.libs/libosmocodec.so libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007fb4c900d000) ./ctrl/.libs/libosmoctrl.so libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f5df5129000) libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f5df4d10000) libosmovty.so.4 => /usr/local/lib/libosmovty.so.4 (0x00007f5df4bc6000) ./gb/.libs/libosmogb.so libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f788e536000) libosmovty.so.4 => /usr/local/lib/libosmovty.so.4 (0x00007f788e3ec000) libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f788dfd3000) ./vty/.libs/libosmovty.so libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f3b7ed21000) ./gsm/.libs/libosmogsm.so libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007fc69472e000) ./sim/.libs/libosmosim.so libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f2f6412d000) libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f2f63d14000) Add all explicit linking of all required library dependencies in all regression test programs, as shown by above listing. Example for reproducing a problem: In libosmocore.a, introduce a new function, and call that from libosmovty code. For example, I made loglevel_strs non-static in logging.c, and used that in logging_vty.c. Build and install this in a place where libtool can find it. Then go back to before this change and rebuild. You will see that linking ctrl_test (before this patch) then complains about libosmovty requiring the loglevel_strs symbol which it cannot find in libosmocore.so. Change-Id: Id084e6e6efd25cd62b1bd7a4fc7c5985c39130c6 --- tests/Makefile.am | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 072bb4a2..5d07695a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -76,7 +76,10 @@ abis_abis_test_SOURCES = abis/abis_test.c abis_abis_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la ctrl_ctrl_test_SOURCES = ctrl/ctrl_test.c -ctrl_ctrl_test_LDADD = $(LDADD) $(top_builddir)/src/ctrl/libosmoctrl.la +ctrl_ctrl_test_LDADD = $(LDADD) \ + $(top_builddir)/src/ctrl/libosmoctrl.la \ + $(top_builddir)/src/gsm/libosmogsm.la \ + $(top_builddir)/src/vty/libosmovty.la gea_gea_test_SOURCES = gea/gea_test.c gea_gea_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la @@ -130,20 +133,24 @@ ussd_ussd_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la gb_bssgp_fc_test_SOURCES = gb/bssgp_fc_test.c gb_bssgp_fc_test_LDADD = $(LDADD) $(top_builddir)/src/gb/libosmogb.la \ + $(top_builddir)/src/vty/libosmovty.la \ $(top_builddir)/src/gsm/libosmogsm.la gb_gprs_bssgp_test_SOURCES = gb/gprs_bssgp_test.c gb_gprs_bssgp_test_LDADD = $(LDADD) $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DLSYM) \ + $(top_builddir)/src/vty/libosmovty.la \ $(top_builddir)/src/gsm/libosmogsm.la gb_gprs_ns_test_SOURCES = gb/gprs_ns_test.c gb_gprs_ns_test_LDADD = $(LDADD) $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DLSYM) \ + $(top_builddir)/src/vty/libosmovty.la \ $(top_builddir)/src/gsm/libosmogsm.la logging_logging_test_SOURCES = logging/logging_test.c fr_fr_test_SOURCES = fr/fr_test.c fr_fr_test_LDADD = $(LDADD) $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DLSYM) \ + $(top_builddir)/src/vty/libosmovty.la \ $(top_builddir)/src/gsm/libosmogsm.la codec_codec_test_SOURCES = codec/codec_test.c @@ -177,7 +184,11 @@ oap_oap_client_test_SOURCES = oap/oap_client_test.c oap_oap_client_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la fsm_fsm_test_SOURCES = fsm/fsm_test.c -fsm_fsm_test_LDADD = $(LDADD) $(top_builddir)/src/ctrl/libosmoctrl.la +fsm_fsm_test_LDADD = \ + $(LDADD) \ + $(top_builddir)/src/ctrl/libosmoctrl.la \ + $(top_builddir)/src/gsm/libosmogsm.la \ + $(top_builddir)/src/vty/libosmovty.la write_queue_wqueue_test_SOURCES = write_queue/wqueue_test.c -- cgit v1.2.3