commit f1701358728b20aea473ac3f24e5655dbb4da065
Author: orbea <orbea@riseup.net>
Date:   Sun Apr 11 09:45:59 2021 -0700

    WIP: Fix the build with slibtool.

diff --git a/src/bin/lttng-relayd/Makefile.am b/src/bin/lttng-relayd/Makefile.am
index f6d5b295..da2fedf5 100644
--- a/src/bin/lttng-relayd/Makefile.am
+++ b/src/bin/lttng-relayd/Makefile.am
@@ -7,6 +7,13 @@ if EMBED_HELP
 AM_CPPFLAGS += -I$(top_builddir)/doc/man
 endif
 
+noinst_LTLIBRARIES = liblttng-relayd-compat.la
+
+liblttng_relayd_compat_la_SOURCES = backward-compatibility-group-by.c \
+		backward-compatibility-group-by.h
+
+liblttng_relayd_compat_la_LDFLAGS = -static -no-undefined
+
 bin_PROGRAMS = lttng-relayd
 
 lttng_relayd_SOURCES = main.c lttng-relayd.h utils.h utils.c cmd.h \
@@ -24,8 +31,7 @@ lttng_relayd_SOURCES = main.c lttng-relayd.h utils.h utils.c cmd.h \
                        viewer-session.c viewer-session.h \
                        tracefile-array.c tracefile-array.h \
                        tcp_keep_alive.c tcp_keep_alive.h \
-                       sessiond-trace-chunks.c sessiond-trace-chunks.h \
-                       backward-compatibility-group-by.c backward-compatibility-group-by.h
+                       sessiond-trace-chunks.c sessiond-trace-chunks.h
 
 # link on liblttngctl for check if relayd is already alive.
 lttng_relayd_LDADD = $(URCU_LIBS) \
@@ -37,4 +43,5 @@ lttng_relayd_LDADD = $(URCU_LIBS) \
 		$(top_builddir)/src/common/health/libhealth.la \
 		$(top_builddir)/src/common/config/libconfig.la \
 		$(top_builddir)/src/common/testpoint/libtestpoint.la \
-		$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
+		$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \
+		liblttng-relayd-compat.la
diff --git a/src/bin/lttng-sessiond/Makefile.am b/src/bin/lttng-sessiond/Makefile.am
index 8a299fab..08b094b5 100644
--- a/src/bin/lttng-sessiond/Makefile.am
+++ b/src/bin/lttng-sessiond/Makefile.am
@@ -7,45 +7,58 @@ if EMBED_HELP
 AM_CPPFLAGS += -I$(top_builddir)/doc/man
 endif
 
+noinst_LTLIBRARIES = liblttng-sessiond-comm.la
+
+liblttng_sessiond_comm_la_SOURCES = agent.c agent.h \
+		buffer-registry.c buffer-registry.h \
+		channel.c channel.h \
+		cmd.c cmd.h \
+		condition-internal.c condition-internal.h \
+		consumer.c consumer.h \
+		context.c context.h \
+		event.c event.h \
+		event-notifier-error-accounting.c event-notifier-error-accounting.h \
+		fd-limit.c fd-limit.h \
+		globals.c \
+		ht-cleanup.c ht-cleanup.h \
+		kernel.c kernel.h \
+		kernel-consumer.c kernel-consumer.h \
+		lttng-syscall.h lttng-syscall.c \
+		modprobe.c modprobe.h kern-modules.h \
+		notification-thread.c notification-thread.h \
+		notification-thread-internal.h \
+		notification-thread-commands.c notification-thread-commands.h \
+		notification-thread-events.c notification-thread-events.h \
+		rotate.c rotate.h \
+		rotation-thread.c rotation-thread.h \
+		session.c session.h \
+		snapshot.c snapshot.h \
+		timer.c timer.h \
+		trace-kernel.c trace-kernel.h \
+		tracker.c tracker.h \
+		thread.c thread.h \
+		utils.c utils.h
+
+liblttng_sessiond_comm_la_LDFLAGS = -static -no-undefined
+
+liblttng_sessiond_comm_la_LIBADD = $(top_builddir)/src/common/libcommon.la \
+		$(top_builddir)/src/common/compat/libcompat.la \
+		$(top_builddir)/src/common/health/libhealth.la \
+		$(top_builddir)/src/common/kernel-ctl/libkernel-ctl.la \
+		$(top_builddir)/src/common/relayd/librelayd.la
+
 bin_PROGRAMS = lttng-sessiond
 
