Introduce libcommon-lgpl for liblttng-ctl
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 11 Jan 2022 20:57:37 +0000 (15:57 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 26 Jan 2022 18:50:27 +0000 (13:50 -0500)
liblttng-ctl is a LGPLv2.1 library should should not use GPLv2 code.
Introduce libcommon-lgpl as a static archive containing only LGPLv2.1
compatible code.

This also removes the dependency from liblttng-ctl to liburcu.

Include some source files in libcommon-lgpl.a which are indirectly needed
by source files required in libcommon-lgpl.a:

- endpoint.cpp,
- lttng-elf.cpp,
- lttng-elf.h.

Include some source files in libcommon-lgpl.a which are only needed to
link the lttng executable:

- domain.cpp,
- spawn-viewer.cpp, spawn-viewer.h.

Introduce the new source file hashtable/seed.cpp to move the
lttng_ht_seed symbol in a source file which does not require
liburcu-cds, so it can be present in libcommon-lgpl. This allows
building compile units which are needed in the lgpl common library which
also contain functions which directly refer to lttng_ht_seed.

Programs and libraries which use libhashtable.la are changed to use
libcommon-gpl.la instead. libhashtable becomes internal to libcommon.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I27d2acb823a6d951692a5da88ce32bbe6bafb072

14 files changed:
src/bin/lttng-consumerd/Makefile.am
src/bin/lttng-relayd/Makefile.am
src/bin/lttng-sessiond/Makefile.am
src/common/Makefile.am
src/common/consumer/Makefile.am
src/common/hashtable/Makefile.am
src/common/hashtable/hashtable.c
src/common/hashtable/seed.c [new file with mode: 0644]
src/common/kernel-consumer/Makefile.am
src/common/ust-consumer/Makefile.am
src/lib/lttng-ctl/Makefile.am
tests/regression/tools/live/Makefile.am
tests/unit/Makefile.am
tests/unit/ini_config/Makefile.am

index 5704ee7213ce2fa2c863bcda04b475fa7d37c39f..2c2ee1d756bae162ab72062d9ba8b8484bbd344b 100644 (file)
@@ -9,7 +9,6 @@ lttng_consumerd_SOURCES = lttng-consumerd.c \
 
 lttng_consumerd_LDADD = \
           $(top_builddir)/src/common/consumer/libconsumer.la \
-          $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \
           $(top_builddir)/src/common/libcommon-gpl.la \
           $(top_builddir)/src/common/index/libindex.la \
           $(top_builddir)/src/common/health/libhealth.la \
index 5ce2ba4799edb208c719ebccf7d74a238311cd86..fa4168c7bf58698ed727d5f6f189e1b84006b27e 100644 (file)
@@ -31,8 +31,6 @@ lttng_relayd_SOURCES = main.c lttng-relayd.h utils.h utils.c cmd.h \
 lttng_relayd_LDADD = -lurcu-common -lurcu \
                $(top_builddir)/src/common/libcommon-gpl.la \
                $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.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/index/libindex.la \
                $(top_builddir)/src/common/health/libhealth.la \
index a22b4b774ac4e0a303e9f7004ba894122d87a678..5819beee1fc187cf5469ffff445986a51f6c0ad3 100644 (file)
@@ -71,7 +71,6 @@ lttng_sessiond_LDADD = -lurcu-common -lurcu $(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-gpl.la \
                $(top_builddir)/src/common/compat/libcompat.la \
                $(top_builddir)/src/common/relayd/librelayd.la \
index beeb7b70c22065f51a992dd816c9d2a437cfbef4..213e21772c076f43a8fa2d322d64fc8f8fd760af 100644 (file)
@@ -23,33 +23,28 @@ DIST_SUBDIRS = \
        fd-tracker
 
 # Common library
-noinst_LTLIBRARIES = libcommon-gpl.la
+noinst_LTLIBRARIES = libcommon-lgpl.la libcommon-gpl.la
 EXTRA_DIST = mi-lttng-4.0.xsd
 
-libcommon_gpl_la_SOURCES = \
+# The libcommon-lgpl static archive contains only LGPLv2.1 code. It is
+# meant to be used by LGPLv2.1 libraries such as liblttng-ctl. It also
+# contains libcommon-lgpl.la.
+libcommon_lgpl_la_SOURCES = \
        action.c \
-       buffer-usage.c \
        buffer-view.h buffer-view.c \
-       common.h \
-       condition.c \
-       context.c context.h \
+       buffer-usage.c \
        credentials.h \
-       daemonize.c daemonize.h \
+       condition.c \
        defaults.c \
        dynamic-array.c dynamic-array.h \
        dynamic-buffer.c dynamic-buffer.h \
        endpoint.c \
        error.c error.h \
        evaluation.c \
-       event.c \
-       filter.c filter.h \
-       futex.c futex.h \
        location.c \
        mi-lttng.c mi-lttng.h \
        notification.c \
        notify.c \
-       optional.h \
-       pipe.c pipe.h \
        readwrite.c readwrite.h \
        runas.c runas.h \
        session-consumed-size.c \
@@ -57,31 +52,49 @@ libcommon_gpl_la_SOURCES = \
        session-rotation.c \
        spawn-viewer.c spawn-viewer.h \
        time.c \
-       trace-chunk.c trace-chunk.h \
-       trace-chunk-registry.h \
+       tracker.c tracker.h \
        trigger.c \
        unix.c unix.h \
        uri.c uri.h \
        userspace-probe.c \
-       utils.c utils.h \
-       uuid.c uuid.h \
-       tracker.c tracker.h \
-       waiter.c waiter.h \
-       fs-handle.h fs-handle-internal.h fs-handle.c
+       utils.c utils.h
 
 if HAVE_ELF_H
-libcommon_gpl_la_SOURCES += \
+libcommon_lgpl_la_SOURCES += \
        lttng-elf.c lttng-elf.h
 endif
 
-libcommon_gpl_la_LIBADD = \
+libcommon_lgpl_la_LIBADD = \
        $(top_builddir)/src/common/config/libconfig.la \
-       $(top_builddir)/src/common/compat/libcompat.la \
-       $(top_builddir)/src/common/hashtable/libhashtable.la \
+       $(top_builddir)/src/common/hashtable/libhashtable-lgpl.la
+
+# The libcommon-gpl static archive contains GPLv2 compatible code. It is
+# meant to be used by GPL executables.
+libcommon_gpl_la_SOURCES = \
+       common.h \
+       context.c context.h \
+       daemonize.c daemonize.h \
+       event.c \
+       filter.c filter.h \
+       fs-handle.c fs-handle.h fs-handle-internal.h \
+       futex.c futex.h \
+       optional.h \
+       pipe.c pipe.h \
+       trace-chunk.c trace-chunk.h \
+       trace-chunk-registry.h \
+       uuid.c uuid.h \
+       waiter.c waiter.h
+
+libcommon_gpl_la_LIBADD = \
+       -lurcu -lurcu-common \
+       libcommon-lgpl.la \
+       $(top_builddir)/src/common/hashtable/libhashtable-gpl.la \
        $(top_builddir)/src/common/fd-tracker/libfd-tracker.la
 
 if BUILD_LIB_COMPAT
 SUBDIRS += compat
+libcommon_lgpl_la_LIBADD += \
+       $(top_builddir)/src/common/compat/libcompat.la
 endif
 
 if BUILD_LIB_HEALTH
index 55e47b2101dcae6ac7ef0c4eab260689c601ba98..24185bc102850cad8a64c8694ceddabdd186fdff 100644 (file)
@@ -12,8 +12,6 @@ libconsumer_la_SOURCES = consumer.c consumer.h consumer-metadata-cache.c \
 libconsumer_la_LIBADD = \
                $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \
                $(top_builddir)/src/common/kernel-consumer/libkernel-consumer.la \
-               $(top_builddir)/src/common/hashtable/libhashtable.la \
-               $(top_builddir)/src/common/compat/libcompat.la \
                $(top_builddir)/src/common/relayd/librelayd.la
 
 if HAVE_LIBLTTNG_UST_CTL
index ba002b6c35c4f4ce255373aa5cc7f8c5a9983e2d..6d70455c151f67426cc7494a1a1ab13035cab802 100644 (file)
@@ -1,9 +1,15 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-noinst_LTLIBRARIES = libhashtable.la
+noinst_LTLIBRARIES = libhashtable-gpl.la libhashtable-lgpl.la
 
-libhashtable_la_SOURCES = hashtable.c hashtable.h \
-                         utils.c utils.h \
-                         hashtable-symbols.h
+libhashtable_lgpl_la_SOURCES = \
+       seed.c \
+       utils.c \
+       utils.h
+
+libhashtable_gpl_la_LIBADD = -lurcu-common -lurcu -lurcu-cds
+libhashtable_gpl_la_SOURCES = \
+       hashtable.c \
+       hashtable.h \
+       hashtable-symbols.h
 
-libhashtable_la_LIBADD = -lurcu-common -lurcu -lurcu-cds
index d490096f8478e9c2c4248219b25636053630e30a..d10a839302e4bd00efb5850bb9ad4eb3e4edf670 100644 (file)
@@ -20,7 +20,6 @@
 /* seed_lock protects both seed_init and lttng_ht_seed. */
 static pthread_mutex_t seed_lock = PTHREAD_MUTEX_INITIALIZER;
 static bool seed_init;
-unsigned long lttng_ht_seed;
 
 static unsigned long min_hash_alloc_size = 1;
 static unsigned long max_hash_buckets_size = 0;
diff --git a/src/common/hashtable/seed.c b/src/common/hashtable/seed.c
new file mode 100644 (file)
index 0000000..24da1bc
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ */
+
+#define _LGPL_SOURCE
+#include "hashtable.h"
+#include "utils.h"
+
+unsigned long lttng_ht_seed;
index cf86e2a63256c69442c1b14719f8212699dcb166..0f9d8330bcf45693a52564161b4f65c03faf9226 100644 (file)
@@ -4,6 +4,4 @@ noinst_LTLIBRARIES = libkernel-consumer.la
 
 libkernel_consumer_la_SOURCES = kernel-consumer.c kernel-consumer.h
 
-libkernel_consumer_la_LIBADD = \
-                  $(top_builddir)/src/common/kernel-ctl/libkernel-ctl.la \
-                  $(top_builddir)/src/common/relayd/librelayd.la
+libkernel_consumer_la_LIBADD = $(top_builddir)/src/common/kernel-ctl/libkernel-ctl.la
index 5ab0fe60284bd7c6dfc5ba675ab13d3e8eb56213..914c00a2bb899a736213d3eea3e456f9f879fdfa 100644 (file)
@@ -6,8 +6,6 @@ noinst_LTLIBRARIES = libust-consumer.la
 
 libust_consumer_la_SOURCES = ust-consumer.c ust-consumer.h
 
-libust_consumer_la_LIBADD = \
-                       $(UST_CTL_LIBS) \
-                       $(top_builddir)/src/common/relayd/librelayd.la
+libust_consumer_la_LIBADD = $(UST_CTL_LIBS)
 
 endif
index 106b4027d395c384ab0a558c3b29f85c856d266b..da40b21607ec7adca313f3e3d29af6fb2156bfa9 100644 (file)
@@ -16,7 +16,7 @@ liblttng_ctl_la_LDFLAGS = \
 
 liblttng_ctl_la_LIBADD = \
                $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \
-               $(top_builddir)/src/common/libcommon-gpl.la \
+               $(top_builddir)/src/common/libcommon-lgpl.la \
                $(top_builddir)/src/lib/lttng-ctl/filter/libfilter.la
 
 pkgconfigdir = $(libdir)/pkgconfig
index e4c2dbe84d65c98482e039214d5def0dbb1adcb1..20010c80ad5bcc2125e97b8b56b1f9f829964fb4 100644 (file)
@@ -6,7 +6,7 @@ LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la
 
 LIBCOMMON_GPL=$(top_builddir)/src/common/libcommon-gpl.la
 LIBSESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
-LIBHASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la
+LIBHASHTABLE_GPL=$(top_builddir)/src/common/hashtable/libhashtable-gpl.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
@@ -25,7 +25,7 @@ endif
 
 live_test_SOURCES = live_test.c
 live_test_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBRELAYD) $(LIBSESSIOND_COMM) \
-               $(LIBHASHTABLE) $(LIBHEALTH) $(DL_LIBS) $(LIBCOMPAT) -lrt
+               $(LIBHASHTABLE_GPL) $(LIBHEALTH) $(DL_LIBS) $(LIBCOMPAT) -lrt
 live_test_LDADD += $(LIVE) \
                $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
 
index a46558635edb6bb9429c08e902a052998e514a1a..e1e60ff93319c68d7385ce083dfd0f07eeae414a 100644 (file)
@@ -29,7 +29,6 @@ LIBCOMMON_GPL=$(top_builddir)/src/common/libcommon-gpl.la
 LIBSTRINGUTILS=$(top_builddir)/src/common/string-utils/libstring-utils.la
 LIBFDTRACKER=$(top_builddir)/src/common/fd-tracker/libfd-tracker.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
 LIBLTTNG_CTL=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
 
@@ -48,7 +47,7 @@ endif
 
 # URI unit tests
 test_uri_SOURCES = test_uri.c
-test_uri_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBHASHTABLE) $(DL_LIBS)
+test_uri_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS)
 
 # Sessiond objects
 SESSIOND_OBJS = $(top_builddir)/src/bin/lttng-sessiond/buffer-registry.$(OBJEXT) \
