Skip to content

Commit d25ed5d

Browse files
soramichiacmel
authored andcommitted
perf tools: Move two variables usied in libperf from perf.c
The use_browser and perf_version_string variables are both declared in perf.c but they are also referenced by other functions of libperf.a. Therefore a user linking an own main() with libperf.a must declare those two variables in their files even if the files never use the browser or the version information. This patch fixes this issue by moving use_browser and perf_version_string out of perf.c to some other files. Signed-off-by: Soramichi Akiyama <akiyama@m.soramichi.jp> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20170117002237.c1aec0ce3b4d675dca018deb@m.soramichi.jp Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 587782c commit d25ed5d

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎tools/perf/Build‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ CFLAGS_builtin-help.o += $(paths)
4040
CFLAGS_builtin-timechart.o += $(paths)
4141
CFLAGS_perf.o += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))" \
4242
-DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))" \
43-
-DPREFIX="BUILD_STR($(prefix_SQ))" \
44-
-include $(OUTPUT)PERF-VERSION-FILE
43+
-DPREFIX="BUILD_STR($(prefix_SQ))"
4544
CFLAGS_builtin-trace.o += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))"
4645
CFLAGS_builtin-report.o += -DTIPDIR="BUILD_STR($(tipdir_SQ))"
4746
CFLAGS_builtin-report.o += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"

‎tools/perf/perf.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const char perf_usage_string[] =
2929
const char perf_more_info_string[] =
3030
"See 'perf help COMMAND' for more information on a specific command.";
3131

32-
int use_browser = -1;
3332
static int use_pager = -1;
3433
const char *input_name;
3534

@@ -330,8 +329,6 @@ static int handle_alias(int *argcp, const char ***argv)
330329
return ret;
331330
}
332331

333-
const char perf_version_string[] = PERF_VERSION;
334-
335332
#define RUN_SETUP (1<<0)
336333
#define USE_PAGER (1<<1)
337334

‎tools/perf/ui/setup.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
99
void *perf_gtk_handle;
10+
int use_browser = -1;
1011

1112
#ifdef HAVE_GTK2_SUPPORT
1213
static int setup_gtk_browser(void)

‎tools/perf/util/Build‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ CFLAGS_rbtree.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ET
162162
CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
163163
CFLAGS_hweight.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
164164
CFLAGS_parse-events.o += -Wno-redundant-decls
165+
CFLAGS_header.o += -include $(OUTPUT)PERF-VERSION-FILE
165166

166167
$(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
167168
$(call rule_mkdir)

‎tools/perf/util/header.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ static const u64 __perf_magic2_sw = 0x50455246494c4532ULL;
4141

4242
#define PERF_MAGIC __perf_magic2
4343

44+
const char perf_version_string[] = PERF_VERSION;
45+
4446
struct perf_file_attr {
4547
struct perf_event_attr attr;
4648
struct perf_file_section ids;

0 commit comments

Comments
 (0)