diff options
-rw-r--r-- | tools/perf/Makefile | 29 | ||||
-rw-r--r-- | tools/perf/config/feature-tests.mak | 25 |
2 files changed, 53 insertions, 1 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 27ae84bb5e4c..0aee6a916493 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -43,6 +43,8 @@ include config/utilities.mak | |||
43 | # | 43 | # |
44 | # Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds) | 44 | # Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds) |
45 | # | 45 | # |
46 | # Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf | ||
47 | # backtrace post unwind. | ||
46 | 48 | ||
47 | $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE | 49 | $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE |
48 | @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) | 50 | @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) |
@@ -64,6 +66,7 @@ AR = $(CROSS_COMPILE)ar | |||
64 | ifeq ($(ARCH),i386) | 66 | ifeq ($(ARCH),i386) |
65 | ARCH := x86 | 67 | ARCH := x86 |
66 | NO_PERF_REGS := 0 | 68 | NO_PERF_REGS := 0 |
69 | LIBUNWIND_LIBS = -lunwind -lunwind-x86 | ||
67 | endif | 70 | endif |
68 | ifeq ($(ARCH),x86_64) | 71 | ifeq ($(ARCH),x86_64) |
69 | ARCH := x86 | 72 | ARCH := x86 |
@@ -77,6 +80,7 @@ ifeq ($(ARCH),x86_64) | |||
77 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S | 80 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S |
78 | endif | 81 | endif |
79 | NO_PERF_REGS := 0 | 82 | NO_PERF_REGS := 0 |
83 | LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 | ||
80 | endif | 84 | endif |
81 | 85 | ||
82 | # Treat warnings as errors unless directed not to | 86 | # Treat warnings as errors unless directed not to |
@@ -97,7 +101,7 @@ ifdef PARSER_DEBUG | |||
97 | PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG | 101 | PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG |
98 | endif | 102 | endif |
99 | 103 | ||
100 | CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) | 104 | CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) |
101 | EXTLIBS = -lpthread -lrt -lelf -lm | 105 | EXTLIBS = -lpthread -lrt -lelf -lm |
102 | ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE | 106 | ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE |
103 | ALL_LDFLAGS = $(LDFLAGS) | 107 | ALL_LDFLAGS = $(LDFLAGS) |
@@ -476,6 +480,21 @@ ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y) | |||
476 | endif | 480 | endif |
477 | endif # NO_LIBELF | 481 | endif # NO_LIBELF |
478 | 482 | ||
483 | ifndef NO_LIBUNWIND | ||
484 | # for linking with debug library, run like: | ||
485 | # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ | ||
486 | ifdef LIBUNWIND_DIR | ||
487 | LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include | ||
488 | LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib | ||
489 | endif | ||
490 | |||
491 | FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(ALL_CFLAGS) $(LIBUNWIND_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) | ||
492 | ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND)),y) | ||
493 | msg := $(warning No libunwind found. Please install libunwind >= 0.99); | ||
494 | NO_LIBUNWIND := 1 | ||
495 | endif # Libunwind support | ||
496 | endif # NO_LIBUNWIND | ||
497 | |||
479 | -include arch/$(ARCH)/Makefile | 498 | -include arch/$(ARCH)/Makefile |
480 | 499 | ||
481 | ifneq ($(OUTPUT),) | 500 | ifneq ($(OUTPUT),) |
@@ -522,6 +541,14 @@ endif # PERF_HAVE_DWARF_REGS | |||
522 | endif # NO_DWARF | 541 | endif # NO_DWARF |
523 | endif # NO_LIBELF | 542 | endif # NO_LIBELF |
524 | 543 | ||
544 | ifdef NO_LIBUNWIND | ||
545 | BASIC_CFLAGS += -DNO_LIBUNWIND_SUPPORT | ||
546 | else | ||
547 | EXTLIBS += $(LIBUNWIND_LIBS) | ||
548 | BASIC_CFLAGS := $(LIBUNWIND_CFLAGS) $(BASIC_CFLAGS) | ||
549 | BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS) | ||
550 | endif | ||
551 | |||
525 | ifdef NO_NEWT | 552 | ifdef NO_NEWT |
526 | BASIC_CFLAGS += -DNO_NEWT_SUPPORT | 553 | BASIC_CFLAGS += -DNO_NEWT_SUPPORT |
527 | else | 554 | else |
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 6c18785a6417..2f1156a62ab7 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak | |||
@@ -154,3 +154,28 @@ int main(void) | |||
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
156 | endef | 156 | endef |
157 | |||
158 | ifndef NO_LIBUNWIND | ||
159 | define SOURCE_LIBUNWIND | ||
160 | #include <libunwind.h> | ||
161 | #include <stdlib.h> | ||
162 | |||
163 | extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, | ||
164 | unw_word_t ip, | ||
165 | unw_dyn_info_t *di, | ||
166 | unw_proc_info_t *pi, | ||
167 | int need_unwind_info, void *arg); | ||
168 | |||
169 | |||
170 | #define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) | ||
171 | |||
172 | int main(void) | ||
173 | { | ||
174 | unw_addr_space_t addr_space; | ||
175 | addr_space = unw_create_addr_space(NULL, 0); | ||
176 | unw_init_remote(NULL, addr_space, NULL); | ||
177 | dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL); | ||
178 | return 0; | ||
179 | } | ||
180 | endef | ||
181 | endif | ||