perf tools: Move two variables usied in libperf from perf.c
authorSoramichi AKIYAMA <akiyama@m.soramichi.jp>
Mon, 16 Jan 2017 15:22:37 +0000 (00:22 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 17 Jan 2017 14:36:45 +0000 (11:36 -0300)
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>
tools/perf/Build
tools/perf/perf.c
tools/perf/ui/setup.c
tools/perf/util/Build
tools/perf/util/header.c

index 0b48806f93c270114d68b11aaf5fa3ad768d9ff7..7039ecb89170cc853c8a94eb367a1bafd9376d5c 100644 (file)
@@ -40,8 +40,7 @@ CFLAGS_builtin-help.o      += $(paths)
 CFLAGS_builtin-timechart.o += $(paths)
 CFLAGS_perf.o              += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))"      \
                              -DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))"   \
-                             -DPREFIX="BUILD_STR($(prefix_SQ))"                \
-                             -include $(OUTPUT)PERF-VERSION-FILE
+                             -DPREFIX="BUILD_STR($(prefix_SQ))"
 CFLAGS_builtin-trace.o    += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))"
 CFLAGS_builtin-report.o           += -DTIPDIR="BUILD_STR($(tipdir_SQ))"
 CFLAGS_builtin-report.o           += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"
index 13c8a7db055ed3c0cd12e13c0d2e2dada3998e34..0324cd15e42a6edb9ec574bf61e3499bc460f8dd 100644 (file)
@@ -29,7 +29,6 @@ const char perf_usage_string[] =
 const char perf_more_info_string[] =
        "See 'perf help COMMAND' for more information on a specific command.";
 
-int use_browser = -1;
 static int use_pager = -1;
 const char *input_name;
 
@@ -330,8 +329,6 @@ static int handle_alias(int *argcp, const char ***argv)
        return ret;
 }
 
-const char perf_version_string[] = PERF_VERSION;
-
 #define RUN_SETUP      (1<<0)
 #define USE_PAGER      (1<<1)
 
index 1f6b0994f4f4190c8498292771f4ecc3bb09c277..50d13e58210f0d7dc4b59421914317604757ac10 100644 (file)
@@ -7,6 +7,7 @@
 
 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
 void *perf_gtk_handle;
+int use_browser = -1;
 
 #ifdef HAVE_GTK2_SUPPORT
 static int setup_gtk_browser(void)
index 3840e3a870579e7ac8898306b881fb0f40ed00c0..5da376bc1afca6733664f798e0e9d3050dab6e21 100644 (file)
@@ -162,6 +162,7 @@ CFLAGS_rbtree.o        += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ET
 CFLAGS_libstring.o     += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_hweight.o       += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_parse-events.o  += -Wno-redundant-decls
+CFLAGS_header.o        += -include $(OUTPUT)PERF-VERSION-FILE
 
 $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
        $(call rule_mkdir)
index d89c9c7ef4e54ba6381c7b63d8db29c87328b3ea..00fd8a8850d3391545981b89ab74c97c62969af0 100644 (file)
@@ -41,6 +41,8 @@ static const u64 __perf_magic2_sw = 0x50455246494c4532ULL;
 
 #define PERF_MAGIC     __perf_magic2
 
+const char perf_version_string[] = PERF_VERSION;
+
 struct perf_file_attr {
        struct perf_event_attr  attr;
        struct perf_file_section        ids;