-lttng_sessiond_SOURCES = utils.c utils.h \
-                       trace-kernel.c trace-kernel.h \
-                       kernel.c kernel.h \
-                       ust-app.h trace-ust.h notify-apps.h \
+lttng_sessiond_SOURCES = ust-app.h trace-ust.h notify-apps.h \
                        lttng-ust-ctl.h lttng-ust-abi.h lttng-ust-error.h \
                        ust-ctl-internal.h ust-abi-internal.h ust-error-internal.h \
                        ust-registry.h \
-                       condition-internal.c condition-internal.h \
-                       context.c context.h \
-                       channel.c channel.h \
-                       event.c event.h \
-                       consumer.c consumer.h \
-                       session.c session.h \
-                       modprobe.c modprobe.h kern-modules.h \
-                       fd-limit.c fd-limit.h \
-                       kernel-consumer.c kernel-consumer.h \
-                       consumer.h \
                        health-sessiond.h \
-                       cmd.c cmd.h \
-                       buffer-registry.c buffer-registry.h \
-                       testpoint.h ht-cleanup.c ht-cleanup.h \
-                       snapshot.c snapshot.h \
-                       agent.c agent.h \
+                       testpoint.h \
                        save.h save.c \
-                       lttng-syscall.h lttng-syscall.c \
-                       notification-thread.h notification-thread.c \
-                       notification-thread-internal.h \
-                       notification-thread-commands.h notification-thread-commands.c \
-                       notification-thread-events.h notification-thread-events.c \
                        sessiond-config.h sessiond-config.c \
-                       rotate.h rotate.c \
-                       rotation-thread.h rotation-thread.c \
-                       timer.c timer.h \
-                       globals.c \
                        thread-utils.c \
                        process-utils.c \
-                       thread.c thread.h \
                        health.c \
                        client.c client.h \
                        dispatch.c dispatch.h \
@@ -54,14 +67,12 @@ lttng_sessiond_SOURCES = utils.c utils.h \
                        manage-kernel.c manage-kernel.h \
                        manage-consumer.c manage-consumer.h \
                        clear.c clear.h \
-                       tracker.c tracker.h \
-                       event-notifier-error-accounting.c event-notifier-error-accounting.h \
                        action-executor.c action-executor.h
 
 lttng_sessiond_LDFLAGS = -rdynamic
 
 if HAVE_LIBLTTNG_UST_CTL
-lttng_sessiond_SOURCES += trace-ust.c ust-registry.c ust-app.c \
+liblttng_sessiond_comm_la_SOURCES += trace-ust.c ust-registry.c ust-app.c \
 			ust-consumer.c ust-consumer.h notify-apps.c \
 			ust-metadata.c ust-clock.h agent-thread.c agent-thread.h \
 			ust-field-utils.h ust-field-utils.c
@@ -71,18 +82,14 @@ endif
 lttng_sessiond_SOURCES += lttng-sessiond.h main.c
 
 # link on liblttngctl for check if sessiond is already alive.
-lttng_sessiond_LDADD = -lurcu-common $(URCU_LIBS) $(KMOD_LIBS) \
+lttng_sessiond_LDADD = $(URCU_LIBS) $(KMOD_LIBS) \
 		$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \
 		$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \
-		$(top_builddir)/src/common/kernel-ctl/libkernel-ctl.la \
 		$(top_builddir)/src/common/hashtable/libhashtable.la \
-		$(top_builddir)/src/common/libcommon.la \
-		$(top_builddir)/src/common/compat/libcompat.la \
-		$(top_builddir)/src/common/relayd/librelayd.la \
 		$(top_builddir)/src/common/testpoint/libtestpoint.la \
-		$(top_builddir)/src/common/health/libhealth.la \
 		$(top_builddir)/src/common/config/libconfig.la \
