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>
Thu, 20 Jan 2022 19:45:05 +0000 (14:45 -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.cpp
src/common/hashtable/seed.cpp [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 0e8ec982ad660e57c5f827cd96ff30e35215f118..82df3e3753101867d8deb31ed894cfdb404d2c84 100644 (file)
@@ -10,7 +10,6 @@ lttng_consumerd_SOURCES = \
 
 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 f16a98d64a0aa2727e771b2fd64eb3d2230cd8e8..9fe11f287b7221dd24f4744df1bfb17ac5ddc510 100644 (file)
@@ -31,7 +31,6 @@ lttng_relayd_SOURCES = main.cpp lttng-relayd.h utils.h utils.cpp cmd.h \
 lttng_relayd_LDADD = $(URCU_LIBS) \
                $(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/compat/libcompat.la \
                $(top_builddir)/src/common/index/libindex.la \
                $(top_builddir)/src/common/health/libhealth.la \
index a7cbdc523fae0efca8babdb3cb5abee360d30afb..1ab26e0a093272daf15367b79ae0e4df8e4b90da 100644 (file)
@@ -72,7 +72,6 @@ liblttng_sessiond_common_la_LIBADD = $(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-gpl.la \
                $(top_builddir)/src/common/compat/libcompat.la \
                $(top_builddir)/src/common/relayd/librelayd.la \
index 8cd93af44b2f02237cae292e528146cfcdcc02c6..b7b59f95a9837615f2ec4d7dadd74e1325113d1c 100644 (file)
@@ -38,10 +38,14 @@ DIST_SUBDIRS = \
        argpar-utils
 
 # Common library
-noinst_LTLIBRARIES = libcommon-gpl.la
+noinst_LTLIBRARIES = libcommon-lgpl.la libcommon-gpl.la
 EXTRA_DIST = mi-lttng-4.1.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 = \
        actions/action.cpp \
        actions/list.cpp \
        actions/notify.cpp \
@@ -52,15 +56,12 @@ libcommon_gpl_la_SOURCES = \
        actions/stop-session.cpp \
        actions/rate-policy.cpp \
        buffer-view.h buffer-view.cpp \
-       common.h \
        conditions/buffer-usage.cpp \
        conditions/condition.cpp \
        conditions/event-rule-matches.cpp \
        conditions/session-consumed-size.cpp \
        conditions/session-rotation.cpp \
-       context.cpp context.h \
        credentials.cpp credentials.h \
-       daemonize.cpp daemonize.h \
        defaults.cpp \
        domain.cpp \
        dynamic-array.cpp dynamic-array.h \
@@ -69,7 +70,6 @@ libcommon_gpl_la_SOURCES = \
        error.cpp error.h \
        error-query.cpp \
        evaluation.cpp \
-       event.cpp \
        event-expr/event-expr.cpp \
        event-field-value.cpp \
        event-rule/event-rule.cpp \
@@ -81,54 +81,67 @@ libcommon_gpl_la_SOURCES = \
        event-rule/log4j-logging.cpp \
        event-rule/jul-logging.cpp \
        event-rule/python-logging.cpp \
-       filter.cpp filter.h \
        fd-handle.cpp fd-handle.h \
-       fs-handle.cpp fs-handle.h fs-handle-internal.h \
-       futex.cpp futex.h \
        kernel-probe.cpp \
-       index-allocator.cpp index-allocator.h \
        location.cpp \
        log-level-rule.cpp \
        mi-lttng.cpp mi-lttng.h \
        notification.cpp \
-       optional.h \
        payload.cpp payload.h \
        payload-view.cpp payload-view.h \
-       pipe.cpp pipe.h \
        readwrite.cpp readwrite.h \
        runas.cpp runas.h \
-       shm.cpp shm.h \
        session-descriptor.cpp \
        snapshot.cpp snapshot.h \
        spawn-viewer.cpp spawn-viewer.h \
+       thread.cpp thread.h \
        time.cpp \
-       trace-chunk.cpp trace-chunk.h \
-       trace-chunk-registry.h \
+       tracker.cpp tracker.h \
        trigger.cpp \
        unix.cpp unix.h \
        uri.cpp uri.h \
        userspace-probe.cpp \
-       utils.cpp utils.h \
-       uuid.cpp uuid.h \
-       thread.cpp thread.h \
-       tracker.cpp tracker.h \
-       waiter.cpp waiter.h
+       utils.cpp utils.h
 
 if HAVE_ELF_H
-libcommon_gpl_la_SOURCES += \
+libcommon_lgpl_la_SOURCES += \
        lttng-elf.cpp lttng-elf.h
 endif
 
-libcommon_gpl_la_LIBADD = \
+libcommon_lgpl_la_LIBADD = \
        $(top_builddir)/src/common/bytecode/libbytecode.la \
-       $(top_builddir)/src/common/config/libconfig.la \
-       $(top_builddir)/src/common/ini-config/libini-config.la \
        $(top_builddir)/src/common/compat/libcompat.la \
-       $(top_builddir)/src/common/hashtable/libhashtable.la \
-       $(top_builddir)/src/common/fd-tracker/libfd-tracker.la \
+       $(top_builddir)/src/common/config/libconfig.la \
        $(top_builddir)/src/common/filter/libfilter.la \
+       $(top_builddir)/src/common/hashtable/libhashtable-lgpl.la \
        $(top_builddir)/src/vendor/msgpack/libmsgpack.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.cpp context.h \
+       daemonize.cpp daemonize.h \
+       event.cpp \
+       filter.cpp filter.h \
+       fs-handle.cpp fs-handle.h fs-handle-internal.h \
+       futex.cpp futex.h \
+       index-allocator.cpp index-allocator.h \
+       optional.h \
+       pipe.cpp pipe.h \
+       shm.cpp shm.h \
+       trace-chunk.cpp trace-chunk.h \
+       trace-chunk-registry.h \
+       uuid.cpp uuid.h \
+       waiter.cpp waiter.h
+
+libcommon_gpl_la_LIBADD = \
+       libcommon-lgpl.la \
+       $(top_builddir)/src/common/ini-config/libini-config.la \
+       $(top_builddir)/src/common/hashtable/libhashtable-gpl.la \
+       $(top_builddir)/src/common/fd-tracker/libfd-tracker.la
+
 if BUILD_LIB_HEALTH
 SUBDIRS += health
 endif
@@ -181,8 +194,7 @@ noinst_HEADERS = \
 
 noinst_PROGRAMS = filter-grammar-test
 filter_grammar_test_SOURCES = filter-grammar-test.cpp
-filter_grammar_test_LDADD = \
-       libcommon-gpl.la
+filter_grammar_test_LDADD = libcommon-gpl.la
 
 all-local:
        @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
index ba3ecf1da3834879d9053d409cfee063d57e53d2..46810d116c51ca5ccb431ba1bbb23c898c4bfb4e 100644 (file)
@@ -18,8 +18,6 @@ libconsumer_la_SOURCES = \
 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 b14254b34f051a5cf5c1289a64c400b36691efee..f16b1b513d06a1b0e2bf46013c21e34b571fe86c 100644 (file)
@@ -1,12 +1,17 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-noinst_LTLIBRARIES = libhashtable.la
+noinst_LTLIBRARIES = libhashtable-gpl.la libhashtable-lgpl.la
 
-libhashtable_la_SOURCES = \
+libhashtable_lgpl_la_SOURCES = \
+       seed.cpp \
+       utils.cpp \
+       utils.h
+
+libhashtable_gpl_la_SOURCES = \
        hashtable.cpp \
        hashtable.h \
-       hashtable-symbols.h \
-        utils.cpp \
-       utils.h
+       hashtable-symbols.h
 
-libhashtable_la_LIBADD = $(URCU_LIBS) $(URCU_CDS_LIBS)
+libhashtable_gpl_la_LIBADD = \
+       $(URCU_LIBS) \
+       $(URCU_CDS_LIBS)
index 5ae7f26e0e0fbde4aa168dbf1a229ec6140f8b9b..c641dad3c8db2949e156dfd8f4ecd0a691508595 100644 (file)
@@ -19,7 +19,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.cpp b/src/common/hashtable/seed.cpp
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 b1184130efc9298d127f668c3d315aa8bdb85717..4e7205cbee1939f947f686a002f7e69fe6c73d1a 100644 (file)
@@ -6,6 +6,4 @@ libkernel_consumer_la_SOURCES = \
        kernel-consumer.cpp \
        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 26f1667857652ace298070da8e5c112b71072a68..5e100537209ffc8e03af71e5c02fb9009612ada6 100644 (file)
@@ -8,8 +8,6 @@ libust_consumer_la_SOURCES = \
        ust-consumer.cpp \
        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 590ed2fd8cf708bf33002140a50ea214793225f5..281806c1fcb31d76fecd3560e839a1255c03a921 100644 (file)
@@ -31,7 +31,7 @@ EXTRA_DIST = liblttng-ctl.sym
 
 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
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = lttng-ctl.pc
index dcbeba9a4b5dc6157137a4527b7e7225de359a41..494b982df1989ec0d4698b39f443f7b41c8176cd 100644 (file)
@@ -3,13 +3,6 @@
 AM_CPPFLAGS += -I$(top_srcdir)/tests/utils/ -I$(srcdir)
 
 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
-LIBRELAYD=$(top_builddir)/src/common/relayd/librelayd.la
-LIBHEALTH=$(top_builddir)/src/common/health/libhealth.la
-LIBCOMPAT=$(top_builddir)/src/common/compat/libcompat.la
 LIBLTTNG_SESSIOND_COMMON=$(top_builddir)/src/bin/lttng-sessiond/liblttng-sessiond-common.la
 
 noinst_PROGRAMS = live_test
index 6441e2efbdfbd77026a262c6cadf38b171183218..bcba28fdb0255f2b2c41f71a7df74054dfe986dc 100644 (file)
@@ -40,7 +40,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
 LIBLTTNG_SESSIOND_COMMON=$(top_builddir)/src/bin/lttng-sessiond/liblttng-sessiond-common.la
@@ -79,7 +78,7 @@ endif
 
 # URI unit tests
 test_uri_SOURCES = test_uri.cpp
-test_uri_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBHASHTABLE) $(DL_LIBS)
+test_uri_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(DL_LIBS)
 
 RELAYD_OBJS = $(top_builddir)/src/bin/lttng-relayd/backward-compatibility-group-by.$(OBJEXT)
 
@@ -104,15 +103,15 @@ test_kernel_data_LDADD = $(LIBTAP) $(LIBLTTNG_SESSIOND_COMMON) $(DL_LIBS)
 
 # parse_size_suffix unit test
 test_utils_parse_size_suffix_SOURCES = test_utils_parse_size_suffix.cpp
-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.cpp
-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.cpp
-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)
 
 # compat_pthread unit test
@@ -122,11 +121,11 @@ test_utils_compat_pthread_LDADD  = $(LIBTAP) \
 
 # expand_path unit test
 test_utils_expand_path_SOURCES = test_utils_expand_path.cpp
-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.cpp
-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.cpp
@@ -157,7 +156,7 @@ test_rate_policy_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBLTTNG_CTL) $(DL_LIBS) \
 
 # fd tracker unit test
 test_fd_tracker_SOURCES = test_fd_tracker.cpp
-test_fd_tracker_LDADD = $(LIBTAP) $(LIBFDTRACKER) $(DL_LIBS) $(URCU_LIBS) $(LIBCOMMON_GPL) $(LIBHASHTABLE)
+test_fd_tracker_LDADD = $(LIBTAP) $(LIBFDTRACKER) $(DL_LIBS) $(URCU_LIBS) $(LIBCOMMON_GPL)
 
 # uuid unit test
 test_uuid_SOURCES = test_uuid.cpp
index 76a6cb6bfae4ded9f2fe0ec0b1d23a377a3f4bc7..6bb88df485776d23621076dfb7ab0407ad7b990a 100644 (file)
@@ -4,13 +4,12 @@ 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
 
 noinst_PROGRAMS = ini_config
 EXTRA_DIST = test_ini_config sample.ini
 
 ini_config_SOURCES = ini_config.cpp
-ini_config_LDADD = $(LIBTAP) $(LIBCOMMON_GPL) $(LIBHASHTABLE)
+ini_config_LDADD = $(LIBTAP) $(LIBCOMMON_GPL)
 
 all-local:
        @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
This page took 0.033171 seconds and 4 git commands to generate.