From e1d64b5c248be1da1734357816e029527d6a2cce Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 16 Jan 2020 14:34:47 -0500 Subject: [PATCH] Fix: build failure with -fno-common MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit GCC 10 will default to building with -fno-common, this inhibits the linker from merging multiple tentative definitions of a symbol in an archive. I'm not sure I understand what happen with the symbols in mi-lttng.h but a similar issue was adressed in: commit 4965f956f3ef47388fb4a1b2f8f504abfe31afe7 Author: Jérémie Galarneau Date: Fri May 22 12:53:30 2015 -0400 Fix: Mark MI and Config string declarations as extern This fixes a build issue with GCC 5.1 which would complain about these symbols being defined multiple times. Make sure these symbols are extern and defined only in one compile unit. For more information, see: https://gcc.gnu.org/gcc-10/porting_to.html Change-Id: I139c9695371836cb1011f9ce192080b602ed2fbc Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- src/bin/lttng-consumerd/lttng-consumerd.h | 2 +- src/bin/lttng-sessiond/ust-app.c | 4 ++ src/bin/lttng-sessiond/ust-app.h | 6 +-- src/common/mi-lttng.h | 58 +++++++++++------------ tests/regression/tools/live/live_test.c | 3 -- tests/unit/test_kernel_data.c | 4 -- tests/unit/test_session.c | 4 -- tests/unit/test_ust_data.c | 7 --- 8 files changed, 37 insertions(+), 51 deletions(-) diff --git a/src/bin/lttng-consumerd/lttng-consumerd.h b/src/bin/lttng-consumerd/lttng-consumerd.h index 6d18fdf88..dbbb83e87 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.h +++ b/src/bin/lttng-consumerd/lttng-consumerd.h @@ -23,7 +23,7 @@ #define NR_LTTNG_CONSUMER_READY 1 extern int lttng_consumer_ready; -const char *tracing_group_name; +extern const char *tracing_group_name; enum lttng_consumer_type lttng_consumer_get_type(void); diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 205fdad16..f7acbf190 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -45,6 +45,10 @@ #include "notification-thread-commands.h" #include "rotate.h" +struct lttng_ht *ust_app_ht; +struct lttng_ht *ust_app_ht_by_sock; +struct lttng_ht *ust_app_ht_by_notify_sock; + static int ust_app_flush_app_session(struct ust_app *app, struct ust_app_session *ua_sess); diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 4c8c3cc62..169fc0814 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -81,7 +81,7 @@ struct ust_register_msg { * Global applications HT used by the session daemon. This table is indexed by * PID using the pid_n node and pid value of an ust_app. */ -struct lttng_ht *ust_app_ht; +extern struct lttng_ht *ust_app_ht; /* * Global applications HT used by the session daemon. This table is indexed by @@ -89,13 +89,13 @@ struct lttng_ht *ust_app_ht; * * The 'sock' in question here is the 'command' socket. */ -struct lttng_ht *ust_app_ht_by_sock; +extern struct lttng_ht *ust_app_ht_by_sock; /* * Global applications HT used by the session daemon. This table is indexed by * socket using the notify_sock_n node and notify_sock value of an ust_app. */ -struct lttng_ht *ust_app_ht_by_notify_sock; +extern struct lttng_ht *ust_app_ht_by_notify_sock; /* Stream list containing ust_app_stream. */ struct ust_app_stream_list { diff --git a/src/common/mi-lttng.h b/src/common/mi-lttng.h index 0540a5ba9..db85c7ca3 100644 --- a/src/common/mi-lttng.h +++ b/src/common/mi-lttng.h @@ -110,8 +110,8 @@ extern const char * const mi_lttng_element_save; /* Strings related to load command */ extern const char * const mi_lttng_element_load; -LTTNG_HIDDEN const char * const mi_lttng_element_load_overrides; -LTTNG_HIDDEN const char * const mi_lttng_element_load_override_url; +LTTNG_HIDDEN extern const char * const mi_lttng_element_load_overrides; +LTTNG_HIDDEN extern const char * const mi_lttng_element_load_override_url; /* General element of mi_lttng */ extern const char * const mi_lttng_element_empty; @@ -186,40 +186,40 @@ extern const char * const mi_lttng_element_snapshot_session_name; extern const char * const mi_lttng_element_snapshots; /* String related to track/untrack command */ -const char * const mi_lttng_element_track_untrack_all_wildcard; +extern const char * const mi_lttng_element_track_untrack_all_wildcard; -LTTNG_HIDDEN const char * const mi_lttng_element_session_name; +LTTNG_HIDDEN extern const char * const mi_lttng_element_session_name; /* String related to rotate command */ -LTTNG_HIDDEN const char * const mi_lttng_element_rotation; -LTTNG_HIDDEN const char * const mi_lttng_element_rotate_status; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedules; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_periodic; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_periodic_time_us; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_size_threshold; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_result; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_results; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_state; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_local; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_local_absolute_path; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_host; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_control_port; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_data_port; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_protocol; -LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_relative_path; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotate_status; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedules; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_periodic; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_size_threshold; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_result; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_results; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_state; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_local; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_local_absolute_path; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_host; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_control_port; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_data_port; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_protocol; +LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_relative_path; /* String related to enum lttng_rotation_state */ -LTTNG_HIDDEN const char * const mi_lttng_rotation_state_str_ongoing; -LTTNG_HIDDEN const char * const mi_lttng_rotation_state_str_completed; -LTTNG_HIDDEN const char * const mi_lttng_rotation_state_str_expired; -LTTNG_HIDDEN const char * const mi_lttng_rotation_state_str_error; +LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_ongoing; +LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_completed; +LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_expired; +LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_error; /* String related to enum lttng_trace_archive_location_relay_protocol_type */ -LTTNG_HIDDEN const char * const mi_lttng_rotation_location_relay_protocol_str_tcp; +LTTNG_HIDDEN extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp; /* String related to add-context command */ LTTNG_HIDDEN extern const char * const mi_lttng_element_context_symbol; diff --git a/tests/regression/tools/live/live_test.c b/tests/regression/tools/live/live_test.c index 217c72af4..151e23fb6 100644 --- a/tests/regression/tools/live/live_test.c +++ b/tests/regression/tools/live/live_test.c @@ -51,9 +51,6 @@ #define NUM_TESTS 11 #define mmap_size 524288 -int ust_consumerd32_fd; -int ust_consumerd64_fd; - static int control_sock; struct live_session *session; diff --git a/tests/unit/test_kernel_data.c b/tests/unit/test_kernel_data.c index 412e4004f..132488051 100644 --- a/tests/unit/test_kernel_data.c +++ b/tests/unit/test_kernel_data.c @@ -38,10 +38,6 @@ int lttng_opt_quiet = 1; int lttng_opt_verbose; int lttng_opt_mi; -struct notification_thread_handle *notification_thread_handle; - -int ust_consumerd32_fd; -int ust_consumerd64_fd; static const char alphanum[] = "0123456789" diff --git a/tests/unit/test_session.c b/tests/unit/test_session.c index d01117809..c16695255 100644 --- a/tests/unit/test_session.c +++ b/tests/unit/test_session.c @@ -44,7 +44,6 @@ /* Number of TAP tests in this file */ #define NUM_TESTS 11 -struct health_app *health_sessiond; static struct ltt_session_list *session_list; /* For error.h */ @@ -52,9 +51,6 @@ int lttng_opt_quiet = 1; int lttng_opt_verbose = 0; int lttng_opt_mi; -int ust_consumerd32_fd; -int ust_consumerd64_fd; - static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index b4e927c9d..a900d1274 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -47,13 +47,6 @@ int lttng_opt_quiet = 1; int lttng_opt_verbose; int lttng_opt_mi; -int ust_consumerd32_fd; -int ust_consumerd64_fd; - -/* Global variables required by sessiond objects being linked-in */ -struct lttng_ht *agent_apps_ht_by_sock; -struct notification_thread_handle *notification_thread_handle; - static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -- 2.34.1