-		$(top_builddir)/src/common/string-utils/libstring-utils.la
+		$(top_builddir)/src/common/string-utils/libstring-utils.la \
+		liblttng-sessiond-comm.la
 
 
 if HAVE_LIBLTTNG_UST_CTL
diff --git a/src/bin/lttng/Makefile.am b/src/bin/lttng/Makefile.am
index 50ab9298..a80b4cfc 100644
--- a/src/bin/lttng/Makefile.am
+++ b/src/bin/lttng/Makefile.am
@@ -10,6 +10,11 @@ AUTOMAKE_OPTIONS = subdir-objects
 
 bin_PROGRAMS = lttng
 
+noinst_LTLIBRARIES = liblttng-log.la
+
+liblttng_log_la_SOURCES = loglevel.c loglevel.h
+liblttng_log_la_LDFLAGS = -no-undefined -static
+
 lttng_SOURCES = command.h conf.c conf.h commands/start.c \
 				commands/list.c commands/create.c commands/destroy.c \
 				commands/stop.c commands/enable_events.c \
@@ -29,7 +34,6 @@ lttng_SOURCES = command.h conf.c conf.h commands/start.c \
 				commands/enable_rotation.c \
 				commands/disable_rotation.c \
 				commands/clear.c \
-				loglevel.c loglevel.h \
 				commands/add_trigger.c \
 				commands/list_triggers.c \
 				commands/remove_trigger.c \
@@ -44,4 +48,5 @@ lttng_LDADD = $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \
 			$(top_builddir)/src/common/string-utils/libstring-utils.la \
 			$(top_builddir)/src/common/filter/libfilter.la \
 			$(top_builddir)/src/common/argpar/libargpar.la \
+			liblttng-log.la \
 			$(POPT_LIBS)
diff --git a/tests/regression/tools/live/Makefile.am b/tests/regression/tools/live/Makefile.am
index 94333fd3..780b0d22 100644
--- a/tests/regression/tools/live/Makefile.am
+++ b/tests/regression/tools/live/Makefile.am
@@ -4,17 +4,10 @@ AM_CPPFLAGS += -I$(top_srcdir)/tests/utils/ -I$(srcdir)
 
 LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la
 
-LIBCOMMON=$(top_builddir)/src/common/libcommon.la
 LIBSESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
 LIBHASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la
-LIBRELAYD=$(top_builddir)/src/common/relayd/librelayd.la
-LIBHEALTH=$(top_builddir)/src/common/health/libhealth.la
-LIBCOMPAT=$(top_builddir)/src/common/compat/libcompat.la
 
-LIVE= $(top_builddir)/src/bin/lttng-sessiond/consumer.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/globals.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/utils.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/snapshot.$(OBJEXT)
+LIVE= $(top_builddir)/src/bin/lttng-sessiond/liblttng-sessiond-comm.la
 
 noinst_PROGRAMS = live_test
 EXTRA_DIST = test_kernel test_lttng_kernel
@@ -24,8 +17,7 @@ EXTRA_DIST += test_ust test_ust_tracefile_count test_lttng_ust
 endif
 
 live_test_SOURCES = live_test.c
-live_test_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBRELAYD) $(LIBSESSIOND_COMM) \
-		$(LIBHASHTABLE) $(LIBHEALTH) $(DL_LIBS) $(LIBCOMPAT) -lrt
+live_test_LDADD = $(LIBTAP) $(LIBSESSIOND_COMM) $(LIBHASHTABLE) $(DL_LIBS) -lrt
 live_test_LDADD += $(LIVE) \
 		$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
 
diff --git a/tests/regression/ust/baddr-statedump/Makefile.am b/tests/regression/ust/baddr-statedump/Makefile.am
index 35de5f94..c663de19 100644
--- a/tests/regression/ust/baddr-statedump/Makefile.am
+++ b/tests/regression/ust/baddr-statedump/Makefile.am
@@ -15,7 +15,7 @@ EXTRA_DIST = test_baddr-statedump test_baddr-statedump.py
 
 # Extract debug symbols
 prog.debug: prog
-	$(objcopy_verbose)$(OBJCOPY) --only-keep-debug prog prog.debug
+	$(LIBTOOL) --mode=execute $(objcopy_verbose)$(OBJCOPY) --only-keep-debug prog prog.debug
 
 # Strip and add debuglink
 prog.strip: prog.debug