@@ -82,7 +81,7 @@ SESSIOND_OBJS = $(top_builddir)/src/bin/lttng-sessiond/buffer-registry.$(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 \
+        $(top_builddir)/src/common/libcommon-gpl.la \
         $(top_builddir)/src/common/testpoint/libtestpoint.la \
         $(top_builddir)/src/common/compat/libcompat.la \
         $(top_builddir)/src/common/health/libhealth.la \
@@ -156,24 +155,24 @@ test_kernel_data_LDADD += $(KERN_DATA_TRACE)
 
 # parse_size_suffix unit test
 test_utils_parse_size_suffix_SOURCES = test_utils_parse_size_suffix.c
-test_utils_parse_size_suffix_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON_GPL) $(DL_LIBS)
+test_utils_parse_size_suffix_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS)
 
 # parse_time_suffix unit test
 test_utils_parse_time_suffix_SOURCES = test_utils_parse_time_suffix.c
-test_utils_parse_time_suffix_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON_GPL)
+test_utils_parse_time_suffix_LDADD = $(LIBTAP) $(LIBCOMMON_GPL)
 
 # compat_poll unit test
 test_utils_compat_poll_SOURCES = test_utils_compat_poll.c
-test_utils_compat_poll_LDADD  = $(LIBTAP) $(LIBHASHTABLE) $(DL_LIBS) \
+test_utils_compat_poll_LDADD  = $(LIBTAP) $(DL_LIBS) \
                      $(top_builddir)/src/common/compat/libcompat.la $(LIBCOMMON_GPL)
 
 # expand_path unit test
 test_utils_expand_path_SOURCES = test_utils_expand_path.c
