From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH] trace-cmd: Fix "multiple definition" compiler errors
Date: Mon, 10 Feb 2020 10:50:10 +0200 [thread overview]
Message-ID: <20200210085010.7974-1-tz.stoyanov@gmail.com> (raw)
When compiling with gcc and option "-fno-common", there are
errors because of multiple global variables with the same names.
The "-fno-common" gcc option is turned on by default on gcc 10, so
trace-cmd build fails on this compiler.
Problem in reported by Ziqian SUN (Zamir):
https://bugzilla.kernel.org/show_bug.cgi?id=206467
Proposed solution: set the variables to be static, as their scope is
only the current C file.
Reported-by: Ziqian SUN (Zamir) <sztsian@gmail.com>
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
tracecmd/trace-hist.c | 40 ++++++++++++++++++++--------------------
tracecmd/trace-mem.c | 38 +++++++++++++++++++-------------------
2 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/tracecmd/trace-hist.c b/tracecmd/trace-hist.c
index c451826..fdfd4a1 100644
--- a/tracecmd/trace-hist.c
+++ b/tracecmd/trace-hist.c
@@ -27,26 +27,26 @@ static int kernel_stack_type;
static int long_size;
-struct tep_format_field *common_type_field;
-struct tep_format_field *common_pid_field;
-struct tep_format_field *sched_wakeup_comm_field;
-struct tep_format_field *sched_wakeup_new_comm_field;
-struct tep_format_field *sched_wakeup_pid_field;
-struct tep_format_field *sched_wakeup_new_pid_field;
-struct tep_format_field *sched_switch_prev_field;
-struct tep_format_field *sched_switch_next_field;
-struct tep_format_field *sched_switch_prev_pid_field;
-struct tep_format_field *sched_switch_next_pid_field;
-struct tep_format_field *function_ip_field;
-struct tep_format_field *function_parent_ip_field;
-struct tep_format_field *function_graph_entry_func_field;
-struct tep_format_field *function_graph_entry_depth_field;
-struct tep_format_field *function_graph_exit_func_field;
-struct tep_format_field *function_graph_exit_depth_field;
-struct tep_format_field *function_graph_exit_calltime_field;
-struct tep_format_field *function_graph_exit_rettime_field;
-struct tep_format_field *function_graph_exit_overrun_field;
-struct tep_format_field *kernel_stack_caller_field;
+static struct tep_format_field *common_type_field;
+static struct tep_format_field *common_pid_field;
+static struct tep_format_field *sched_wakeup_comm_field;
+static struct tep_format_field *sched_wakeup_new_comm_field;
+static struct tep_format_field *sched_wakeup_pid_field;
+static struct tep_format_field *sched_wakeup_new_pid_field;
+static struct tep_format_field *sched_switch_prev_field;
+static struct tep_format_field *sched_switch_next_field;
+static struct tep_format_field *sched_switch_prev_pid_field;
+static struct tep_format_field *sched_switch_next_pid_field;
+static struct tep_format_field *function_ip_field;
+static struct tep_format_field *function_parent_ip_field;
+static struct tep_format_field *function_graph_entry_func_field;
+static struct tep_format_field *function_graph_entry_depth_field;
+static struct tep_format_field *function_graph_exit_func_field;
+static struct tep_format_field *function_graph_exit_depth_field;
+static struct tep_format_field *function_graph_exit_calltime_field;
+static struct tep_format_field *function_graph_exit_rettime_field;
+static struct tep_format_field *function_graph_exit_overrun_field;
+static struct tep_format_field *kernel_stack_caller_field;
static int compact;
diff --git a/tracecmd/trace-mem.c b/tracecmd/trace-mem.c
index 37046fd..5caeeb6 100644
--- a/tracecmd/trace-mem.c
+++ b/tracecmd/trace-mem.c
@@ -30,31 +30,31 @@ static int kmem_cache_alloc_type;
static int kmem_cache_alloc_node_type;
static int kmem_cache_free_type;
-struct tep_format_field *common_type_field;
+static struct tep_format_field *common_type_field;
-struct tep_format_field *kmalloc_callsite_field;
-struct tep_format_field *kmalloc_bytes_req_field;
-struct tep_format_field *kmalloc_bytes_alloc_field;
-struct tep_format_field *kmalloc_ptr_field;
+static struct tep_format_field *kmalloc_callsite_field;
+static struct tep_format_field *kmalloc_bytes_req_field;
+static struct tep_format_field *kmalloc_bytes_alloc_field;
+static struct tep_format_field *kmalloc_ptr_field;
-struct tep_format_field *kmalloc_node_callsite_field;
-struct tep_format_field *kmalloc_node_bytes_req_field;
-struct tep_format_field *kmalloc_node_bytes_alloc_field;
-struct tep_format_field *kmalloc_node_ptr_field;
+static struct tep_format_field *kmalloc_node_callsite_field;
+static struct tep_format_field *kmalloc_node_bytes_req_field;
+static struct tep_format_field *kmalloc_node_bytes_alloc_field;
+static struct tep_format_field *kmalloc_node_ptr_field;
-struct tep_format_field *kfree_ptr_field;
+static struct tep_format_field *kfree_ptr_field;
-struct tep_format_field *kmem_cache_callsite_field;
-struct tep_format_field *kmem_cache_bytes_req_field;
-struct tep_format_field *kmem_cache_bytes_alloc_field;
-struct tep_format_field *kmem_cache_ptr_field;
+static struct tep_format_field *kmem_cache_callsite_field;
+static struct tep_format_field *kmem_cache_bytes_req_field;
+static struct tep_format_field *kmem_cache_bytes_alloc_field;
+static struct tep_format_field *kmem_cache_ptr_field;
-struct tep_format_field *kmem_cache_node_callsite_field;
-struct tep_format_field *kmem_cache_node_bytes_req_field;
-struct tep_format_field *kmem_cache_node_bytes_alloc_field;
-struct tep_format_field *kmem_cache_node_ptr_field;
+static struct tep_format_field *kmem_cache_node_callsite_field;
+static struct tep_format_field *kmem_cache_node_bytes_req_field;
+static struct tep_format_field *kmem_cache_node_bytes_alloc_field;
+static struct tep_format_field *kmem_cache_node_ptr_field;
-struct tep_format_field *kmem_cache_free_ptr_field;
+static struct tep_format_field *kmem_cache_free_ptr_field;
static void *zalloc(size_t size)
{
--
2.24.1
reply other threads:[~2020-02-10 8:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200210085010.7974-1-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).