diff --git a/tests/regression/ust/clock-override/Makefile.am b/tests/regression/ust/clock-override/Makefile.am
index 9495bca0..ff6c6a29 100644
--- a/tests/regression/ust/clock-override/Makefile.am
+++ b/tests/regression/ust/clock-override/Makefile.am
@@ -17,7 +17,7 @@ GETCPU_LIBTOOL_FLAGS = \
     -module \
     -shared \
     -avoid-version \
-    --no-as-needed \
+    -Wl,--no-as-needed \
     -rpath $(abs_builddir)
 
 noinst_LTLIBRARIES = lttng-ust-clock-override-test.la
diff --git a/tests/regression/ust/getcpu-override/Makefile.am b/tests/regression/ust/getcpu-override/Makefile.am
index 3eb25436..0c04961e 100644
--- a/tests/regression/ust/getcpu-override/Makefile.am
+++ b/tests/regression/ust/getcpu-override/Makefile.am
@@ -18,7 +18,7 @@ GETCPU_LIBTOOL_FLAGS = \
     -module \
     -shared \
     -avoid-version \
-    --no-as-needed \
+    -Wl,--no-as-needed \
     -rpath $(abs_builddir)
 
 noinst_LTLIBRARIES = lttng-ust-getcpu-override-test.la
diff --git a/tests/regression/ust/ust-dl/Makefile.am b/tests/regression/ust/ust-dl/Makefile.am
index 2176b23b..603c67e3 100644
--- a/tests/regression/ust/ust-dl/Makefile.am
+++ b/tests/regression/ust/ust-dl/Makefile.am
@@ -48,11 +48,11 @@ libtp_la_LDFLAGS = -module -shared -rpath $(abs_builddir)
 
 # Extract debug symbols
 libfoo.so.debug: libfoo.la
-	$(objcopy_verbose)$(OBJCOPY) --only-keep-debug .libs/libfoo.so libfoo.so.debug
+	$(LIBTOOL) --mode=execute $(objcopy_verbose)$(OBJCOPY) --only-keep-debug libfoo.so libfoo.so.debug
 libbar.so.debug: libbar.la
-	$(objcopy_verbose)$(OBJCOPY) --only-keep-debug .libs/libbar.so libbar.so.debug
+	$(LIBTOOL) --mode=execute $(objcopy_verbose)$(OBJCOPY) --only-keep-debug libbar.so libbar.so.debug
 libzzz.so.debug: libzzz.la
-	$(objcopy_verbose)$(OBJCOPY) --only-keep-debug .libs/libzzz.so libzzz.so.debug
+	$(LIBTOOL) --mode=execute $(objcopy_verbose)$(OBJCOPY) --only-keep-debug libzzz.so libzzz.so.debug
 
 # Strip and add debuglink
 libfoo.so: libfoo.so.debug
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index b972c358..88d909a0 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -41,6 +41,7 @@ LIBSESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
 LIBHASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la
 LIBRELAYD=$(top_builddir)/src/common/relayd/librelayd.la
 LIBLTTNG_CTL=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
+LIBLTTNG_LOG=$(top_builddir)/src/bin/lttng/liblttng-log.la
 
 # Define test programs
 noinst_PROGRAMS = \
@@ -77,57 +78,11 @@ test_uri_SOURCES = test_uri.c
 test_uri_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBHASHTABLE) $(DL_LIBS)
 
 # Sessiond objects
-SESSIOND_OBJS = $(top_builddir)/src/bin/lttng-sessiond/buffer-registry.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/cmd.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/condition-internal.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/save.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/notification-thread-commands.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/kernel.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/ht-cleanup.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/notification-thread.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/action-executor.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/lttng-syscall.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/channel.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/agent.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/kernel-consumer.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/trace-kernel.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/rotation-thread.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/context.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/consumer.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/utils.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/fd-limit.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/notification-thread-events.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/event.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/event-notifier-error-accounting.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/timer.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/snapshot.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/sessiond-config.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/rotate.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/modprobe.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/session.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/globals.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/thread-utils.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/process-utils.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/thread.$(OBJEXT) \
-	 $(top_builddir)/src/bin/lttng-sessiond/tracker.$(OBJEXT) \
-	 $(top_builddir)/src/common/libcommon.la \
+SESSIOND_OBJS = $(top_builddir)/src/bin/lttng-sessiond/liblttng-sessiond-comm.la \
 	 $(top_builddir)/src/common/testpoint/libtestpoint.la \