-test_utils_expand_path_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON_GPL) $(DL_LIBS)
+test_utils_expand_path_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS)
 
 # directory handle unit test
 test_directory_handle_SOURCES = test_directory_handle.c
-test_directory_handle_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON_GPL) $(DL_LIBS)
+test_directory_handle_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS)
 
 # string utilities unit test
 test_string_utils_SOURCES = test_string_utils.c
@@ -190,7 +189,7 @@ test_relayd_backward_compat_group_by_session_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_s
 
 # fd tracker unit test
 test_fd_tracker_SOURCES = test_fd_tracker.c
-test_fd_tracker_LDADD = $(LIBTAP) $(LIBFDTRACKER) $(DL_LIBS) -lurcu $(LIBCOMMON_GPL) $(LIBHASHTABLE)
+test_fd_tracker_LDADD = $(LIBTAP) $(LIBFDTRACKER) $(DL_LIBS) -lurcu $(LIBCOMMON_GPL)
 
 # uuid unit test
 test_uuid_SOURCES = test_uuid.c
index 080b39ea32f166c984af505e3752ed2a19f51246..f4c0840793e3ec5e6c020aec9e40c5d536ef549b 100644 (file)
@@ -4,15 +4,13 @@ AM_CPPFLAGS += -I$(top_srcdir)/tests/utils/
 
 LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la
 LIBCOMMON_GPL=$(top_builddir)/src/common/libcommon-gpl.la
-LIBHASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la
 LIBLTTNG_CTL=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
 
 noinst_PROGRAMS = ini_config
 EXTRA_DIST = test_ini_config sample.ini
 
 ini_config_SOURCES = ini_config.c
-ini_config_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(LIBHASHTABLE)
-
+ini_config_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL)
 
 all-local:
        @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
This page took 0.035226 seconds and 5 git commands to generate.