lib: compile liblttng-ctl as C++
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 6 Oct 2021 16:15:33 +0000 (12:15 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 17 Nov 2021 23:30:51 +0000 (18:30 -0500)
commit4bd69c5f1161cd065f487da0f4c1aa03a73c47e4
treeacd63ef2ccccc93fbc1a86440bd93f790adb4612
parent657d1bf105996bf8f6e13af697fb1112afa61b28
lib: compile liblttng-ctl as C++

Same as the previous commits, but compile the liblttng-ctl library as
C++ code (while still offering a C interface).

Some exported global variables (for example in deprecated-symbols.cpp)
have to be made non-const, otherwise we get:

      CXX      deprecated-symbols.lo
    /home/simark/src/lttng-tools/src/lib/lttng-ctl/deprecated-symbols.cpp:21:33: error: ‘visibility’ attribute ignored [-Werror=attributes]
       21 | LTTNG_EXPORT const char * const config_element_pid_tracker;
          |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~

I think this is related to the fact that const global variables
automatically have internal linkage in C++.

Despite using -export-symbols in src/lib/lttng-ctl/Makefile.am, some new
ELF symbols become exposed.  It could be related to this, in the ld man
page:

           --retain-symbols-file does not discard undefined symbols, or
           symbols needed for relocations.

One new symbol I see, for example, is `_Z16connect_sessiondv`.  Looking
at liblttng-ctl.so, I indeed see a relocation for this symbol:

    000000000010b778  0000053e00000007 R_X86_64_JUMP_SLOT 00000000000314a2 _Z16connect_sessiondv + 0

And that would explain why the linker keeps that symbol visible.  This
is related to the entry for this function in the procedure linkage
table. I'm not entirely sure why these functions didn't generate a PLT
entry in C, but do in C++.

To avoid these new symbols, build everything with -fvisibility=hidden
and -fvisibility-inlines-hidden, and tag functions we really want to
export with LTTNG_EXPORT, a new macro defined to
__attribute__((visibility("default"))).  This macro is publicly visible,
because it has to be used in distributed header files (although it's of
no use for users of liblttng-ctl).

Change-Id: Ie51bf0a2edfb87e5f46f9c39eed5309d9f8c41d6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
111 files changed:
configure.ac
include/Makefile.am
include/lttng/action/action.h
include/lttng/action/list.h
include/lttng/action/notify.h
include/lttng/action/path.h
include/lttng/action/rate-policy.h
include/lttng/action/rotate-session.h
include/lttng/action/snapshot-session.h
include/lttng/action/start-session.h
include/lttng/action/stop-session.h
include/lttng/channel.h
include/lttng/clear-handle.h
include/lttng/clear.h
include/lttng/condition/buffer-usage.h
include/lttng/condition/condition.h
include/lttng/condition/evaluation.h
include/lttng/condition/event-rule-matches.h
include/lttng/condition/session-consumed-size.h
include/lttng/condition/session-rotation.h
include/lttng/destruction-handle.h
include/lttng/domain.h
include/lttng/endpoint.h
include/lttng/error-query.h
include/lttng/event-expr.h
include/lttng/event-field-value.h
include/lttng/event-rule/event-rule.h
include/lttng/event-rule/jul-logging.h
include/lttng/event-rule/kernel-kprobe.h
include/lttng/event-rule/kernel-syscall.h
include/lttng/event-rule/kernel-tracepoint.h
include/lttng/event-rule/kernel-uprobe.h
include/lttng/event-rule/log4j-logging.h
include/lttng/event-rule/python-logging.h
include/lttng/event-rule/user-tracepoint.h
include/lttng/event.h
include/lttng/handle.h
include/lttng/health.h
include/lttng/kernel-probe.h
include/lttng/load.h
include/lttng/location.h
include/lttng/log-level-rule.h
include/lttng/lttng-error.h
include/lttng/lttng-export.h [new file with mode: 0644]
include/lttng/lttng.h
include/lttng/notification/channel.h
include/lttng/notification/notification.h
include/lttng/rotation.h
include/lttng/save.h
include/lttng/session-descriptor.h
include/lttng/session.h
include/lttng/snapshot.h
include/lttng/tracker.h
include/lttng/trigger/trigger.h
include/lttng/userspace-probe.h
src/bin/lttng-consumerd/lttng-consumerd.h
src/bin/lttng-sessiond/notification-thread.cpp
src/bin/lttng-sessiond/ust-sigbus.cpp
src/common/config/config-session-abi.h
src/common/config/session-config.c
src/common/consumer/consumer.h
src/common/error.h
src/common/filter/filter-lexer.l
src/common/filter/filter-symbols.h
src/common/hashtable/hashtable.h
src/common/index-allocator.h
src/common/lttng-elf.h
src/common/mi-lttng.c
src/common/mi-lttng.h
src/common/sessiond-comm/inet.h
src/common/spawn-viewer.h
src/common/ust-consumer/ust-consumer.c
src/lib/lttng-ctl/Makefile.am
src/lib/lttng-ctl/channel.c [deleted file]
src/lib/lttng-ctl/channel.cpp [new file with mode: 0644]
src/lib/lttng-ctl/clear.c [deleted file]
src/lib/lttng-ctl/clear.cpp [new file with mode: 0644]
src/lib/lttng-ctl/deprecated-symbols.c [deleted file]
src/lib/lttng-ctl/deprecated-symbols.cpp [new file with mode: 0644]
src/lib/lttng-ctl/destruction-handle.c [deleted file]
src/lib/lttng-ctl/destruction-handle.cpp [new file with mode: 0644]
src/lib/lttng-ctl/event.c [deleted file]
src/lib/lttng-ctl/event.cpp [new file with mode: 0644]
src/lib/lttng-ctl/load.c [deleted file]
src/lib/lttng-ctl/load.cpp [new file with mode: 0644]
src/lib/lttng-ctl/lttng-ctl-health.c [deleted file]
src/lib/lttng-ctl/lttng-ctl-health.cpp [new file with mode: 0644]
src/lib/lttng-ctl/lttng-ctl.c [deleted file]
src/lib/lttng-ctl/lttng-ctl.cpp [new file with mode: 0644]
src/lib/lttng-ctl/rotate.c [deleted file]
src/lib/lttng-ctl/rotate.cpp [new file with mode: 0644]
src/lib/lttng-ctl/save.c [deleted file]
src/lib/lttng-ctl/save.cpp [new file with mode: 0644]
src/lib/lttng-ctl/snapshot.c [deleted file]
src/lib/lttng-ctl/snapshot.cpp [new file with mode: 0644]
src/lib/lttng-ctl/tracker.c [deleted file]
src/lib/lttng-ctl/tracker.cpp [new file with mode: 0644]
tests/regression/tools/health/health_fail.c
tests/regression/tools/health/health_stall.c
tests/regression/tools/live/live_test.c
tests/regression/tools/notification/consumer_testpoints.c
tests/regression/tools/notification/sessiond_testpoints.c
tests/regression/ust/clock-override/lttng-ust-clock-override-test.c
tests/regression/ust/getcpu-override/lttng-ust-getcpu-override-test.c
tests/regression/ust/multi-lib/callsites.h
tests/regression/ust/ust-dl/libbar.h
tests/regression/ust/ust-dl/libfoo.h
tests/unit/test_kernel_data.cpp
tests/unit/test_ust_data.cpp
tests/unit/ust-sigbus.c
tests/utils/testapp/userspace-probe-elf-binary/foo.h
This page took 0.035077 seconds and 4 git commands to generate.