-	 $(top_builddir)/src/common/compat/libcompat.la \
-	 $(top_builddir)/src/common/health/libhealth.la \
 	 $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
 
-if HAVE_LIBLTTNG_UST_CTL
-SESSIOND_OBJS += $(top_builddir)/src/bin/lttng-sessiond/trace-ust.$(OBJEXT) \
-		 $(top_builddir)/src/bin/lttng-sessiond/ust-registry.$(OBJEXT) \
-		 $(top_builddir)/src/bin/lttng-sessiond/ust-app.$(OBJEXT) \
-		 $(top_builddir)/src/bin/lttng-sessiond/ust-consumer.$(OBJEXT) \
-		 $(top_builddir)/src/bin/lttng-sessiond/notify-apps.$(OBJEXT) \
-		 $(top_builddir)/src/bin/lttng-sessiond/ust-metadata.$(OBJEXT) \
-		 $(top_builddir)/src/bin/lttng-sessiond/agent-thread.$(OBJEXT) \
-		 $(top_builddir)/src/bin/lttng-sessiond/ust-field-utils.$(OBJEXT)
-endif
-
-RELAYD_OBJS = $(top_builddir)/src/bin/lttng-relayd/backward-compatibility-group-by.$(OBJEXT)
+RELAYD_OBJS = $(top_builddir)/src/bin/lttng-relayd/liblttng-relayd-compat.la
 
 test_session_SOURCES = test_session.c
 test_session_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBRELAYD) $(LIBSESSIOND_COMM) \
@@ -165,19 +120,14 @@ test_ust_data_LDADD += $(SESSIOND_OBJS)
 endif
 
 # Kernel data structures unit test
-KERN_DATA_TRACE=$(top_builddir)/src/bin/lttng-sessiond/trace-kernel.$(OBJEXT) \
-		$(top_builddir)/src/common/compat/libcompat.la \
-		$(top_builddir)/src/bin/lttng-sessiond/consumer.$(OBJEXT) \
-		$(top_builddir)/src/bin/lttng-sessiond/globals.$(OBJEXT) \
-		$(top_builddir)/src/bin/lttng-sessiond/utils.$(OBJEXT) \
-		$(top_builddir)/src/bin/lttng-sessiond/tracker.$(OBJEXT) \
+KERN_DATA_TRACE=$(top_builddir)/src/common/compat/libcompat.la \
 		$(top_builddir)/src/common/health/libhealth.la \
-		$(top_builddir)/src/bin/lttng-sessiond/notification-thread-commands.$(OBJEXT) \
+		$(top_builddir)/src/bin/lttng-sessiond/liblttng-sessiond-comm.la \
 		$(LIBLTTNG_CTL)
 
 test_kernel_data_SOURCES = test_kernel_data.c
-test_kernel_data_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBRELAYD) $(LIBSESSIOND_COMM) \
-			 $(LIBHASHTABLE) $(DL_LIBS) -lrt
+test_kernel_data_LDADD = $(LIBTAP) $(LIBRELAYD) $(LIBSESSIOND_COMM) $(LIBHASHTABLE) \
+			 $(DL_LIBS) -lrt
 test_kernel_data_LDADD += $(KERN_DATA_TRACE)
 
 # utils suffix for unit test
@@ -218,8 +168,7 @@ test_notification_LDADD = $(LIBTAP) $(LIBLTTNG_CTL) $(DL_LIBS)
 
 # Event rule api
 test_event_rule_SOURCES = test_event_rule.c
-test_event_rule_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(DL_LIBS) \
-		      $(top_builddir)/src/bin/lttng/lttng-loglevel.$(OBJEXT)
+test_event_rule_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(LIBLTTNG_LOG) $(DL_LIBS)
 
 # Condition api
 test_condition_SOURCES = test_condition.c
