From a334646a99520fdcf81e1460a839cae5c6d06f2c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 14 Dec 2011 11:10:31 -0500 Subject: [PATCH] Make dlopen more robust by using the .0 target for the library We've experienced a double library load on a setup where the lttng-ust .so and .so.0 were two physical files instead of a symlink (as they should be). So let's make liblttng-ust slightly more robust by specifying the target .so.0 instead of .so. It will also make handling of library version upgrades easier. Signed-off-by: Mathieu Desnoyers --- configure.ac | 7 +++++++ include/lttng/tracepoint.h | 2 +- liblttng-ust/Makefile.am | 2 +- libringbuffer/Makefile.am | 3 --- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 927bae36..459bccbe 100644 --- a/configure.ac +++ b/configure.ac @@ -2,6 +2,13 @@ # Process this file with autoconf to produce a configure script. AC_INIT([lttng-ust],[1.9.1],[mathieu dot desnoyers at efficios dot com]) + +# Following the numbering scheme proposed by libtool for the library version +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +AC_SUBST([LTTNG_UST_LIBRARY_VERSION], [0:0:0]) +# note: remember to update tracepoint.h dlopen() to match this version +# number. TODO: eventually automate by exporting the major number. + AC_CONFIG_AUX_DIR([config]) AC_CANONICAL_TARGET AC_CANONICAL_HOST diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index 2942c175..1adb149d 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -190,7 +190,7 @@ static void __attribute__((constructor)) __tracepoints__init(void) if (__tracepoint_registered++) return; - liblttngust_handle = dlopen("liblttng-ust.so", RTLD_NOW | RTLD_GLOBAL); + liblttngust_handle = dlopen("liblttng-ust.so.0", RTLD_NOW | RTLD_GLOBAL); if (!liblttngust_handle) return; tracepoint_register_lib = diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am index 6b33906b..a71f2074 100644 --- a/liblttng-ust/Makefile.am +++ b/liblttng-ust/Makefile.am @@ -37,7 +37,7 @@ liblttng_ust_support_la_SOURCES = \ liblttng_ust_la_SOURCES = -liblttng_ust_la_LDFLAGS = -no-undefined -version-info 0:0:0 +liblttng_ust_la_LDFLAGS = -no-undefined -version-info $(LTTNG_UST_LIBRARY_VERSION) liblttng_ust_support_la_LIBADD = \ $(top_builddir)/libringbuffer/libringbuffer.la diff --git a/libringbuffer/Makefile.am b/libringbuffer/Makefile.am index f1d7ade3..9bd85868 100644 --- a/libringbuffer/Makefile.am +++ b/libringbuffer/Makefile.am @@ -13,9 +13,6 @@ libringbuffer_la_SOURCES = \ frontend_api.h frontend.h frontend_internal.h frontend_types.h \ nohz.h vatomic.h - -libringbuffer_la_LDFLAGS = -no-undefined -version-info 0:0:0 - libringbuffer_la_LIBADD = \ -lpthread \ -lrt -- 2.34.1