tools/perf: Speed up the build system
cover tools/perf: Speed up the build system
About the purpose of this series, see the previous announcement at:
https://lkml.org/lkml/2013/10/7/199
This -v2 series addresses the review feedback from David Ahern and Jiri Olsa (thanks guys!).
If everything is fine with this series then I'll ask Arnaldo to pull the changes.
The changes can also be fetched from this tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git tmp.perf
(HEAD: c31cfd5dc9c3)
Thanks,
Ingo
================>
Ingo Molnar (52):
tools/perf: Standardize feature support define names to:
HAVE_{FEATURE}_SUPPORT
tools/perf/build: Add feature check core code tools/perf/build: Add 'autodep' functionality, generate feature test
dependencies automatically
tools/perf/build: Split out feature check: 'libnuma' tools/perf/build: Split out feature check: 'stackprotector-all' tools/perf/build: Split out feature check: 'stackprotector' tools/perf/build: Split out feature check: 'volatile-register-var' tools/perf/build: Split out feature check: 'fortify-source' tools/perf/build: Split out feature check: 'bionic' tools/perf/build: Clean up the libelf logic in config/Makefile tools/perf/build: Split out feature check: 'libelf' tools/perf/build: Split out feature check: 'glibc' tools/perf/build: Split out feature check: 'dwarf' tools/perf/build: Clean up the mmap logic in config/Makefile tools/perf/build: Split out feature check: 'libelf-mmap' tools/perf/build: Split out feature check: 'libelf-getphdrnum' tools/perf/build: Clean up the libunwind logic in config/Makefile tools/perf/build: Split out feature check: 'libunwind' tools/perf/build: Split out feature check: 'libaudit' tools/perf/build: Split out feature check: 'libslang' tools/perf/build: Split out feature check: 'gtk2' tools/perf/build: Split out feature check: 'gtk2-infobar' tools/perf/build: Split out feature check: 'libperl' tools/perf/build: Split out feature check: 'libpython' tools/perf/build: Split out feature check: 'libpython-version' tools/perf/build: Split out feature check: 'libbfd' tools/perf/build: Split out feature check: 'strlcpy' tools/perf/build: Split out feature check: 'on-exit' tools/perf/build: Split out feature check: 'backtrace' tools/perf: Clean up util/include/linux/compiler.h tools/perf: Turn strlcpy() into a __weak function tools/perf/build: Speed up auto-detection of features by adding a
'test-all' target
tools/perf/build: Speed up git-version test on re-make tools/perf/build: Speed up the final link
tools/perf: Fix double/triple-build of the feature detection logic
during 'make install' et al
tools/perf/build: Invoke feature-checks 'clean' target from the main
Makefile
tools/perf/build: Speed up auto-detection tools/perf/build: Improve printout-of auto-detected features tools/perf/build: Automatically build in parallel, based on number of
CPUs in the system
tools/perf/build: Flip Makefile.parallel and Makefile.perf tools/perf/build: Standardize the various messages output by parallel
make
tools/perf/build: Split out feature checks: 'liberty', 'liberty-z',
'cplus-demangle'
tools/perf/build: Remove unused config/feature-tests.mak tools/perf/build: Clean up various testcases tools/perf/build: Collapse the test-all.c testcase tools/perf/build: Pass through all targets to Makefile.perf tools/perf/build: Make sure autodep feature binaries honor the O=
setting
tools/perf/build: Exclude MAKEFLAGS from nested invocation tools/perf/build: Fix non-canonical directory names in O= tools/perf/build: Fix O=/some/dir perf.o type of targets tools/perf/build: Harmonize the style of the feature testcases tools/perf/build: Pass through LDFLAGS to feature tests
tools/perf/Documentation/Makefile | 17 +- tools/perf/Makefile | 841 ++--------------------------- tools/perf/Makefile.perf | 856 ++++++++++++++++++++++++++++++ tools/perf/arch/x86/include/perf_regs.h | 6 +- tools/perf/arch/x86/util/unwind.c | 4 +- tools/perf/bench/mem-memcpy-arch.h | 2 +- tools/perf/bench/mem-memcpy.c | 2 +- tools/perf/bench/mem-memset-arch.h | 2 +- tools/perf/bench/mem-memset.c | 2 +- tools/perf/builtin-bench.c | 4 +- tools/perf/builtin-inject.c | 2 +- tools/perf/builtin-probe.c | 14 +- tools/perf/builtin-record.c | 12 +- tools/perf/config/Makefile | 327 +++++++----- tools/perf/config/feature-checks/Makefile | 148 ++++++ tools/perf/config/feature-checks/test-all.c | 106 ++++ tools/perf/config/feature-checks/test-backtrace.c | 13 + tools/perf/config/feature-checks/test-bionic.c | 6 + tools/perf/config/feature-checks/test-cplus-demangle.c | 14 + tools/perf/config/feature-checks/test-dwarf.c | 10 + tools/perf/config/feature-checks/test-fortify-source.c | 6 + tools/perf/config/feature-checks/test-glibc.c | 8 + tools/perf/config/feature-checks/test-gtk2-infobar.c | 11 + tools/perf/config/feature-checks/test-gtk2.c | 10 + tools/perf/config/feature-checks/test-hello.c | 6 + tools/perf/config/feature-checks/test-libaudit.c | 10 + tools/perf/config/feature-checks/test-libbfd.c | 15 + tools/perf/config/feature-checks/test-libelf-getphdrnum.c | 8 + tools/perf/config/feature-checks/test-libelf-mmap.c | 8 + tools/perf/config/feature-checks/test-libelf.c | 8 + tools/perf/config/feature-checks/test-libnuma.c | 9 + tools/perf/config/feature-checks/test-libperl.c | 9 + tools/perf/config/feature-checks/test-libpython-version.c | 10 + tools/perf/config/feature-checks/test-libpython.c | 8 + tools/perf/config/feature-checks/test-libslang.c | 6 + tools/perf/config/feature-checks/test-libunwind.c | 27 + tools/perf/config/feature-checks/test-on-exit.c | 15 + tools/perf/config/feature-checks/test-stackprotector-all.c | 6 + tools/perf/config/feature-checks/test-stackprotector.c | 6 + tools/perf/config/feature-checks/test-volatile-register-var.c | 6 + tools/perf/config/feature-tests.mak | 246 --------- tools/perf/config/utilities.mak | 14 - tools/perf/perf.c | 4 +- tools/perf/ui/gtk/browser.c | 2 +- tools/perf/ui/gtk/gtk.h | 4 +- tools/perf/ui/gtk/util.c | 4 +- tools/perf/ui/ui.h | 4 +- tools/perf/util/annotate.h | 4 +- tools/perf/util/cache.h | 3 +- tools/perf/util/generate-cmdlist.sh | 4 +- tools/perf/util/hist.h | 4 +- tools/perf/util/include/dwarf-regs.h | 2 +- tools/perf/util/include/linux/compiler.h | 19 +- tools/perf/util/map.c | 2 +- tools/perf/util/path.c | 10 +- tools/perf/util/perf_regs.h | 4 +- tools/perf/util/probe-event.c | 4 +- tools/perf/util/probe-finder.h | 4 +- tools/perf/util/symbol-elf.c | 2 +- tools/perf/util/symbol.h | 8 +- tools/perf/util/unwind.h | 4 +- tools/perf/util/util.c | 4 +- 62 files changed, 1678 insertions(+), 1258 deletions(-) create mode 100644 tools/perf/Makefile.perf create mode 100644 tools/perf/config/feature-checks/Makefile create mode 100644 tools/perf/config/feature-checks/test-all.c create mode 100644 tools/perf/config/feature-checks/test-backtrace.c create mode 100644 tools/perf/config/feature-checks/test-bionic.c create mode 100644 tools/perf/config/feature-checks/test-cplus-demangle.c create mode 100644 tools/perf/config/feature-checks/test-dwarf.c create mode 100644 tools/perf/config/feature-checks/test-fortify-source.c create mode 100644 tools/perf/config/feature-checks/test-glibc.c create mode 100644 tools/perf/config/feature-checks/test-gtk2-infobar.c create mode 100644 tools/perf/config/feature-checks/test-gtk2.c create mode 100644 tools/perf/config/feature-checks/test-hello.c create mode 100644 tools/perf/config/feature-checks/test-libaudit.c create mode 100644 tools/perf/config/feature-checks/test-libbfd.c create mode 100644 tools/perf/config/feature-checks/test-libelf-getphdrnum.c create mode 100644 tools/perf/config/feature-checks/test-libelf-mmap.c create mode 100644 tools/perf/config/feature-checks/test-libelf.c create mode 100644 tools/perf/config/feature-checks/test-libnuma.c create mode 100644 tools/perf/config/feature-checks/test-libperl.c create mode 100644 tools/perf/config/feature-checks/test-libpython-version.c create mode 100644 tools/perf/config/feature-checks/test-libpython.c create mode 100644 tools/perf/config/feature-checks/test-libslang.c create mode 100644 tools/perf/config/feature-checks/test-libunwind.c create mode 100644 tools/perf/config/feature-checks/test-on-exit.c create mode 100644 tools/perf/config/feature-checks/test-stackprotector-all.c create mode 100644 tools/perf/config/feature-checks/test-stackprotector.c create mode 100644 tools/perf/config/feature-checks/test-volatile-register-var.c delete mode 100644 tools/perf/config/feature-tests.mak
Signature · 1 line
1.8.3.1
PATCH 1/52 tools/perf: Standardize feature support define names to: HAVE_{FEATURE}_SUPPORT
Standardize all the feature flags based on the HAVE_{FEATURE}_SUPPORT naming convention:
HAVE_ARCH_X86_64_SUPPORT HAVE_BACKTRACE_SUPPORT HAVE_CPLUS_DEMANGLE_SUPPORT HAVE_DWARF_SUPPORT HAVE_ELF_GETPHDRNUM_SUPPORT HAVE_GTK2_SUPPORT HAVE_GTK_INFO_BAR_SUPPORT HAVE_LIBAUDIT_SUPPORT HAVE_LIBELF_MMAP_SUPPORT HAVE_LIBELF_SUPPORT HAVE_LIBNUMA_SUPPORT HAVE_LIBUNWIND_SUPPORT HAVE_ON_EXIT_SUPPORT HAVE_PERF_REGS_SUPPORT HAVE_SLANG_SUPPORT HAVE_STRLCPY_SUPPORT
--- tools/perf/arch/x86/include/perf_regs.h | 6 +++--- tools/perf/arch/x86/util/unwind.c | 4 ++-- tools/perf/bench/mem-memcpy-arch.h | 2 +- tools/perf/bench/mem-memcpy.c | 2 +- tools/perf/bench/mem-memset-arch.h | 2 +- tools/perf/bench/mem-memset.c | 2 +- tools/perf/builtin-bench.c | 4 ++-- tools/perf/builtin-inject.c | 2 +- tools/perf/builtin-probe.c | 14 +++++++------- tools/perf/builtin-record.c | 12 ++++++------ tools/perf/config/Makefile | 54 ++++++++++++++++++++++++++--------------------------- tools/perf/perf.c | 4 ++-- tools/perf/ui/gtk/browser.c | 2 +- tools/perf/ui/gtk/gtk.h | 4 ++-- tools/perf/ui/gtk/util.c | 4 ++-- tools/perf/ui/ui.h | 4 ++-- tools/perf/util/annotate.h | 4 ++-- tools/perf/util/cache.h | 2 +- tools/perf/util/generate-cmdlist.sh | 4 ++-- tools/perf/util/hist.h | 4 ++-- tools/perf/util/include/dwarf-regs.h | 2 +- tools/perf/util/map.c | 2 +- tools/perf/util/path.c | 2 +- tools/perf/util/perf_regs.h | 4 ++-- tools/perf/util/probe-event.c | 4 ++-- tools/perf/util/probe-finder.h | 4 ++-- tools/perf/util/symbol-elf.c | 2 +- tools/perf/util/symbol.h | 8 ++++---- tools/perf/util/unwind.h | 4 ++-- tools/perf/util/util.c | 4 ++-- 30 files changed, 86 insertions(+), 86 deletions(-)
tools/perf/arch/x86/include/perf_regs.h +3 -3
@@ -5,7 +5,7 @@#include "../../util/types.h" #include <asm/perf_regs.h> -#ifndef ARCH_X86_64 +#ifndef HAVE_ARCH_X86_64_SUPPORT #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)#else #define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \
@@ -52,7 +52,7 @@ static inline const char *perf_reg_name(int id)return "FS" ;case PERF_REG_X86_GS :return "GS" ; -#ifdef ARCH_X86_64 +#ifdef HAVE_ARCH_X86_64_SUPPORT case PERF_REG_X86_R8 :return "R8" ;case PERF_REG_X86_R9 :
@@ -69,7 +69,7 @@ static inline const char *perf_reg_name(int id)return "R14" ;case PERF_REG_X86_R15 :return "R15" ; -#endif /* ARCH_X86_64 */ +#endif /* HAVE_ARCH_X86_64_SUPPORT */ default :return NULL ; }
tools/perf/arch/x86/util/unwind.c +2 -2
@@ -4,7 +4,7 @@#include "perf_regs.h" #include "../../util/unwind.h" -#ifdef ARCH_X86_64 +#ifdef HAVE_ARCH_X86_64_SUPPORT int unwind__arch_reg_id (int regnum) {int id;
@@ -108,4 +108,4 @@ int unwind__arch_reg_id(int regnum) return id; } -#endif /* ARCH_X86_64 */ +#endif /* HAVE_ARCH_X86_64_SUPPORT */
tools/perf/bench/mem-memcpy-arch.h +1 -1
@@ -1,5 +1,5 @@ -#ifdef ARCH_X86_64 +#ifdef HAVE_ARCH_X86_64_SUPPORT #define MEMCPY_FN (fn, name, desc) \ extern void *fn(void *, const void *, size_t);
tools/perf/bench/mem-memcpy.c +1 -1
@@ -58,7 +58,7 @@ struct routine routines[] = { {"default" ,"Default memcpy() provided by glibc" , memcpy }, -#ifdef ARCH_X86_64 +#ifdef HAVE_ARCH_X86_64_SUPPORT #define MEMCPY_FN(fn, name, desc) { name, desc, fn }, #include "mem-memcpy-x86-64-asm-def.h"
tools/perf/bench/mem-memset-arch.h +1 -1
@@ -1,5 +1,5 @@ -#ifdef ARCH_X86_64 +#ifdef HAVE_ARCH_X86_64_SUPPORT #define MEMSET_FN (fn, name, desc) \ extern void *fn(void *, int, size_t);
tools/perf/bench/mem-memset.c +1 -1
@@ -58,7 +58,7 @@ static const struct routine routines[] = { {"default" ,"Default memset() provided by glibc" , memset }, -#ifdef ARCH_X86_64 +#ifdef HAVE_ARCH_X86_64_SUPPORT #define MEMSET_FN(fn, name, desc) { name, desc, fn }, #include "mem-memset-x86-64-asm-def.h"
tools/perf/builtin-bench.c +2 -2
@@ -35,7 +35,7 @@ struct bench_suite {/* sentinel: easy for help */ #define suite_all { "all", "Test all benchmark suites", NULL } -#ifdef LIBNUMA_SUPPORT +#ifdef HAVE_LIBNUMA_SUPPORT static struct bench_suite numa_suites[] = { { "mem", "Benchmark for NUMA workloads",
@@ -80,7 +80,7 @@ struct bench_subsys { }; static struct bench_subsys subsystems[] = { -#ifdef LIBNUMA_SUPPORT +#ifdef HAVE_LIBNUMA_SUPPORT {"numa" ,"NUMA scheduling and MM behavior" , numa_suites },
tools/perf/builtin-inject.c +1 -1
@@ -231,7 +231,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,* account this as unresolved. */ }else { -#ifdef LIBELF_SUPPORT +#ifdef HAVE_LIBELF_SUPPORT pr_warning ("no symbols found in %s, maybe " "install a debug package?\n" , al.map->dso->long_name);
tools/perf/builtin-probe.c +7 -7
@@ -173,7 +173,7 @@ static int opt_set_target(const struct option *opt, const char *str,if (str && !params.target) {if (!strcmp (opt->long_name,"exec" )) params.uprobes = true; -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORT else if (!strcmp(opt->long_name, "module")) params.uprobes = false;#endif
@@ -187,7 +187,7 @@ static int opt_set_target(const struct option *opt, const char *str,return ret; } -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORT static int opt_show_lines (const struct option *opt__maybe_unused ,const char *str,int unset__maybe_unused ) {
@@ -257,7 +257,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)"perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]" ,"perf probe [<options>] --del '[GROUP:]EVENT' ..." ,"perf probe --list" , -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORT"perf probe [<options>] --line 'LINEDESC'" , "perf probe [<options>] --vars 'PROBEPOINT'", #endif
@@ -271,7 +271,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)OPT_CALLBACK ('d' ,"del" ,NULL ,"[GROUP:]EVENT" ,"delete a probe event." , opt_del_probe_event), OPT_CALLBACK('a', "add", NULL, -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORT "[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT" " [[NAME=]ARG ...]", #else
@@ -283,7 +283,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)"\t\tFUNC:\tFunction name\n" "\t\tOFF:\tOffset from function entry (in byte)\n" "\t\t%return:\tPut the probe at function return\n" -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORT"\t\tSRC:\tSource code path\n" "\t\tRL:\tRelative line number from function entry.\n" "\t\tAL:\tAbsolute line number in file.\n"
@@ -296,7 +296,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) opt_add_probe_event),OPT_BOOLEAN ('f' ,"force" , ¶ms.force_add,"forcibly add events" " with existing name" ), -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORTOPT_CALLBACK ('L' ,"line" ,NULL ,"FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]" , "Show source code lines.", opt_show_lines),
@@ -408,7 +408,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)return ret; } -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORT if (params.show_lines && !params.uprobes) {if (params.mod_events) { pr_err(" Error: Don't use --line with"
tools/perf/builtin-record.c +6 -6
@@ -29,7 +29,7 @@#include <sched.h> #include <sys/mman.h> -#ifndef HAVE_ON_EXIT +#ifndef HAVE_ON_EXIT_SUPPORT #ifndef ATEXIT_MAX #define ATEXIT_MAX 32#endif
@@ -687,7 +687,7 @@ error:return ret; } -#ifdef LIBUNWIND_SUPPORT +#ifdef HAVE_LIBUNWIND_SUPPORT static int get_stack_size (char *str,unsigned long *_size) {char *endptr;
@@ -713,7 +713,7 @@ static int get_stack_size(char *str, unsigned long *_size) max_size, str); return -1; } -#endif /* LIBUNWIND_SUPPORT */ +#endif /* HAVE_LIBUNWIND_SUPPORT */ int record_parse_callchain_opt (const struct option *opt,const char *arg,int unset)
@@ -751,7 +751,7 @@ int record_parse_callchain_opt(const struct option *opt, "needed for -g fp\n");break ; -#ifdef LIBUNWIND_SUPPORT +#ifdef HAVE_LIBUNWIND_SUPPORT /* Dwarf style */ }else if (!strncmp (name,"dwarf" ,sizeof ("dwarf" ))) {const unsigned long default_stack_dump_size =8192 ;
@@ -771,7 +771,7 @@ int record_parse_callchain_opt(const struct option *opt,if (!ret)pr_debug ("callchain: stack dump size %d\n" , opts->stack_dump_size); -#endif /* LIBUNWIND_SUPPORT */ +#endif /* HAVE_LIBUNWIND_SUPPORT */ }else {pr_err ("callchain: Unknown -g option " "value: %s\n" , arg);
@@ -818,7 +818,7 @@ static struct perf_record record = {#define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " -#ifdef LIBUNWIND_SUPPORT +#ifdef HAVE_LIBUNWIND_SUPPORT const char record_callchain_help[] =CALLCHAIN_HELP "[fp] dwarf" ;#else const char record_callchain_help[] =CALLCHAIN_HELP "[fp]" ;
tools/perf/config/Makefile +27 -27
145 lines not on this page · raw message
tools/perf/perf.c +2 -2
@@ -49,14 +49,14 @@ static struct cmd_struct commands[] = { { "version", cmd_version, 0 }, { "script", cmd_script, 0 }, { "sched", cmd_sched, 0 }, -#ifdef LIBELF_SUPPORT +#ifdef HAVE_LIBELF_SUPPORT { "probe", cmd_probe, 0 }, #endif { "kmem", cmd_kmem, 0 }, { "lock", cmd_lock, 0 }, { "kvm", cmd_kvm, 0 }, { "test", cmd_test, 0 }, -#ifdef LIBAUDIT_SUPPORT +#ifdef HAVE_LIBAUDIT_SUPPORT { "trace", cmd_trace, 0 }, #endif { "inject", cmd_inject, 0 },
tools/perf/ui/gtk/browser.c +1 -1
@@ -43,7 +43,7 @@ const char *perf_gtk__get_percent_color(double percent)return NULL ; } -#ifdef HAVE_GTK_INFO_BAR +#ifdef HAVE_GTK_INFO_BAR_SUPPORT GtkWidget *perf_gtk__setup_info_bar (void ) {GtkWidget *info_bar;
tools/perf/ui/gtk/gtk.h +2 -2
@@ -12,7 +12,7 @@ struct perf_gtk_context {GtkWidget *main_window;GtkWidget *notebook; -#ifdef HAVE_GTK_INFO_BAR +#ifdef HAVE_GTK_INFO_BAR_SUPPORT GtkWidget *info_bar;GtkWidget *message_label;#endif
@@ -39,7 +39,7 @@ void perf_gtk__resize_window(GtkWidget *window);const char *perf_gtk__get_percent_color (double percent);GtkWidget *perf_gtk__setup_statusbar (void ); -#ifdef HAVE_GTK_INFO_BAR +#ifdef HAVE_GTK_INFO_BAR_SUPPORT GtkWidget *perf_gtk__setup_info_bar (void );#else static inline GtkWidget *perf_gtk__setup_info_bar (void )
tools/perf/ui/gtk/util.c +2 -2
@@ -53,7 +53,7 @@ static int perf_gtk__error(const char *format, va_list args)return 0 ; } -#ifdef HAVE_GTK_INFO_BAR +#ifdef HAVE_GTK_INFO_BAR_SUPPORT static int perf_gtk__warning_info_bar (const char *format,va_list args) {char *msg;
@@ -105,7 +105,7 @@ static int perf_gtk__warning_statusbar(const char *format, va_list args)struct perf_error_ops perf_gtk_eops = { .error = perf_gtk__error, -#ifdef HAVE_GTK_INFO_BAR +#ifdef HAVE_GTK_INFO_BAR_SUPPORT .warning = perf_gtk__warning_info_bar, #else .warning = perf_gtk__warning_statusbar,
tools/perf/ui/ui.h +2 -2
@@ -12,7 +12,7 @@ extern int use_browser;void setup_browser (bool fallback_to_pager);void exit_browser (bool wait_for_ok); -#ifdef SLANG_SUPPORT +#ifdef HAVE_SLANG_SUPPORT int ui__init (void );void ui__exit (bool wait_for_ok);#else
@@ -23,7 +23,7 @@ static inline int ui__init(void)static inline void ui__exit (bool wait_for_ok__maybe_unused ) {}#endif -#ifdef GTK2_SUPPORT +#ifdef HAVE_GTK2_SUPPORT int perf_gtk__init (void );void perf_gtk__exit (bool wait_for_ok);#else
tools/perf/util/annotate.h +2 -2
@@ -150,7 +150,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, struct perf_evsel *evsel, bool print_lines, bool full_paths, int min_pcnt, int max_lines); -#ifdef SLANG_SUPPORT +#ifdef HAVE_SLANG_SUPPORT int symbol__tui_annotate (struct symbol *sym,struct map *map,struct perf_evsel *evsel,struct hist_browser_timer *hbt);
@@ -165,7 +165,7 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, }#endif -#ifdef GTK2_SUPPORT +#ifdef HAVE_GTK2_SUPPORT int symbol__gtk_annotate (struct symbol *sym,struct map *map,struct perf_evsel *evsel,struct hist_browser_timer *hbt);
tools/perf/util/cache.h +1 -1
@@ -70,7 +70,7 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2extern char *perf_pathdup (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); -#ifndef HAVE_STRLCPY +#ifndef HAVE_STRLCPY_SUPPORT extern size_t strlcpy (char *dest,const char *src,size_t size);#endif
tools/perf/util/generate-cmdlist.sh +2 -2
@@ -22,7 +22,7 @@ do }' "Documentation/perf-$cmd.txt" done -echo "#ifdef LIBELF_SUPPORT" +echo "#ifdef HAVE_LIBELF_SUPPORT" sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt | sort | while read cmd
@@ -35,5 +35,5 @@ do p }' "Documentation/perf-$cmd.txt" done -echo "#endif /* LIBELF_SUPPORT */" +echo "#endif /* HAVE_LIBELF_SUPPORT */" echo "};"
tools/perf/util/hist.h +2 -2
@@ -187,7 +187,7 @@ struct hist_browser_timer {int refresh; }; -#ifdef SLANG_SUPPORT +#ifdef HAVE_SLANG_SUPPORT #include "../ui/keysyms.h" int hist_entry__tui_annotate (struct hist_entry *he,struct perf_evsel *evsel,struct hist_browser_timer *hbt);
@@ -228,7 +228,7 @@ static inline int script_browse(const char *script_opt __maybe_unused)#define K_SWITCH_INPUT_DATA -3000#endif -#ifdef GTK2_SUPPORT +#ifdef HAVE_GTK2_SUPPORT int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help,struct hist_browser_timer *hbt__maybe_unused ,float min_pcnt);
tools/perf/util/include/dwarf-regs.h +1 -1
@@ -1,7 +1,7 @@#ifndef _PERF_DWARF_REGS_H_#define _PERF_DWARF_REGS_H_ -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORT const char *get_arch_regstr (unsigned int n);#endif
tools/perf/util/map.c +1 -1
@@ -172,7 +172,7 @@ int map__load(struct map *map, symbol_filter_t filter)pr_warning (", continuing without symbols\n" );return -1 ; }else if (nr ==0 ) { -#ifdef LIBELF_SUPPORT +#ifdef HAVE_LIBELF_SUPPORT const size_t len =strlen (name);const size_t real_len = len -sizeof (DSO__DELETED );
tools/perf/util/path.c +1 -1
@@ -22,7 +22,7 @@ static const char *get_perf_dir(void)return "." ; } -#ifndef HAVE_STRLCPY +#ifndef HAVE_STRLCPY_SUPPORT size_t strlcpy (char *dest,const char *src,size_t size) {size_t ret =strlen (src);
tools/perf/util/perf_regs.h +2 -2
@@ -1,7 +1,7 @@#ifndef __PERF_REGS_H#define __PERF_REGS_H -#ifdef HAVE_PERF_REGS +#ifdef HAVE_PERF_REGS_SUPPORT #include <perf_regs.h> #else #define PERF_REGS_MASK 0
@@ -10,5 +10,5 @@ static inline const char *perf_reg_name(int id __maybe_unused) {return NULL ; } -#endif /* HAVE_PERF_REGS */ +#endif /* HAVE_PERF_REGS_SUPPORT */ #endif /* __PERF_REGS_H */
tools/perf/util/probe-event.c +2 -2
@@ -201,7 +201,7 @@ static int convert_to_perf_probe_point(struct probe_trace_point *tp,return 0 ; } -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORT /* Open new debuginfo of given module */ static struct debuginfo *open_debuginfo (const char *module) {
@@ -630,7 +630,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, return ret; } -#else /* !DWARF_SUPPORT */ +#else /* !HAVE_DWARF_SUPPORT */ static int kprobe_convert_to_perf_probe (struct probe_trace_point *tp,struct perf_probe_point *pp)
tools/perf/util/probe-finder.h +2 -2
@@ -14,7 +14,7 @@ static inline int is_c_varname(const char *name)return isalpha (name[0 ]) || name[0 ] =='_' ; } -#ifdef DWARF_SUPPORT +#ifdef HAVE_DWARF_SUPPORT #include "dwarf-aux.h"
@@ -105,6 +105,6 @@ struct line_finder {int found; }; -#endif /* DWARF_SUPPORT */ +#endif /* HAVE_DWARF_SUPPORT */ #endif /*_PROBE_FINDER_H */
tools/perf/util/symbol-elf.c +1 -1
@@ -8,7 +8,7 @@#include "symbol.h" #include "debug.h" -#ifndef HAVE_ELF_GETPHDRNUM +#ifndef HAVE_ELF_GETPHDRNUM_SUPPORT static int elf_getphdrnum (Elf *elf,size_t *dst) {GElf_Ehdr gehdr;
tools/perf/util/symbol.h +4 -4
@@ -13,7 +13,7 @@#include <libgen.h> #include "build-id.h" -#ifdef LIBELF_SUPPORT +#ifdef HAVE_LIBELF_SUPPORT #include <libelf.h> #include <gelf.h> #endif
@@ -21,7 +21,7 @@#include "dso.h" -#ifdef HAVE_CPLUS_DEMANGLE +#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT extern char *cplus_demangle (const char *,int );static inline char *bfd_demangle (void __maybe_unused *v,const char *c,int i)
@@ -46,7 +46,7 @@ static inline char *bfd_demangle(void __maybe_unused *v,* libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; * for newer versions we can use mmap to reduce memory usage: */ -#ifdef LIBELF_MMAP +#ifdef HAVE_LIBELF_MMAP_SUPPORT # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP#else # define PERF_ELF_C_READ_MMAP ELF_C_READ
@@ -178,7 +178,7 @@ struct symsrc {int fd;enum dso_binary_type type; -#ifdef LIBELF_SUPPORT +#ifdef HAVE_LIBELF_SUPPORT Elf *elf;GElf_Ehdr ehdr;
tools/perf/util/unwind.h +2 -2
@@ -13,7 +13,7 @@ struct unwind_entry {typedef int (*unwind_entry_cb_t )(struct unwind_entry *entry,void *arg); -#ifdef LIBUNWIND_SUPPORT +#ifdef HAVE_LIBUNWIND_SUPPORT int unwind__get_entries(unwind_entry_cb_t cb, void *arg, struct machine *machine, struct thread *thread,
@@ -31,5 +31,5 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, {return 0 ; } -#endif /* LIBUNWIND_SUPPORT */ +#endif /* HAVE_LIBUNWIND_SUPPORT */ #endif /* __UNWIND_H */
tools/perf/util/util.c +2 -2
@@ -1,7 +1,7 @@#include "../perf.h" #include "util.h" #include <sys/mman.h> -#ifdef BACKTRACE_SUPPORT +#ifdef HAVE_BACKTRACE_SUPPORT #include <execinfo.h> #endif #include <stdio.h>
@@ -204,7 +204,7 @@ int hex2u64(const char *ptr, u64 *long_val) }/* Obtain a backtrace and print it to stdout. */ -#ifdef BACKTRACE_SUPPORT +#ifdef HAVE_BACKTRACE_SUPPORT void dump_stack (void ) {void *array[16 ];
Signature · 1 line
1.8.3.1
PATCH 2/52 tools/perf/build: Add feature check core code
In reply to Ingo MolnarStart the split-out of the feature check code by adding a list of features to be tested, and rules to process that list by building its matching feature-check file in config/feature-checks/test-<feature>.c.
Add 'hello' as the initial feature.
This structure will allow us to build split-out feature checks in parallel and thus speed up feature detection dramatically.
No change in functionality: no feature check is used by the build rules yet.
--- tools/perf/config/Makefile | 16 ++++++++++++++++ tools/perf/config/feature-checks/Makefile | 16 ++++++++++++++++ tools/perf/config/feature-checks/test-hello.c | 6 ++++++ 3 files changed, 38 insertions(+)
tools/perf/config/Makefile +16 -0
@@ -89,6 +89,22 @@ CFLAGS += -std=gnu99 EXTLIBS = -lelf -lpthread -lrt -lm -ldl +feature_check = $(eval $(feature_check_code)); $(info CHK: config/feature-checks/test-$(1)) +define feature_check_code + feature-$(2) := $(shell make -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) +endef + +# +# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: +# +$(info Testing features:) +$(shell make -i -j -C config/feature-checks >/dev/null 2>&1) +$(info done) + +FEATURE_TESTS = hello + +$(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test))) + ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) CFLAGS += -fstack-protector-all endif
tools/perf/config/feature-checks/Makefile new file +16 -0
@@ -0,0 +1,16 @@ + +FILES=test-hello + +all: $(FILES) + +BUILD = $(CC) -o $(OUTPUT)$@ [email protected] + +############################### + +test-hello: test-hello.c + $(BUILD) + +############################### + +clean: + rm -f $(FILES)
tools/perf/config/feature-checks/test-hello.c new file +6 -0
@@ -0,0 +1,6 @@ +#include <stdio.h> + +int main (void ) +{ +return puts ("hi" ); +}
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 02/52] tools/perf/build: Add feature check core code
Hi Ingo,
Quoted 5 lines · Ingo Molnar
tools/perf/config/Makefile +5
-0+feature_check = $(eval $(feature_check_code)); $(info CHK: config/feature-checks/test-$(1)) +define feature_check_code + feature-$(2) := $(shell make -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) +endef +
tools/perf/config/Makefile CFLAGS += -std=gnu99 · line 106
Quoted 10 lines
tools/perf/config/Makefile +10
-0+# +# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: +# +$(info Testing features:) +$(shell make -i -j -C config/feature-checks >/dev/null 2>&1) +$(info done) + +FEATURE_TESTS = hello + +$(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
So as far as I can see, all the feature checking goes twice - once in $(shell make ...) and another in $(foreach test,...). They look like doing exactly same thing. And the final Makefile in this series still has it twice. Is it intentional or did I miss something?
Thanks,
Namhyung
Re: [PATCH 02/52] tools/perf/build: Add feature check core code
Quoted 15 lines · Namhyung Kim
Hi Ingo,
Quoted 12 lines · Ingo Molnar
tools/perf/config/Makefile +12
-0+feature_check = $(eval $(feature_check_code)); $(info CHK: config/feature-checks/test-$(1)) +define feature_check_code + feature-$(2) := $(shell make -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) +endef + +# +# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: +# +$(info Testing features:) +$(shell make -i -j -C config/feature-checks >/dev/null 2>&1) +$(info done) +
Quoted 8 lines
tools/perf/config/Makefile CFLAGS += -std=gnu99 · line 106
Quoted 3 lines
tools/perf/config/Makefile +3
-0+FEATURE_TESTS = hello + +$(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))So as far as I can see, all the feature checking goes twice - once in $(shell make ...) and another in $(foreach test,...). They look like doing exactly same thing. And the final
Makefilein this series still has it twice. Is it intentional or did I miss something?
Yes - and this is a performance trick.
The first run is to build them all in parallel:
$(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
Note how we build in parallel (-j), ignore errors (-i) and suppress all output.
This is very fast even if all testcases are rebuilt, but we cannot possibly recover which feature test failed.
So we run it once more, this time serially, and recover the test results. The vast majority of testcases will pass, and the repeat build will do, in essence:
comet:~/tip/tools/perf/config/feature-checks> perf stat --null --repeat 10 make test-libelf >/dev/null
Performance counter stats for 'make test-libelf' (10 runs):
0.014682647 seconds time elapsed ( +- 0.14% )
so it's just 14 msecs to recover each testcase result.
In theory we could optimize this further, by generating an actual test success/failure file via the initial parallel make attempt, and recovering those flags via the serial loop. That should be even faster.
Thanks,
Ingo
Namhyung Kim
maintainerRe: [PATCH 02/52] tools/perf/build: Add feature check core code
Quoted 42 lines · Ingo Molnar
Quoted 15 lines · Namhyung Kim
Hi Ingo,
Quoted 12 lines · Ingo Molnar
tools/perf/config/Makefile +12
-0+feature_check = $(eval $(feature_check_code)); $(info CHK: config/feature-checks/test-$(1)) +define feature_check_code + feature-$(2) := $(shell make -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) +endef + +# +# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: +# +$(info Testing features:) +$(shell make -i -j -C config/feature-checks >/dev/null 2>&1) +$(info done) +Quoted 8 lines
tools/perf/config/Makefile CFLAGS += -std=gnu99 · line 106
Quoted 3 lines
tools/perf/config/Makefile +3
-0+FEATURE_TESTS = hello + +$(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))So as far as I can see, all the feature checking goes twice - once in $(shell make ...) and another in $(foreach test,...). They look like doing exactly same thing. And the final
Makefilein this series still has it twice. Is it intentional or did I miss something?Yes - and this is a performance trick.
The first run is to build them all in parallel:
$(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
Note how we build in parallel (-j), ignore errors (-i) and suppress all output.
This is very fast even if all testcases are rebuilt, but we cannot possibly recover which feature test failed.
So we run it once more, this time serially, and recover the test results. The vast majority of testcases will pass, and the repeat build will do, in essence:
Quoted 7 lines
comet:~/tip/tools/perf/config/feature-checks> perf stat --null --repeat 10 make test-libelf >/dev/null
Performance counter stats for 'make test-libelf' (10 runs):
0.014682647 seconds time elapsed ( +- 0.14% )
so it's just 14 msecs to recover each testcase result.
Okay, got it. Thanks for the explanation! :)
Quoted 4 lines
In theory we could optimize this further, by generating an actual test success/failure file via the initial parallel make attempt, and recovering those flags via the serial loop. That should be even faster.
Well, I think it's already fast enough. ;)
Thanks,
Namhyung
PATCH 3/52 tools/perf/build: Add 'autodep' functionality, generate feature test dependencies automatically
In reply to Ingo MolnarUse GCC's -MD feature to generate a dependency file for each feature test .c file, and include that .d file in the config/feature-checks/Makefile.
This allows us to do two things:
- speed up feature tests
- detect removal or changes in build dependencies - including system libraries/headers
--- tools/perf/config/feature-checks/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/perf/config/feature-checks/Makefile +6 -2
@@ -1,16 +1,20 @@ FILES=test-hello +CC := $(CC) -MD + all: $(FILES) BUILD = $(CC) -o $(OUTPUT)$@ [email protected] ############################### -test-hello: test-hello.c +test-hello: $(BUILD) +-include *.d */*.d + ############################### clean: - rm -f $(FILES) + rm -f $(FILES) *.d
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 03/52] tools/perf/build: Add 'autodep' functionality, generate feature test dependencies automatically
Quoted 1 line · Ingo Molnar
+-include *.d */*.d
Hmm.. this */*.d part is really needed?
tools/perf/config/feature-checks/Makefile line 20
Quoted 6 lines
tools/perf/config/feature-checks/Makefile +2
-1+ ############################### clean: - rm -f $(FILES) + rm -f $(FILES) *.d
If so, at least it'd be deleted from here IMHO.
Thanks,
Namhyung
Re: [PATCH 03/52] tools/perf/build: Add 'autodep' functionality, generate feature test dependencies automatically
Quoted 4 lines · Namhyung Kim
Quoted 1 line · Ingo Molnar
+-include *.d */*.d
Hmm.. this */*.d part is really needed?
Indeed! :-) I'll remove it.
Thanks,
Ingo
PATCH 1/1 tools/perf/build: Simplify the autodep inclusion rule
In reply to Namhyung KimNamhyung Kim noticed that the autodep .d file inclusion rule was unnecessarily complicated:
Quoted 3 lines
Quoted 1 line
+-include *.d */*.d
Hmm.. this */*.d part is really needed?
Only include *.d files.
--- tools/perf/config/feature-checks/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/config/feature-checks/Makefile +1 -1
@@ -136,7 +136,7 @@ test-on-exit: test-backtrace: $(BUILD) --include *.d */*.d +-include *.d ###############################
PATCH 4/52 tools/perf/build: Split out feature check: 'libnuma'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 7 ++++--- tools/perf/config/feature-checks/Makefile | 7 ++++++- tools/perf/config/feature-checks/test-libnuma.c | 8 ++++++++ 3 files changed, 18 insertions(+), 4 deletions(-)
tools/perf/config/Makefile +4 -3
@@ -101,7 +101,9 @@ $(info Testing features:) $(shell make -i -j -C config/feature-checks >/dev/null 2>&1) $(info done) -FEATURE_TESTS = hello +FEATURE_TESTS = \ + hello \ + libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -434,8 +436,7 @@ ifndef NO_BACKTRACE endif ifndef NO_LIBNUMA - FLAGS_LIBNUMA = $(CFLAGS) $(LDFLAGS) -lnuma - ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y) + ifeq ($(feature-libnuma), 0) msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev); NO_LIBNUMA := 1 else
tools/perf/config/feature-checks/Makefile +6 -1
@@ -1,5 +1,7 @@ -FILES=test-hello +FILES= \ + test-hello \ + test-libnuma CC := $(CC) -MD
@@ -12,6 +14,9 @@ BUILD = $(CC) -o $(OUTPUT)$@ [email protected] test-hello: $(BUILD) +test-libnuma: + $(BUILD) -lnuma + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-libnuma.c new file +8 -0
@@ -0,0 +1,8 @@ +#include <numa.h> +#include <numaif.h> + +int main (void ) +{ +numa_available (); +return 0 ; +}
Signature · 1 line
1.8.3.1
PATCH 5/52 tools/perf/build: Split out feature check: 'stackprotector-all'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-stackprotector-all.c | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -103,11 +103,12 @@ $(info done) FEATURE_TESTS = \ hello \ + stackprotector-all \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test))) -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) +ifeq ($(feature-stackprotector-all), 1) CFLAGS += -fstack-protector-all endif
tools/perf/config/feature-checks/Makefile +4 -0
@@ -1,6 +1,7 @@ FILES= \ test-hello \ + test-stackprotector-all \ test-libnuma CC := $(CC) -MD
@@ -14,6 +15,9 @@ BUILD = $(CC) -o $(OUTPUT)$@ [email protected] test-hello: $(BUILD) +test-stackprotector-all: + $(BUILD) -Werror -fstack-protector-all + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-stackprotector-all.c new file +6 -0
@@ -0,0 +1,6 @@ +#include <stdio.h> + +int main (void ) +{ +return puts ("hi" ); +}
Signature · 1 line
1.8.3.1
PATCH 6/52 tools/perf/build: Split out feature check: 'stackprotector'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-stackprotector.c | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -104,6 +104,7 @@ $(info done) FEATURE_TESTS = \ hello \ stackprotector-all \ + stackprotector \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -112,7 +113,7 @@ ifeq ($(feature-stackprotector-all), 1) CFLAGS += -fstack-protector-all endif -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) +ifeq ($(feature-stackprotector), 1) CFLAGS += -Wstack-protector endif
tools/perf/config/feature-checks/Makefile +4 -0
@@ -2,6 +2,7 @@ FILES= \ test-hello \ test-stackprotector-all \ + test-stackprotector \ test-libnuma CC := $(CC) -MD
@@ -18,6 +19,9 @@ test-hello: test-stackprotector-all: $(BUILD) -Werror -fstack-protector-all +test-stackprotector: + $(BUILD) -Werror -fstack-protector + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-stackprotector.c new file +6 -0
@@ -0,0 +1,6 @@ +#include <stdio.h> + +int main (void ) +{ +return puts ("hi" ); +}
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 06/52] tools/perf/build: Split out feature check: 'stackprotector'
Quoted 4 lines · Ingo Molnar
tools/perf/config/Makefile +1
-1-ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) +ifeq ($(feature-stackprotector), 1) CFLAGS += -Wstack-protector endif
[SNIP]
tools/perf/config/feature-checks/Makefile test-hello: · line 23
Quoted 2 lines
tools/perf/config/feature-checks/Makefile +2
-0+test-stackprotector: + $(BUILD) -Werror -fstack-protector
The flag being checked should be -"W"stack-protector instead of -"f"stack-protector. And the gcc manpage says that -Wstack-protector is only active when -fstack-protector is active. So the end result should look like
$(BUILD) -Werror -fstack-protector -Wstack-protector
Thanks,
Namhyung
Re: [PATCH 06/52] tools/perf/build: Split out feature check: 'stackprotector'
Quoted 16 lines · Namhyung Kim
Quoted 4 lines · Ingo Molnar
tools/perf/config/Makefile +1
-1-ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) +ifeq ($(feature-stackprotector), 1) CFLAGS += -Wstack-protector endif[SNIP]
tools/perf/config/feature-checks/Makefile test-hello: · line 23
Quoted 2 lines
tools/perf/config/feature-checks/Makefile +2
-0+test-stackprotector: + $(BUILD) -Werror -fstack-protectorThe flag being checked should be -"W"stack-protector instead of -"f"stack-protector. And the gcc manpage says that -Wstack-protector is only active when -fstack-protector is active. So the end result should look like
Quoted 1 line
$(BUILD) -Werror -fstack-protector -Wstack-protector
So, I think this testcase only wanted to check whether GCC knows the option or not, right?
Nevertheless I agree that we could add -Wstack-protector to be on the safe side, I'll send a patch for that.
Thanks,
Ingo
PATCH 1/1 tools/perf/build: Improve the 'stackprotector' feature test
In reply to Namhyung KimNamhyung Kim noticed that the stackprotector testcase was incomplete:
Quoted 6 lines
The flag being checked should be -"W"stack-protector instead of -"f"stack-protector. And the gcc manpage says that -Wstack-protector is only active when -fstack-protector is active. So the end result should look like
$(BUILD) -Werror -fstack-protector -Wstack-protector
Add -Wstack-protector.
--- tools/perf/config/feature-checks/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/config/feature-checks/Makefile +1 -1
@@ -45,7 +45,7 @@ test-stackprotector-all: $(BUILD) -Werror -fstack-protector-all test-stackprotector: - $(BUILD) -Werror -fstack-protector + $(BUILD) -Werror -fstack-protector -Wstack-protector test-fortify-source: $(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2
PATCH 7/52 tools/perf/build: Split out feature check: 'volatile-register-var'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-volatile-register-var.c | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -105,6 +105,7 @@ FEATURE_TESTS = \ hello \ stackprotector-all \ stackprotector \ + volatile-register-var \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -117,7 +118,7 @@ ifeq ($(feature-stackprotector), 1) CFLAGS += -Wstack-protector endif -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) +ifeq ($(feature-volatile-register-var), 1) CFLAGS += -Wvolatile-register-var endif
tools/perf/config/feature-checks/Makefile +4 -0
@@ -3,6 +3,7 @@ FILES= \ test-hello \ test-stackprotector-all \ test-stackprotector \ + test-volatile-register-var \ test-libnuma CC := $(CC) -MD
@@ -22,6 +23,9 @@ test-stackprotector-all: test-stackprotector: $(BUILD) -Werror -fstack-protector +test-volatile-register-var: + $(BUILD) -Werror -Wvolatile-register-var + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-volatile-register-var.c new file +6 -0
@@ -0,0 +1,6 @@ +#include <stdio.h> + +int main (void ) +{ +return puts ("hi" ); +}
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 07/52] tools/perf/build: Split out feature check: 'volatile-register-var'
Quoted 18 lines · Ingo Molnar
tools/perf/config/Makefile +1
-1-ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) +ifeq ($(feature-volatile-register-var), 1) CFLAGS += -Wvolatile-register-var endiftools/perf/config/feature-checks/Makefile +1
-0@@ -3,6 +3,7 @@ FILES= \ test-hello \ test-stackprotector-all \ test-stackprotector \ + test-volatile-register-var \ test-libnuma CC := $(CC) -MD
tools/perf/config/feature-checks/Makefile test-stackprotector-all: · line 27
Quoted 5 lines
tools/perf/config/feature-checks/Makefile +2
-0@@ -22,6 +23,9 @@ test-stackprotector-all: test-stackprotector: $(BUILD) -Werror -fstack-protector +test-volatile-register-var: + $(BUILD) -Werror -Wvolatile-register-var
I'm not sure this test is necessary at all.
The gcc manpage says this warning is enabled by -Wall, and we add -Wall to CFLAGS before doing feature checks. So all gcc versions that support -Wvolatile-register-var enables it by default without this check and older gcc versions will always fail the feature check.
Thanks,
Namhyung
Re: [PATCH 07/52] tools/perf/build: Split out feature check: 'volatile-register-var'
Quoted 9 lines · Namhyung Kim
tools/perf/config/feature-checks/Makefile test-stackprotector-all: · line 27
Quoted 2 lines
tools/perf/config/feature-checks/Makefile +2
-0+test-volatile-register-var: + $(BUILD) -Werror -Wvolatile-register-varI'm not sure this test is necessary at all.
The gcc manpage says this warning is enabled by -Wall, and we add -Wall to CFLAGS before doing feature checks. So all gcc versions that support -Wvolatile-register-var enables it by default without this check and older gcc versions will always fail the feature check.
Good point - I'll send a patch to remove it.
Thanks,
Ingo
PATCH 1/1 tools/perf/build: Remove the volatile-register-var feature check
In reply to Namhyung KimNamhyung Kim noticed that the volatile-register-var feature check is superfluous:
Quoted 4 lines
The gcc manpage says this warning is enabled by -Wall, and we add -Wall to CFLAGS before doing feature checks. So all gcc versions that support -Wvolatile-register-var enables it by default without this check and older gcc versions will always fail the feature check.
Remove it - this will further speed up feature checks.
--- tools/perf/config/Makefile | 7 +------ tools/perf/config/feature-checks/Makefile | 8 ++------ 2 files changed, 3 insertions(+), 12 deletions(-)
tools/perf/config/Makefile +1 -6
@@ -132,8 +132,7 @@ CORE_FEATURE_TESTS = \ libunwind \ on-exit \ stackprotector \ - stackprotector-all \ - volatile-register-var + stackprotector-all # # So here we detect whether test-all was rebuilt, to be able
@@ -203,10 +202,6 @@ ifeq ($(feature-stackprotector), 1) CFLAGS += -Wstack-protector endif -ifeq ($(feature-volatile-register-var), 1) - CFLAGS += -Wvolatile-register-var -endif - ifeq ($(DEBUG),0) ifeq ($(feature-fortify-source), 1) CFLAGS += -D_FORTIFY_SOURCE=2
tools/perf/config/feature-checks/Makefile +2 -6
@@ -25,8 +25,7 @@ FILES= \ test-libunwind \ test-on-exit \ test-stackprotector-all \ - test-stackprotector \ - test-volatile-register-var + test-stackprotector CC := $(CC) -MD
@@ -37,7 +36,7 @@ BUILD = $(CC) $(LDFLAGS) -o $(OUTPUT)$@ [email protected] ############################### test-all: - $(BUILD) -Werror -fstack-protector -fstack-protector-all -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl + $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl test-hello: $(BUILD)
@@ -48,9 +47,6 @@ test-stackprotector-all: test-stackprotector: $(BUILD) -Werror -fstack-protector -test-volatile-register-var: - $(BUILD) -Werror -Wvolatile-register-var - test-fortify-source: $(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2
PATCH 8/52 tools/perf/build: Split out feature check: 'fortify-source'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-fortify-source.c | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -106,6 +106,7 @@ FEATURE_TESTS = \ stackprotector-all \ stackprotector \ volatile-register-var \ + fortify-source \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -123,7 +124,7 @@ ifeq ($(feature-volatile-register-var), 1) endif ifndef PERF_DEBUG - ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y) + ifeq ($(feature-fortify-source), 1) CFLAGS += -D_FORTIFY_SOURCE=2 endif endif
tools/perf/config/feature-checks/Makefile +4 -0
@@ -4,6 +4,7 @@ FILES= \ test-stackprotector-all \ test-stackprotector \ test-volatile-register-var \ + test-fortify-source \ test-libnuma CC := $(CC) -MD
@@ -26,6 +27,9 @@ test-stackprotector: test-volatile-register-var: $(BUILD) -Werror -Wvolatile-register-var +test-fortify-source: + $(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2 + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-fortify-source.c new file +6 -0
@@ -0,0 +1,6 @@ +#include <stdio.h> + +int main (void ) +{ +return puts ("hi" ); +}
Signature · 1 line
1.8.3.1
PATCH 9/52 tools/perf/build: Split out feature check: 'bionic'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 12 +++++++----- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-bionic.c | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-)
tools/perf/config/Makefile +7 -5
@@ -107,6 +107,7 @@ FEATURE_TESTS = \ stackprotector \ volatile-register-var \ fortify-source \ + bionic \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -150,12 +151,13 @@ CFLAGS += -I$(LIB_INCLUDE) CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE ifndef NO_BIONIC -ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) - BIONIC := 1 - EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) - EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) + $(feature_check,bionic) + ifeq ($(feature-bionic), 1) + BIONIC := 1 + EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) + EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) + endif endif -endif # NO_BIONIC ifdef NO_LIBELF NO_DWARF := 1
tools/perf/config/feature-checks/Makefile +4 -0
@@ -5,6 +5,7 @@ FILES= \ test-stackprotector \ test-volatile-register-var \ test-fortify-source \ + test-bionic \ test-libnuma CC := $(CC) -MD
@@ -30,6 +31,9 @@ test-volatile-register-var: test-fortify-source: $(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2 +test-bionic: + $(BUILD) + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-bionic.c new file +6 -0
@@ -0,0 +1,6 @@ +#include <android/api-level.h> + +int main (void ) +{ +return __ANDROID_API__; +}
Signature · 1 line
1.8.3.1
PATCH 10/52 tools/perf/build: Clean up the libelf logic in config/Makefile
In reply to Ingo MolnarNest the rules properly. No change in functionality.
--- tools/perf/config/Makefile | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-)
tools/perf/config/Makefile +29 -29
@@ -164,38 +164,38 @@ ifdef NO_LIBELF NO_DEMANGLE := 1 NO_LIBUNWIND := 1 else -FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) - FLAGS_GLIBC=$(CFLAGS) $(LDFLAGS) - ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) - LIBC_SUPPORT := 1 - endif - ifeq ($(BIONIC),1) - LIBC_SUPPORT := 1 - endif - ifeq ($(LIBC_SUPPORT),1) - msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); + FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) + ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) + FLAGS_GLIBC=$(CFLAGS) $(LDFLAGS) + ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) + LIBC_SUPPORT := 1 + endif + ifeq ($(BIONIC),1) + LIBC_SUPPORT := 1 + endif + ifeq ($(LIBC_SUPPORT),1) + msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); - NO_LIBELF := 1 - NO_DWARF := 1 - NO_DEMANGLE := 1 + NO_LIBELF := 1 + NO_DWARF := 1 + NO_DEMANGLE := 1 + else + msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); + endif else - msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); - endif -else - # for linking with debug library, run like: - # make DEBUG=1 LIBDW_DIR=/opt/libdw/ - ifdef LIBDW_DIR - LIBDW_CFLAGS := -I$(LIBDW_DIR)/include - LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib - endif + # for linking with debug library, run like: + # make DEBUG=1 LIBDW_DIR=/opt/libdw/ + ifdef LIBDW_DIR + LIBDW_CFLAGS := -I$(LIBDW_DIR)/include + LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib + endif - FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lz -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) - ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) - msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); - NO_DWARF := 1 - endif # Dwarf support -endif # SOURCE_LIBELF + FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lz -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) + ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) + msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); + NO_DWARF := 1 + endif # Dwarf support + endif # SOURCE_LIBELF endif # NO_LIBELF ifndef NO_LIBELF
Signature · 1 line
1.8.3.1
PATCH 11/52 tools/perf/build: Split out feature check: 'libelf'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 4 ++-- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-libelf.c | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -2
@@ -108,6 +108,7 @@ FEATURE_TESTS = \ volatile-register-var \ fortify-source \ bionic \ + libelf \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -164,8 +165,7 @@ ifdef NO_LIBELF NO_DEMANGLE := 1 NO_LIBUNWIND := 1 else - FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) - ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) + ifeq ($(feature-libelf), 0) FLAGS_GLIBC=$(CFLAGS) $(LDFLAGS) ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) LIBC_SUPPORT := 1
tools/perf/config/feature-checks/Makefile +4 -0
@@ -6,6 +6,7 @@ FILES= \ test-volatile-register-var \ test-fortify-source \ test-bionic \ + test-libelf \ test-libnuma CC := $(CC) -MD
@@ -34,6 +35,9 @@ test-fortify-source: test-bionic: $(BUILD) +test-libelf: + $(BUILD) -lelf + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-libelf.c new file +7 -0
@@ -0,0 +1,7 @@ +#include <libelf.h> + +int main (void ) +{ +Elf *elf =elf_begin (0 ,ELF_C_READ ,0 ); +return (long )elf; +}
Signature · 1 line
1.8.3.1
PATCH 12/52 tools/perf/build: Split out feature check: 'glibc'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 4 ++-- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-glibc.c | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -2
@@ -109,6 +109,7 @@ FEATURE_TESTS = \ fortify-source \ bionic \ libelf \ + glibc \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -166,8 +167,7 @@ ifdef NO_LIBELF NO_LIBUNWIND := 1 else ifeq ($(feature-libelf), 0) - FLAGS_GLIBC=$(CFLAGS) $(LDFLAGS) - ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) + ifeq ($(feature-glibc), 1) LIBC_SUPPORT := 1 endif ifeq ($(BIONIC),1)
tools/perf/config/feature-checks/Makefile +4 -0
@@ -7,6 +7,7 @@ FILES= \ test-fortify-source \ test-bionic \ test-libelf \ + test-glibc \ test-libnuma CC := $(CC) -MD
@@ -38,6 +39,9 @@ test-bionic: test-libelf: $(BUILD) -lelf +test-glibc: + $(BUILD) + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-glibc.c new file +8 -0
@@ -0,0 +1,8 @@ +#include <gnu/libc-version.h> + +int main (void ) +{ +const char *version =gnu_get_libc_version (); +return (long )version; +} +
Signature · 1 line
1.8.3.1
PATCH 13/52 tools/perf/build: Split out feature check: 'dwarf'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 4 ++-- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-dwarf.c | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -2
@@ -110,6 +110,7 @@ FEATURE_TESTS = \ bionic \ libelf \ glibc \ + dwarf \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -190,8 +191,7 @@ else LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib endif - FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lz -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) - ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) + ifneq ($(feature-dwarf), 1) msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); NO_DWARF := 1 endif # Dwarf support
tools/perf/config/feature-checks/Makefile +4 -0
@@ -8,6 +8,7 @@ FILES= \ test-bionic \ test-libelf \ test-glibc \ + test-dwarf \ test-libnuma CC := $(CC) -MD
@@ -42,6 +43,9 @@ test-libelf: test-glibc: $(BUILD) +test-dwarf: + $(BUILD) -ldw + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-dwarf.c new file +9 -0
@@ -0,0 +1,9 @@ +#include <dwarf.h> +#include <elfutils/libdw.h> +#include <elfutils/version.h> + +int main (void ) +{ +Dwarf *dbg =dwarf_begin (0 ,DWARF_C_READ ); +return (long )dbg; +}
Signature · 1 line
1.8.3.1
PATCH 14/52 tools/perf/build: Clean up the mmap logic in config/Makefile
In reply to Ingo MolnarNest the rules properly. No change in functionality.
--- tools/perf/config/Makefile | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-)
tools/perf/config/Makefile +26 -25
@@ -199,37 +199,38 @@ else endif # NO_LIBELF ifndef NO_LIBELF -CFLAGS += -DHAVE_LIBELF_SUPPORT -FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) - CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT -endif -ifeq ($(call try-cc,$(SOURCE_ELF_GETPHDRNUM),$(FLAGS_LIBELF),-DHAVE_ELF_GETPHDRNUM_SUPPORT),y) - CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT -endif + CFLAGS += -DHAVE_LIBELF_SUPPORT + FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -# include ARCH specific config --include $(src-perf)/arch/$(ARCH)/Makefile + ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) + CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT + endif -ifndef NO_DWARF -ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) - msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); - NO_DWARF := 1 -else - CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) - LDFLAGS += $(LIBDW_LDFLAGS) - EXTLIBS += -lelf -ldw -endif # PERF_HAVE_DWARF_REGS -endif # NO_DWARF + ifeq ($(call try-cc,$(SOURCE_ELF_GETPHDRNUM),$(FLAGS_LIBELF),-DHAVE_ELF_GETPHDRNUM_SUPPORT),y) + CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT + endif + + # include ARCH specific config + -include $(src-perf)/arch/$(ARCH)/Makefile + ifndef NO_DWARF + ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) + msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); + NO_DWARF := 1 + else + CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) + LDFLAGS += $(LIBDW_LDFLAGS) + EXTLIBS += -lelf -ldw + endif # PERF_HAVE_DWARF_REGS + endif # NO_DWARF endif # NO_LIBELF ifndef NO_LIBELF -CFLAGS += -DHAVE_LIBELF_SUPPORT -FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) - CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT -endif # try-cc + CFLAGS += -DHAVE_LIBELF_SUPPORT + FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) + ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) + CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT + endif # try-cc endif # NO_LIBELF # There's only x86 (both 32 and 64) support for CFI unwind so far
Signature · 1 line
1.8.3.1
PATCH 15/52 tools/perf/build: Split out feature check: 'libelf-mmap'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 6 +++--- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-libelf-mmap.c | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-)
tools/perf/config/Makefile +3 -3
@@ -111,6 +111,7 @@ FEATURE_TESTS = \ libelf \ glibc \ dwarf \ + libelf-mmap \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -202,7 +203,7 @@ ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) - ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) + ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif
@@ -227,8 +228,7 @@ endif # NO_LIBELF ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT - FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) - ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) + ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif # try-cc endif # NO_LIBELF
tools/perf/config/feature-checks/Makefile +4 -0
@@ -9,6 +9,7 @@ FILES= \ test-libelf \ test-glibc \ test-dwarf \ + test-libelf-mmap \ test-libnuma CC := $(CC) -MD
@@ -46,6 +47,9 @@ test-glibc: test-dwarf: $(BUILD) -ldw +test-libelf-mmap: + $(BUILD) -lelf + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-libelf-mmap.c new file +7 -0
@@ -0,0 +1,7 @@ +#include <libelf.h> +# +int main (void ) +{ +Elf *elf =elf_begin (0 ,ELF_C_READ_MMAP ,0 ); +return (long )elf; +}
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 15/52] tools/perf/build: Split out feature check: 'libelf-mmap'
Quoted 10 lines · Ingo Molnar
tools/perf/config/Makefile +1
-1@@ -202,7 +203,7 @@ ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) - ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) + ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif
tools/perf/config/Makefile endif # NO_LIBELF · line 234
Quoted 9 lines
tools/perf/config/Makefile +1
-2@@ -227,8 +228,7 @@ endif # NO_LIBELF ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT - FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) - ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) + ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif # try-cc endif # NO_LIBELF
As Ulrich Drepper reported, it seems that this hunk is duplicate.
Thanks,
Namhyung
Re: [PATCH 15/52] tools/perf/build: Split out feature check: 'libelf-mmap'
Quoted 12 lines · Namhyung Kim
Quoted 11 lines · Ingo Molnar
tools/perf/config/Makefile +1
-1@@ -202,7 +203,7 @@ ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) - ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) + ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif@@ -227,8 +228,7 @@ endif # NO_LIBELF
Quoted 10 lines
tools/perf/config/Makefile endif # NO_LIBELF · line 234
Quoted 8 lines
tools/perf/config/Makefile +1
-2ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT - FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) - ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DHAVE_LIBELF_MMAP_SUPPORT),y) + ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif # try-cc endif # NO_LIBELFAs Ulrich Drepper reported, it seems that this hunk is duplicate.
This was pre-existing, but indeed it's an unnecessary duplication. I'll send a patch in a separate mail.
Thanks,
Ingo
PATCH 1/1 tools/perf/build: Simplify the libelf logic
In reply to Namhyung KimUlrich Drepper and Namhyung Kim reported that the libelf logic in config/Makefile is duplicated in part.
Remove the duplication, and also remove the now unused FLAGS_LIBELF variable.
--- tools/perf/config/Makefile | 8 -------- 1 file changed, 8 deletions(-)
tools/perf/config/Makefile +0 -8
@@ -280,7 +280,6 @@ endif # NO_LIBELF ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT - FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
@@ -305,13 +304,6 @@ ifndef NO_LIBELF endif # NO_DWARF endif # NO_LIBELF -ifndef NO_LIBELF - CFLAGS += -DHAVE_LIBELF_SUPPORT - ifeq ($(feature-libelf-mmap), 1) - CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT - endif -endif # NO_LIBELF - # There's only x86 (both 32 and 64) support for CFI unwind so far ifneq ($(ARCH),x86) NO_LIBUNWIND := 1
PATCH 16/52 tools/perf/build: Split out feature check: 'libelf-getphdrnum'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 5 +++-- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-libelf-getphdrnum.c | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +3 -2
@@ -112,6 +112,7 @@ FEATURE_TESTS = \ glibc \ dwarf \ libelf-mmap \ + libelf-getphdrnum \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -207,7 +208,7 @@ ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif - ifeq ($(call try-cc,$(SOURCE_ELF_GETPHDRNUM),$(FLAGS_LIBELF),-DHAVE_ELF_GETPHDRNUM_SUPPORT),y) + ifeq ($(feature-libelf-getphdrnum), 1) CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT endif
@@ -230,7 +231,7 @@ ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT - endif # try-cc + endif endif # NO_LIBELF # There's only x86 (both 32 and 64) support for CFI unwind so far
tools/perf/config/feature-checks/Makefile +4 -0
@@ -10,6 +10,7 @@ FILES= \ test-glibc \ test-dwarf \ test-libelf-mmap \ + test-libelf-getphdrnum \ test-libnuma CC := $(CC) -MD
@@ -50,6 +51,9 @@ test-dwarf: test-libelf-mmap: $(BUILD) -lelf +test-libelf-getphdrnum: + $(BUILD) -lelf + test-libnuma: $(BUILD) -lnuma
tools/perf/config/feature-checks/test-libelf-getphdrnum.c new file +7 -0
@@ -0,0 +1,7 @@ +#include <libelf.h> +# +int main (void ) +{ +size_t dst; +return elf_getphdrnum (0 , &dst); +}
Signature · 1 line
1.8.3.1
PATCH 17/52 tools/perf/build: Clean up the libunwind logic in config/Makefile
In reply to Ingo MolnarNest the rules properly. No change in functionality.
--- tools/perf/config/Makefile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
tools/perf/config/Makefile +12 -12
@@ -240,19 +240,19 @@ ifneq ($(ARCH),x86) endif ifndef NO_LIBUNWIND -# for linking with debug library, run like: -# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ -ifdef LIBUNWIND_DIR - LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include - LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib -endif + # for linking with debug library, run like: + # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ + ifdef LIBUNWIND_DIR + LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include + LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib + endif -FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) -ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) - msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99); - NO_LIBUNWIND := 1 -endif # Libunwind support -endif # NO_LIBUNWIND + FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) + ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) + msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99); + NO_LIBUNWIND := 1 + endif +endif ifndef NO_LIBUNWIND CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
Signature · 1 line
1.8.3.1
PATCH 18/52 tools/perf/build: Split out feature check: 'libunwind'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 13 +++---------- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-libunwind.c | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 10 deletions(-)
tools/perf/config/Makefile +3 -10
@@ -113,6 +113,7 @@ FEATURE_TESTS = \ dwarf \ libelf-mmap \ libelf-getphdrnum \ + libunwind \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -240,15 +241,7 @@ ifneq ($(ARCH),x86) endif ifndef NO_LIBUNWIND - # for linking with debug library, run like: - # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ - ifdef LIBUNWIND_DIR - LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include - LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib - endif - - FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) - ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) + ifneq ($(feature-libunwind), 1) msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99); NO_LIBUNWIND := 1 endif
@@ -259,7 +252,7 @@ ifndef NO_LIBUNWIND EXTLIBS += $(LIBUNWIND_LIBS) CFLAGS += $(LIBUNWIND_CFLAGS) LDFLAGS += $(LIBUNWIND_LDFLAGS) -endif # NO_LIBUNWIND +endif ifndef NO_LIBAUDIT FLAGS_LIBAUDIT = $(CFLAGS) $(LDFLAGS) -laudit
tools/perf/config/feature-checks/Makefile +4 -0
@@ -11,6 +11,7 @@ FILES= \ test-dwarf \ test-libelf-mmap \ test-libelf-getphdrnum \ + test-libunwind \ test-libnuma CC := $(CC) -MD
@@ -57,6 +58,9 @@ test-libelf-getphdrnum: test-libnuma: $(BUILD) -lnuma +test-libunwind: + $(BUILD) -lunwind -lunwind-x86_64 -lelf + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-libunwind.c new file +20 -0
@@ -0,0 +1,20 @@ +#include <libunwind.h> +#include <stdlib.h> + +extern int UNW_OBJ (dwarf_search_unwind_table ) (unw_addr_space_t as, +unw_word_t ip, +unw_dyn_info_t *di, +unw_proc_info_t *pi, +int need_unwind_info,void *arg); + + +#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) + +int main (void ) +{ +unw_addr_space_t addr_space; + addr_space =unw_create_addr_space (NULL ,0 ); +unw_init_remote (NULL , addr_space,NULL ); +dwarf_search_unwind_table (addr_space,0 ,NULL ,NULL ,0 ,NULL ); +return 0 ; +}
Signature · 1 line
1.8.3.1
Re: [PATCH 18/52] tools/perf/build: Split out feature check: 'libunwind'
tools/perf/config/Makefile ifneq ($(ARCH),x86) · line 248
Quoted 10 lines · Ingo Molnar
tools/perf/config/Makefile +0
-6@@ -240,15 +241,7 @@ ifneq ($(ARCH),x86) endif ifndef NO_LIBUNWIND - # for linking with debug library, run like: - # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ - ifdef LIBUNWIND_DIR - LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include - LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib - endif
You are dropping the above so add-on libunwind support will break.
David
Re: [PATCH 18/52] tools/perf/build: Split out feature check: 'libunwind'
Quoted 4 lines · David Ahern
Quoted 3 lines · Ingo Molnar
(quoted diff) +0
-0@@ -240,15 +241,7 @@ ifneq ($(ARCH),x86) endif
Quoted 9 lines
tools/perf/config/Makefile ifneq ($(ARCH),x86) · line 248
Quoted 7 lines
tools/perf/config/Makefile +0
-6ifndef NO_LIBUNWIND - # for linking with debug library, run like: - # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ - ifdef LIBUNWIND_DIR - LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include - LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib - endifYou are dropping the above so add-on libunwind support will break.
Oops - restored it.
Thanks,
Ingo
PATCH 19/52 tools/perf/build: Split out feature check: 'libaudit'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 4 ++-- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-libaudit.c | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -2
@@ -114,6 +114,7 @@ FEATURE_TESTS = \ libelf-mmap \ libelf-getphdrnum \ libunwind \ + libaudit \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -255,8 +256,7 @@ ifndef NO_LIBUNWIND endif ifndef NO_LIBAUDIT - FLAGS_LIBAUDIT = $(CFLAGS) $(LDFLAGS) -laudit - ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y) + ifneq ($(feature-libaudit), 1) msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); NO_LIBAUDIT := 1 else
tools/perf/config/feature-checks/Makefile +4 -0
@@ -12,6 +12,7 @@ FILES= \ test-libelf-mmap \ test-libelf-getphdrnum \ test-libunwind \ + test-libaudit \ test-libnuma CC := $(CC) -MD
@@ -61,6 +62,9 @@ test-libnuma: test-libunwind: $(BUILD) -lunwind -lunwind-x86_64 -lelf +test-libaudit: + $(BUILD) -laudit + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-libaudit.c new file +7 -0
@@ -0,0 +1,7 @@ +#include <libaudit.h> + +int main (void ) +{ +printf ("error message: %s\n" ,audit_errno_to_name (0 )); +return audit_open (); +}
Signature · 1 line
1.8.3.1
PATCH 20/52 tools/perf/build: Split out feature check: 'libslang'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 4 ++-- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-libslang.c | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -2
@@ -115,6 +115,7 @@ FEATURE_TESTS = \ libelf-getphdrnum \ libunwind \ libaudit \ + libslang \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -270,8 +271,7 @@ ifdef NO_NEWT endif ifndef NO_SLANG - FLAGS_SLANG=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -I/usr/include/slang -lslang - ifneq ($(call try-cc,$(SOURCE_SLANG),$(FLAGS_SLANG),libslang),y) + ifneq ($(feature-libslang), 1) msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); NO_SLANG := 1 else
tools/perf/config/feature-checks/Makefile +4 -0
@@ -13,6 +13,7 @@ FILES= \ test-libelf-getphdrnum \ test-libunwind \ test-libaudit \ + test-libslang \ test-libnuma CC := $(CC) -MD
@@ -65,6 +66,9 @@ test-libunwind: test-libaudit: $(BUILD) -laudit +test-libslang: + $(BUILD) -I/usr/include/slang -lslang + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-libslang.c new file +6 -0
@@ -0,0 +1,6 @@ +#include <slang.h> + +int main (void ) +{ +return SLsmg_init_smg (); +}
Signature · 1 line
1.8.3.1
PATCH 21/52 tools/perf/build: Split out feature check: 'gtk2'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-gtk2.c | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -116,6 +116,7 @@ FEATURE_TESTS = \ libunwind \ libaudit \ libslang \ + gtk2 \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -284,7 +285,7 @@ endif ifndef NO_GTK2 FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) - ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y) + ifneq ($(feature-gtk2), 1) msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); NO_GTK2 := 1 else
tools/perf/config/feature-checks/Makefile +4 -0
@@ -14,6 +14,7 @@ FILES= \ test-libunwind \ test-libaudit \ test-libslang \ + test-gtk2 \ test-libnuma CC := $(CC) -MD
@@ -69,6 +70,9 @@ test-libaudit: test-libslang: $(BUILD) -I/usr/include/slang -lslang +test-gtk2: + $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-gtk2.c new file +10 -0
@@ -0,0 +1,10 @@ +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +#include <gtk/gtk.h> +#pragma GCC diagnostic error "-Wstrict-prototypes" + +int main (int argc,char *argv[]) +{ +gtk_init (&argc, &argv); + +return 0 ; +}
Signature · 1 line
1.8.3.1
PATCH 22/52 tools/perf/build: Split out feature check: 'gtk2-infobar'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-gtk2-infobar.c | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -117,6 +117,7 @@ FEATURE_TESTS = \ libaudit \ libslang \ gtk2 \ + gtk2-infobar \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -289,7 +290,7 @@ ifndef NO_GTK2 msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); NO_GTK2 := 1 else - ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR_SUPPORT),y) + ifeq ($(feature-gtk2-infobar), 1) CFLAGS += -DHAVE_GTK_INFO_BAR_SUPPORT endif CFLAGS += -DHAVE_GTK2_SUPPORT
tools/perf/config/feature-checks/Makefile +4 -0
@@ -15,6 +15,7 @@ FILES= \ test-libaudit \ test-libslang \ test-gtk2 \ + test-gtk2-infobar \ test-libnuma CC := $(CC) -MD
@@ -73,6 +74,9 @@ test-libslang: test-gtk2: $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) +test-gtk2-infobar: + $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-gtk2-infobar.c new file +10 -0
@@ -0,0 +1,10 @@ +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +#include <gtk/gtk.h> +#pragma GCC diagnostic error "-Wstrict-prototypes" + +int main (void ) +{ +gtk_info_bar_new (); + +return 0 ; +}
Signature · 1 line
1.8.3.1
PATCH 23/52 tools/perf/build: Split out feature check: 'libperl'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 13 +++++++++++++ tools/perf/config/feature-checks/test-libperl.c | 9 +++++++++ 3 files changed, 24 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -118,6 +118,7 @@ FEATURE_TESTS = \ libslang \ gtk2 \ gtk2-infobar \ + libperl \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -311,7 +312,7 @@ else PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) - ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y) + ifneq ($(feature-libperl), 1) CFLAGS += -DNO_LIBPERL NO_LIBPERL := 1 else
tools/perf/config/feature-checks/Makefile +13 -0
@@ -16,6 +16,7 @@ FILES= \ test-libslang \ test-gtk2 \ test-gtk2-infobar \ + test-libperl \ test-libnuma CC := $(CC) -MD
@@ -77,6 +78,18 @@ test-gtk2: test-gtk2-infobar: $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) +grep-libs = $(filter -l%,$(1)) +strip-libs = $(filter-out -l%,$(1)) + +PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) +PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) +PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) +PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` +FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) + +test-libperl: + $(BUILD) $(FLAGS_PERL_EMBED) + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-libperl.c new file +9 -0
@@ -0,0 +1,9 @@ +#include <EXTERN.h> +#include <perl.h> + +int main (void ) +{ +perl_alloc (); + +return 0 ; +}
Signature · 1 line
1.8.3.1
PATCH 24/52 tools/perf/build: Split out feature check: 'libpython'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 18 ++++++++++++++++++ tools/perf/config/feature-checks/test-libpython.c | 7 +++++++ 3 files changed, 27 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -119,6 +119,7 @@ FEATURE_TESTS = \ gtk2 \ gtk2-infobar \ libperl \ + libpython \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -357,7 +358,7 @@ else PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) - ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y) + ifneq ($(feature-libpython), 1) $(call disable-python,Python.h (for Python 2.x)) else
tools/perf/config/feature-checks/Makefile +18 -0
@@ -17,6 +17,7 @@ FILES= \ test-gtk2 \ test-gtk2-infobar \ test-libperl \ + test-libpython \ test-libnuma CC := $(CC) -MD
@@ -90,6 +91,23 @@ FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) test-libperl: $(BUILD) $(FLAGS_PERL_EMBED) +override PYTHON := python +override PYTHON_CONFIG := python-config + +escape-for-shell-sq = $(subst ','\'',$(1)) +shell-sq = '$(escape-for-shell-sq)' + +PYTHON_CONFIG_SQ = $(call shell-sq,$(PYTHON_CONFIG)) + +PYTHON_EMBED_LDOPTS = $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) +PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) +PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) +PYTHON_EMBED_CCOPTS = $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) +FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) + +test-libpython: + $(BUILD) $(FLAGS_PYTHON_EMBED) + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-libpython.c new file +7 -0
@@ -0,0 +1,7 @@ +#include <Python.h> +# +int main (void ) +{ +Py_Initialize (); +return 0 ; +}
Signature · 1 line
1.8.3.1
PATCH 25/52 tools/perf/build: Split out feature check: 'libpython-version'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-libpython-version.c | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -120,6 +120,7 @@ FEATURE_TESTS = \ gtk2-infobar \ libperl \ libpython \ + libpython-version \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -362,7 +363,7 @@ else $(call disable-python,Python.h (for Python 2.x)) else - ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y) + ifneq ($(feature-libpython-version), 1) $(warning Python 3 is not yet supported; please set) $(warning PYTHON and/or PYTHON_CONFIG appropriately.) $(warning If you also have Python 2 installed, then)
tools/perf/config/feature-checks/Makefile +4 -0
@@ -18,6 +18,7 @@ FILES= \ test-gtk2-infobar \ test-libperl \ test-libpython \ + test-libpython-version \ test-libnuma CC := $(CC) -MD
@@ -108,6 +109,9 @@ FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) test-libpython: $(BUILD) $(FLAGS_PYTHON_EMBED) +test-libpython-version: + $(BUILD) $(FLAGS_PYTHON_EMBED) + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-libpython-version.c new file +10 -0
@@ -0,0 +1,10 @@ +#include <Python.h> + +#if PY_VERSION_HEX >=0x03000000 +#error +#endif + +int main (void ) +{ +return 0 ; +}
Signature · 1 line
1.8.3.1
PATCH 26/52 tools/perf/build: Split out feature check: 'libbfd'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 4 ++-- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-libbfd.c | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -2
@@ -121,6 +121,7 @@ FEATURE_TESTS = \ libperl \ libpython \ libpython-version \ + libbfd \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -394,8 +395,7 @@ else CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT else FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd - has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd) - ifeq ($(has_bfd),y) + ifeq ($(feature-libbfd), 1) EXTLIBS += -lbfd else FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
tools/perf/config/feature-checks/Makefile +4 -0
@@ -19,6 +19,7 @@ FILES= \ test-libperl \ test-libpython \ test-libpython-version \ + test-libbfd \ test-libnuma CC := $(CC) -MD
@@ -112,6 +113,9 @@ test-libpython: test-libpython-version: $(BUILD) $(FLAGS_PYTHON_EMBED) +test-libbfd: + $(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-libbfd.c new file +7 -0
@@ -0,0 +1,7 @@ +#include <bfd.h> + +int main (void ) +{ +bfd_demangle (0 ,0 ,0 ); +return 0 ; +}
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 26/52] tools/perf/build: Split out feature check: 'libbfd'
tools/perf/config/feature-checks/Makefile test-libpython: · line 117
Quoted 2 lines · Ingo Molnar
tools/perf/config/feature-checks/Makefile +2
-0+test-libbfd: + $(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl
Duplicate PACKAGE definitions. It seems only one is needed and it should look like a normal C string like -DPACKAGE='"perf"' IMHO.
Thanks,
Namhyung
PATCH 1/1 tools/perf/build: Fix DPACKAGE definitions for the libbfd et al testcases
Namhyung Kim reported these duplicate DPACKAGE definitions:
test-libbfd:
$(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldlFix all affected places and use Namhyung's suggestion that the definition should look like a normal C string: -DPACKAGE='"perf"'.
--- tools/perf/config/feature-checks/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/config/feature-checks/Makefile +4 -4
@@ -37,7 +37,7 @@ BUILD = $(CC) $(LDFLAGS) -o $(OUTPUT)$@ [email protected] ############################### test-all: - $(BUILD) -Werror -fstack-protector -fstack-protector-all -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl + $(BUILD) -Werror -fstack-protector -fstack-protector-all -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl test-hello: $(BUILD)
@@ -123,13 +123,13 @@ test-libpython-version: $(BUILD) $(FLAGS_PYTHON_EMBED) test-libbfd: - $(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl + $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl test-liberty: - $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl -liberty + $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty test-liberty-z: - $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl -liberty -lz + $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz test-cplus-demangle: $(BUILD) -liberty
Re: [PATCH 26/52] tools/perf/build: Split out feature check: 'libbfd'
In reply to Namhyung KimQuoted 6 lines · Namhyung Kim
tools/perf/config/feature-checks/Makefile test-libpython: · line 117
Quoted 2 lines · Ingo Molnar
tools/perf/config/feature-checks/Makefile +2
-0+test-libbfd: + $(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldlDuplicate PACKAGE definitions. It seems only one is needed and it should look like a normal C string like -DPACKAGE='"perf"' IMHO.
Agreed - I sent the fix in a separate mail.
Thanks,
Ingo
PATCH 27/52 tools/perf/build: Split out feature check: 'strlcpy'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-strlcpy.c | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -121,6 +121,7 @@ FEATURE_TESTS = \ libperl \ libpython \ libpython-version \ + strlcpy \ libbfd \ libnuma
@@ -424,7 +425,7 @@ else endif ifndef NO_STRLCPY - ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY_SUPPORT),y) + ifeq ($(feature-strlcpy), 1) CFLAGS += -DHAVE_STRLCPY_SUPPORT endif endif
tools/perf/config/feature-checks/Makefile +4 -0
@@ -19,6 +19,7 @@ FILES= \ test-libperl \ test-libpython \ test-libpython-version \ + test-strlcpy \ test-libbfd \ test-libnuma
@@ -113,6 +114,9 @@ test-libpython: test-libpython-version: $(BUILD) $(FLAGS_PYTHON_EMBED) +test-strlcpy: + $(BUILD) + test-libbfd: $(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl
tools/perf/config/feature-checks/test-strlcpy.c new file +8 -0
@@ -0,0 +1,8 @@ +#include <stdlib.h> +extern size_t strlcpy (char *dest,const char *src,size_t size); + +int main (void ) +{ +strlcpy (NULL ,NULL ,0 ); +return 0 ; +}
Signature · 1 line
1.8.3.1
PATCH 28/52 tools/perf/build: Split out feature check: 'on-exit'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-on-exit.c | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -123,6 +123,7 @@ FEATURE_TESTS = \ libpython-version \ strlcpy \ libbfd \ + on-exit \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -431,7 +432,7 @@ ifndef NO_STRLCPY endif ifndef NO_ON_EXIT - ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT_SUPPORT),y) + ifeq ($(feature-on-exit), 1) CFLAGS += -DHAVE_ON_EXIT_SUPPORT endif endif
tools/perf/config/feature-checks/Makefile +4 -0
@@ -21,6 +21,7 @@ FILES= \ test-libpython-version \ test-strlcpy \ test-libbfd \ + test-on-exit \ test-libnuma CC := $(CC) -MD
@@ -120,6 +121,9 @@ test-strlcpy: test-libbfd: $(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl +test-on-exit: + $(BUILD) + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-on-exit.c new file +6 -0
@@ -0,0 +1,6 @@ +#include <stdio.h> + +int main (void ) +{ +return on_exit (NULL ,NULL ); +}
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 28/52] tools/perf/build: Split out feature check: 'on-exit'
tools/perf/config/feature-checks/test-on-exit.c line 6
Quoted 12 lines
tools/perf/config/feature-checks/test-on-exit.c new file +6
-0@@ -0,0 +1,6 @@ +#include <stdio.h> + +int main (void ) +{ +return on_exit (NULL ,NULL ); +}
Just a nitpick. The manpage says the on_exit() requires <stdlib.h> header rather than <stdio.h> and _BSD_SOURCE or _SVID_SOURCE defined. So I think we can define _GNU_SOURCE before the header file or pass it through make command line - it'd probably be better for synthesized test-all.c checking.
Thanks,
Namhyung
Re: [PATCH 28/52] tools/perf/build: Split out feature check: 'on-exit'
Quoted 10 lines · Namhyung Kim
Quoted 10 lines
tools/perf/config/feature-checks/test-on-exit.c new file +4
-0@@ -0,0 +1,6 @@ +#include <stdio.h> + +int main (void ) +{
Quoted 8 lines
tools/perf/config/feature-checks/test-on-exit.c line 6
Quoted 2 lines
tools/perf/config/feature-checks/test-on-exit.c new file +2
-0+return on_exit (NULL ,NULL ); +}Just a nitpick. The manpage says the
on_exit()requires <stdlib.h> header rather than <stdio.h> and_BSD_SOURCEor_SVID_SOURCEdefined. So I think we can define_GNU_SOURCEbefore the header file or pass it through make command line - it'd probably be better for synthesizedtest-all.cchecking.
This was inherited from the original feature-tests.mak:
define SOURCE_ON_EXIT
#include <stdio.h>
int main(void)
{
return on_exit(NULL, NULL);
}endef
So it appears to work in practice, but yes, I agree that this could be cleaned up.
Thanks,
Ingo
PATCH 29/52 tools/perf/build: Split out feature check: 'backtrace'
In reply to Ingo Molnar--- tools/perf/config/Makefile | 3 ++- tools/perf/config/feature-checks/Makefile | 4 ++++ tools/perf/config/feature-checks/test-backtrace.c | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-)
tools/perf/config/Makefile +2 -1
@@ -124,6 +124,7 @@ FEATURE_TESTS = \ strlcpy \ libbfd \ on-exit \ + backtrace \ libnuma $(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
@@ -438,7 +439,7 @@ ifndef NO_ON_EXIT endif ifndef NO_BACKTRACE - ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DHAVE_BACKTRACE_SUPPORT),y) + ifeq ($(feature-backtrace), 1) CFLAGS += -DHAVE_BACKTRACE_SUPPORT endif endif
tools/perf/config/feature-checks/Makefile +4 -0
@@ -22,6 +22,7 @@ FILES= \ test-strlcpy \ test-libbfd \ test-on-exit \ + test-backtrace \ test-libnuma CC := $(CC) -MD
@@ -124,6 +125,9 @@ test-libbfd: test-on-exit: $(BUILD) +test-backtrace: + $(BUILD) + -include *.d */*.d ###############################
tools/perf/config/feature-checks/test-backtrace.c new file +10 -0
@@ -0,0 +1,10 @@ +#include <execinfo.h> +#include <stdio.h> + +int main (void ) +{ +backtrace (NULL ,0 ); +backtrace_symbols (NULL ,0 ); + +return 0 ; +}
Signature · 1 line
1.8.3.1
PATCH 30/52 tools/perf: Clean up util/include/linux/compiler.h
In reply to Ingo MolnarUse the standard CPP style we use in the kernel:
#ifndef foo
# define foo bar #endif
--- tools/perf/util/include/linux/compiler.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
tools/perf/util/include/linux/compiler.h +10 -5
@@ -2,20 +2,25 @@#define _PERF_LINUX_COMPILER_H_#ifndef __always_inline -#define __always_inline inline +# define __always_inline inline __attribute__((always_inline))#endif +#define __user +#ifndef __attribute_const__ -#define __attribute_const__ +# define __attribute_const__#endif #ifndef __maybe_unused -#define __maybe_unused __attribute__((unused)) +# define __maybe_unused __attribute__((unused)) +#endif + +#ifndef __packed +# define __packed __attribute__((__packed__))#endif -#define __packed __attribute__((__packed__))#ifndef __force -#define __force +# define __force#endif #endif
Signature · 1 line
1.8.3.1
PATCH 31/52 tools/perf: Turn strlcpy() into a __weak function
In reply to Ingo MolnarThe strlcpy() feature check slows every build unnecessarily - so make it a __weak function so it does not have to be auto-detected.
If the libc (or any other library) has an strlcpy() implementation it will be used - otherwise our fallback is active.
--- tools/perf/config/Makefile | 7 ------- tools/perf/config/feature-checks/Makefile | 4 ---- tools/perf/config/feature-checks/test-strlcpy.c | 8 -------- tools/perf/util/cache.h | 3 +-- tools/perf/util/include/linux/compiler.h | 4 ++++ tools/perf/util/path.c | 10 +++++++--- 6 files changed, 12 insertions(+), 24 deletions(-)
tools/perf/config/Makefile +0 -7
@@ -121,7 +121,6 @@ FEATURE_TESTS = \ libperl \ libpython \ libpython-version \ - strlcpy \ libbfd \ on-exit \ backtrace \
@@ -426,12 +425,6 @@ else endif endif -ifndef NO_STRLCPY - ifeq ($(feature-strlcpy), 1) - CFLAGS += -DHAVE_STRLCPY_SUPPORT - endif -endif - ifndef NO_ON_EXIT ifeq ($(feature-on-exit), 1) CFLAGS += -DHAVE_ON_EXIT_SUPPORT
tools/perf/config/feature-checks/Makefile +0 -4
@@ -19,7 +19,6 @@ FILES= \ test-libperl \ test-libpython \ test-libpython-version \ - test-strlcpy \ test-libbfd \ test-on-exit \ test-backtrace \
@@ -116,9 +115,6 @@ test-libpython: test-libpython-version: $(BUILD) $(FLAGS_PYTHON_EMBED) -test-strlcpy: - $(BUILD) - test-libbfd: $(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl
tools/perf/config/feature-checks/test-strlcpy.c deleted +0 -8
@@ -1,8 +0,0 @@ -#include <stdlib.h> -extern size_t strlcpy (char *dest,const char *src,size_t size); - -int main (void ) -{ -strlcpy (NULL ,NULL ,0 ); -return 0 ; -}
tools/perf/util/cache.h +1 -2
@@ -70,8 +70,7 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2extern char *perf_pathdup (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); -#ifndef HAVE_STRLCPY_SUPPORT +/* Matches the libc/libbsd function attribute so we declare this unconditionally: */ extern size_t strlcpy (char *dest,const char *src,size_t size); -#endif #endif /* __PERF_CACHE_H */
tools/perf/util/include/linux/compiler.h +4 -0
@@ -23,4 +23,8 @@# define __force#endif +#ifndef __weak +# define __weak __attribute__((weak)) +#endif +#endif
tools/perf/util/path.c +7 -3
@@ -22,19 +22,23 @@ static const char *get_perf_dir(void)return "." ; } -#ifndef HAVE_STRLCPY_SUPPORT -size_t strlcpy (char *dest,const char *src,size_t size) +/* +* If libc has strlcpy() then that version will override this +* implementation: +*/ +size_t __weak strlcpy (char *dest,const char *src,size_t size) {size_t ret =strlen (src);if (size) {size_t len = (ret >= size) ? size -1 : ret; +memcpy (dest, src, len); dest[len] ='\0' ; } +return ret; } -#endif static char *get_pathname (void ) {
Signature · 1 line
1.8.3.1
PATCH 32/52 tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target
In reply to Ingo MolnarConcatenate all feature checks into test-all.c.
This can be built and checked faster than all the individual tests.
If test-all fails then we still check all the individual features, so this is a pure speedup, it should have no effects on functionality.
--- tools/perf/config/Makefile | 45 +++++++++-- tools/perf/config/feature-checks/Makefile | 3 + tools/perf/config/feature-checks/test-all.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 238 insertions(+), 6 deletions(-)
tools/perf/config/Makefile +39 -6
@@ -89,17 +89,21 @@ CFLAGS += -std=gnu99 EXTLIBS = -lelf -lpthread -lrt -lm -ldl -feature_check = $(eval $(feature_check_code)); $(info CHK: config/feature-checks/test-$(1)) +feature_check = $(eval $(feature_check_code)) define feature_check_code - feature-$(2) := $(shell make -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) + feature-$(1) := $(shell $(MAKE) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) +endef + +feature_set = $(eval $(feature_set_code)) +define feature_set_code + feature-$(1) := 1 endef # # Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: # -$(info Testing features:) -$(shell make -i -j -C config/feature-checks >/dev/null 2>&1) -$(info done) +$(info ) +$(info Auto-detecting system features:) FEATURE_TESTS = \ hello \
@@ -126,7 +130,36 @@ FEATURE_TESTS = \ backtrace \ libnuma -$(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test))) +# +# Special fast-path for the 'all features are available' case: +# +$(call feature_check,all) + +ifeq ($(feature-all), 1) + $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat))) +else + $(shell $(MAKE) -i -j -C config/feature-checks >/dev/null 2>&1) + $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat))) +endif + +feature_print = $(eval $(feature_print_code)) + +# +# Print the result of the feature test: +# +define feature_print_code + ifeq ($(feature-$(1)), 1) + MSG := $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1)) + else + MSG := $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1)) + endif + $(info $(MSG)) +endef + +$(foreach feat,$(FEATURE_TESTS) DUMMY,$(call feature_print,$(feat))) + +# newline at the end of the feature printouts: +$(info ) ifeq ($(feature-stackprotector-all), 1) CFLAGS += -fstack-protector-all
tools/perf/config/feature-checks/Makefile +3 -0
@@ -32,6 +32,9 @@ BUILD = $(CC) -o $(OUTPUT)$@ [email protected] ############################### +test-all: + $(BUILD) -Werror -fstack-protector -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl + test-hello: $(BUILD)
tools/perf/config/feature-checks/test-all.c new file +196 -0
196 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target
On Tue, Oct 08, 2013 at 12:11:02PM +0200, Ingo Molnar wrote:
SNIP
tools/perf/config/feature-checks/Makefile BUILD = $(CC) -o $(OUTPUT)$@ [email protected] · line 37
Quoted 11 lines
tools/perf/config/feature-checks/Makefile +3
-0@@ -32,6 +32,9 @@ BUILD = $(CC) -o $(OUTPUT)$@ [email protected] ############################### +test-all: + $(BUILD) -Werror -fstack-protector -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl +
missing -fstack-protector-all ? ;-)
jirka
Re: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target
Quoted 10 lines · Jiri Olsa
On Tue, Oct 08, 2013 at 12:11:02PM +0200, Ingo Molnar wrote:
SNIP
Quoted 6 lines
tools/perf/config/feature-checks/Makefile +0
-0@@ -32,6 +32,9 @@ BUILD = $(CC) -o $(OUTPUT)$@ [email protected]
Quoted 7 lines
tools/perf/config/feature-checks/Makefile BUILD = $(CC) -o $(OUTPUT)$@ [email protected] · line 37
Quoted 5 lines
tools/perf/config/feature-checks/Makefile +3
-0############################### +test-all: + $(BUILD) -Werror -fstack-protector -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl +missing -fstack-protector-all ? ;-)
Indeed :-) Fixed.
Thanks,
Ingo
Namhyung Kim
maintainerRe: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target
In reply to Ingo Molnartools/perf/config/feature-checks/Makefile BUILD = $(CC) -o $(OUTPUT)$@ [email protected] · line 36
Quoted 2 lines · Ingo Molnar
tools/perf/config/feature-checks/Makefile +2
-0+test-all: + $(BUILD) -Werror -fstack-protector -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl
Also missed -Wstack-protector. And duplicate -Werror.
Anyway, it'd be great to generate this flags as well as source file automatically.
Thanks,
Namhyung
Re: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target
Quoted 10 lines · Namhyung Kim
Quoted 6 lines · Ingo Molnar
(quoted diff) +2
-3+test-all: + $(BUILD) -Werror -fstack-protector -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED)$(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl
Also missed -Wstack-protector. And duplicate -Werror.
Quoted 2 lines
Anyway, it'd be great to generate this flags as well as source file automatically.
Well, the source file would mean some extra construction overhead during detection - but generating the flags ought to be possible, by putting the test-all entry last and generating a rolling ALL_FLAGS variable via the rules above it.
Would you like to write such a patch?
Thanks,
Ingo
Namhyung Kim
maintainerRe: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target
Quoted 15 lines · Ingo Molnar
Quoted 10 lines · Namhyung Kim
Quoted 6 lines · Ingo Molnar
(quoted diff) +2
-3+test-all: + $(BUILD) -Werror -fstack-protector -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED)$(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl
Also missed -Wstack-protector. And duplicate -Werror.
Quoted 2 lines
Anyway, it'd be great to generate this flags as well as source file automatically.
Quoted 6 lines
Well, the source file would mean some extra construction overhead during detection - but generating the flags ought to be possible, by putting the test-all entry last and generating a rolling
ALL_FLAGSvariable via the rules above it.Would you like to write such a patch?
Well, I'll try to do it tomorrow. :)
Thanks,
Namhyung
PATCH 33/52 tools/perf/build: Speed up git-version test on re-make
In reply to Ingo Molnarutil/PERF-VERSION-GEN is currently executed on every build attempt, and this script can take a lot of time on trees that are at a significant git-distance from Linus's tree:
$ time util/PERF-VERSION-GEN
real 0m4.343s user 0m4.176s sys 0m0.140s
It also takes a lot of time if the Git repository is network attached, etc., because the commands it uses:
TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null )
has to count commits from the nearest tag and thus has to access (and decompress) every git commit blob on the relevant version path.
Even on Linus's tree it takes 0.28 seconds on a fast box to count all the commits and get the git version string:
$ time util/PERF-VERSION-GEN
real 0m0.279s user 0m0.247s sys 0m0.025s
But the version string only has to be regenerated if the git repository's head commit changes. So add a dependency of ../../.git/HEAD and touch the file every time it's regenerated, so that Make's build rules can pick it up and cache the result:
make: `PERF-VERSION-FILE' is up to date.
real 0m0.184s user 0m0.117s sys 0m0.026s
--- tools/perf/Makefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
tools/perf/Makefile +13 -2
@@ -70,8 +70,9 @@ ifneq ($(OUTPUT),) #$(info Determined 'OUTPUT' to be $(OUTPUT)) endif -$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE +$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) + @touch $(OUTPUT)PERF-VERSION-FILE CC = $(CROSS_COMPILE)gcc AR = $(CROSS_COMPILE)ar
@@ -814,6 +815,16 @@ clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean $(RM) $(OUTPUT)util/*-flex* $(python-clean) +# +# Trick: if ../../.git does not exist - we are building out of tree for example, +# then force version regeneration: +# +ifeq ($(wildcard ../../.git/HEAD),) + GIT-HEAD-PHONY = ../../.git/HEAD +else + GIT-HEAD-PHONY = +endif + .PHONY: all install clean strip $(LIBTRACEEVENT) $(LIBLK) .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell -.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS +.PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope .FORCE-PERF-CFLAGS
Signature · 1 line
1.8.3.1
PATCH 34/52 tools/perf/build: Speed up the final link
In reply to Ingo Molnarlibtraceevent.a and liblk.a rules have always-missed dependencies, which causes python.so to be relinked at every build attempt - even if none of the affected code changes.
This slows down re-builds unnecessarily, by adding more than a second to the build time:
comet:~/tip/tools/perf> time make
...
SUBDIR /fast/mingo/tip/tools/lib/lk/
make[1]: `liblk.a' is up to date.
SUBDIR /fast/mingo/tip/tools/lib/traceevent/
LINK perf
GEN python/perf.so
real 0m1.701s user 0m1.338s sys 0m0.301s
Add the (trivial) dependencies to not force a re-link.
This speeds up an empty re-build enormously:
comet:~/tip/tools/perf> time make
...
real 0m0.207s user 0m0.134s sys 0m0.028s
[ This adds some coupling between the build dependencies of
libtraceevent and liblk - but until those stay relatively simple this should not be an issue. ]
--- tools/perf/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/perf/Makefile +7 -3
@@ -669,15 +669,19 @@ $(LIB_FILE): $(LIB_OBJS) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS) # libtraceevent.a -$(LIBTRACEEVENT): +TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch]) + +$(LIBTRACEEVENT): $(TE_SOURCES) $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libtraceevent.a $(LIBTRACEEVENT)-clean: $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) clean +LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch]) + # if subdir is set, we've been called from above so target has been built # already -$(LIBLK): +$(LIBLK): $(LIBLK_SOURCES) ifeq ($(subdir),) $(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) liblk.a endif
@@ -825,6 +829,6 @@ else GIT-HEAD-PHONY = endif -.PHONY: all install clean strip $(LIBTRACEEVENT) $(LIBLK) +.PHONY: all install clean strip .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope .FORCE-PERF-CFLAGS
Signature · 1 line
1.8.3.1
PATCH 35/52 tools/perf: Fix double/triple-build of the feature detection logic during 'make install' et al
In reply to Ingo MolnarLinus reported the following perf build system bug:
'Another annoyance during that make was that "make install" seems to
want to re-make the thing I just built. That's absolutely horrible, [...]'
The thing that got re-built were 'only' the (numerous) feature checks, not the whole project - but still it was mighty annoying as the feature checks took 9+ seconds even on reasonably fast boxes.
Even with the autodep patches where feature detection is much faster it wastes resources, wastes screen real estate and confuses users if we execute feature detection twice.
There were two sources for these unnecessary re-builds of the feature checks:
- Unnecessary nested invocations of $(MAKE), apparently to be able to do conditional compilation dependent on documentation tools presence. Use straight dependencies instead, with no nesting.
- A direct invocation of $(MAKE) to rebuild the PERF-VERSION-FILE. This is apparently done to be able to include it into the Makefile:
-include $(OUTPUT)PERF-VERSION-FILE
but that's entirely pointless for two reasons: 1) the version file gets regenerated by the initial build pass anyway, 2) including it is futile, given its contents:
#define PERF_VERSION "3.12.rc3.g8510c7"
'make' will interpret that as a comment line...
So just remove this part of the doc-generation logic.
With these things fixed a 'make install' now rebuilds only what is needed.
A repeated 'make install' on an already built tree is super fast now, it finishes in under 0.3 seconds:
#
# After the patch:
#
$ time make install
...
real 0m0.280s user 0m0.162s sys 0m0.054s
Prior all the autodep changes and prior this fix, a repeat 'make install' took 24.1 seconds (!) on the same system:
#
# Before the patches:
#
$ time make install
...
real 0m24.109s user 0m21.171s sys 0m2.449s
Which almost entirely was caused by fixable build system fat. We are now literally ~86 times faster.
A fresh rebuild and install now takes just 11.4 seconds:
#
# After the patch:
#
$ make clean $ time make -j16 install
...
real 0m11.457s user 1m43.411s sys 0m7.610s
Without the patches it took 27.8 seconds:
#
# Before the patches:
#
$ make clean $ time make -j16 install
...
real 0m27.801s user 1m59.242s sys 0m9.749s
So even in the complete rebuild case we are now ~2.5 times faster.
--- tools/perf/Documentation/Makefile | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
tools/perf/Documentation/Makefile +4 -13
@@ -192,13 +192,14 @@ do-install-man: man install-man: check-man-tools man -try-install-man: ifdef missing_tools - $(warning Please install $(missing_tools) to have the man pages installed) + DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed) else - $(MAKE) do-install-man + DO_INSTALL_MAN = do-install-man endif +try-install-man: $(DO_INSTALL_MAN) + install-info: info $(INSTALL) -d -m 755 $(DESTDIR)$(infodir) $(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir)
@@ -216,14 +217,6 @@ install-pdf: pdf #install-html: html # '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir) -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),tags) -$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE - $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) $(OUTPUT)PERF-VERSION-FILE - --include $(OUTPUT)PERF-VERSION-FILE -endif -endif # # Determine "include::" file references in asciidoc files.
@@ -342,5 +335,3 @@ $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt #quick-install-html: # '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir) - -.PHONY: .FORCE-PERF-VERSION-FILE
Signature · 1 line
1.8.3.1
PATCH 36/52 tools/perf/build: Invoke feature-checks 'clean' target from the main Makefile
In reply to Ingo Molnarconfig/Makefile is not included for the 'clean' target, so invoke the config/feature-checks/Makefile 'clean' target from Makefile.perf.
--- tools/perf/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
tools/perf/Makefile +9 -2
@@ -809,7 +809,14 @@ $(INSTALL_DOC_TARGETS): ### Cleaning rules -clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean +# +# This is here, not in config/Makefile, because config/Makefile does +# not get included for the clean target: +# +config-clean: + @$(MAKE) -C config/feature-checks clean + +clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean config-clean $(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS) $(RM) $(ALL_PROGRAMS) perf $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
@@ -829,6 +836,6 @@ else GIT-HEAD-PHONY = endif -.PHONY: all install clean strip +.PHONY: all install clean config-clean strip .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope .FORCE-PERF-CFLAGS
Signature · 1 line
1.8.3.1
PATCH 37/52 tools/perf/build: Speed up auto-detection
In reply to Ingo MolnarThe detection of certain rarely detected features can be delayed to when they are actually needed.
So speed up the common case of auto-detection by pre-building only a core set of features and populating only their feature-flags.
[ Features not listed in CORE_FEATURES need to built explicitly
via the feature_check() function. ]
(Also order the feature names alphabetically, while at it.)
--- tools/perf/config/Makefile | 49 +++++++++++++++++++++++++++++-------------------- tools/perf/config/feature-checks/Makefile | 31 ++++++++++++++++--------------- 2 files changed, 45 insertions(+), 35 deletions(-)
tools/perf/config/Makefile +29 -20
@@ -105,30 +105,36 @@ endef $(info ) $(info Auto-detecting system features:) -FEATURE_TESTS = \ - hello \ - stackprotector-all \ - stackprotector \ - volatile-register-var \ +# +# Note that this is not a complete list of all feature tests, just +# those that are typically built on a fully configured system. +# +# [ Feature tests not mentioned here have to be built explicitly in +# the rule that uses them - an example for that is the 'bionic' +# feature check. ] +# +CORE_FEATURE_TESTS = \ + backtrace \ + dwarf \ fortify-source \ - bionic \ - libelf \ glibc \ - dwarf \ - libelf-mmap \ - libelf-getphdrnum \ - libunwind \ - libaudit \ - libslang \ gtk2 \ gtk2-infobar \ + libaudit \ + libbfd \ + libelf \ + libelf-getphdrnum \ + libelf-mmap \ + libnuma \ libperl \ libpython \ libpython-version \ - libbfd \ + libslang \ + libunwind \ on-exit \ - backtrace \ - libnuma + stackprotector \ + stackprotector-all \ + volatile-register-var # # Special fast-path for the 'all features are available' case:
@@ -136,10 +142,13 @@ FEATURE_TESTS = \ $(call feature_check,all) ifeq ($(feature-all), 1) - $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat))) + # + # test-all.c passed - just set all the core feature flags to 1: + # + $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat))) else - $(shell $(MAKE) -i -j -C config/feature-checks >/dev/null 2>&1) - $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat))) + $(shell $(MAKE) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1) + $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat))) endif feature_print = $(eval $(feature_print_code))
@@ -156,7 +165,7 @@ define feature_print_code $(info $(MSG)) endef -$(foreach feat,$(FEATURE_TESTS) DUMMY,$(call feature_print,$(feat))) +$(foreach feat,$(CORE_FEATURE_TESTS) DUMMY,$(call feature_print,$(feat))) # newline at the end of the feature printouts: $(info )
tools/perf/config/feature-checks/Makefile +16 -15
@@ -1,28 +1,29 @@ FILES= \ - test-hello \ - test-stackprotector-all \ - test-stackprotector \ - test-volatile-register-var \ - test-fortify-source \ + test-all \ + test-backtrace \ test-bionic \ - test-libelf \ - test-glibc \ test-dwarf \ - test-libelf-mmap \ - test-libelf-getphdrnum \ - test-libunwind \ - test-libaudit \ - test-libslang \ + test-fortify-source \ + test-glibc \ test-gtk2 \ test-gtk2-infobar \ + test-hello \ + test-libaudit \ + test-libbfd \ + test-libelf \ + test-libelf-getphdrnum \ + test-libelf-mmap \ + test-libnuma \ test-libperl \ test-libpython \ test-libpython-version \ - test-libbfd \ + test-libslang \ + test-libunwind \ test-on-exit \ - test-backtrace \ - test-libnuma + test-stackprotector-all \ + test-stackprotector \ + test-volatile-register-var CC := $(CC) -MD
Signature · 1 line
1.8.3.1
PATCH 38/52 tools/perf/build: Improve printout-of auto-detected features
In reply to Ingo MolnarChange the print-out of auto-detected features by making sure that repeat invocations of 'make' when all features are successfully detected do not produce the (rather lengthy) autodetection printout.
( When one or more features are missing then we still print out the
feature detection table, to make sure people are aware of the resulting limitations. )
--- tools/perf/config/Makefile | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-)
tools/perf/config/Makefile +33 -9
@@ -102,8 +102,6 @@ endef # # Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: # -$(info ) -$(info Auto-detecting system features:) # # Note that this is not a complete list of all feature tests, just
@@ -137,9 +135,33 @@ CORE_FEATURE_TESTS = \ volatile-register-var # +# So here we detect whether test-all was rebuilt, to be able +# to skip the print-out of the long features list if the file +# existed before and after it was built: +# +ifeq ($(wildcard config/feature-checks/test-all),) + test-all-failed := 1 +else + test-all-failed := 0 +endif + +# # Special fast-path for the 'all features are available' case: # -$(call feature_check,all) +$(call feature_check,all,$(MSG)) + +# +# Just in case the build freshly failed, make sure we print the +# feature matrix: +# +ifeq ($(feature-all), 0) + test-all-failed := 1 +endif + +ifeq ($(test-all-failed),1) + $(info ) + $(info Auto-detecting system features:) +endif ifeq ($(feature-all), 1) #
@@ -151,11 +173,10 @@ else $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat))) endif -feature_print = $(eval $(feature_print_code)) - # # Print the result of the feature test: # +feature_print = $(eval $(feature_print_code)) define feature_print_code ifeq ($(feature-$(1)), 1) MSG := $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
@@ -165,10 +186,13 @@ define feature_print_code $(info $(MSG)) endef -$(foreach feat,$(CORE_FEATURE_TESTS) DUMMY,$(call feature_print,$(feat))) - -# newline at the end of the feature printouts: -$(info ) +# +# Only print out our features if we rebuilt the testcases or if a test failed: +# +ifeq ($(test-all-failed), 1) + $(foreach feat,$(CORE_FEATURE_TESTS) DUMMY,$(call feature_print,$(feat))) + $(info ) +endif ifeq ($(feature-stackprotector-all), 1) CFLAGS += -fstack-protector-all
Signature · 1 line
1.8.3.1
PATCH 39/52 tools/perf/build: Automatically build in parallel, based on number of CPUs in the system
In reply to Ingo MolnarImplement automatic parallel builds when building in tools/perf:
$ time make
# [ perf build: Doing 'make -j12' parallel build. ]
Auto-detecting system features:
...
real 0m9.265s user 0m59.888s sys 0m6.082s
On GNU make achieving this is not particularly easy, it requires a separate makefile, which then invokes the main Makefile.
( Note: this patch adds Makefile.parallel to show the concept - the two
makefiles will be flipped in the next patch to avoid having to specify -f to get parallelism in the default build. )
--- tools/perf/Makefile.parallel | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
tools/perf/Makefile.parallel new file +26 -0
@@ -0,0 +1,26 @@ +# +# Do a parallel build with multiple jobs, based on the number of CPUs online +# in this system: 'make -j8' on a 8-CPU system, etc. +# +# (To override it, run 'make JOBS=1' and similar.) +# +ifeq ($(JOBS),) + JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null) + ifeq ($(JOBS),) + JOBS := 1 + endif +endif + +export JOBS + +$(info $(shell printf '# [ perf build: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build. ]\n')) + +# +# Needed if no target specified: +# +all: + @$(MAKE) --no-print-directory -j$(JOBS) $@ + +%: + @$(MAKE) --no-print-directory -j$(JOBS) $@ +
Signature · 1 line
1.8.3.1
RE: [PATCH 39/52] tools/perf/build: Automatically build in parallel, based on number of CPUs in the syst
tools/perf/Makefile.parallel line 8
Quoted 2 lines · Ingo Molnar
tools/perf/Makefile.parallel new file +2
-0+ifeq ($(JOBS),) + JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
nproc is probably ubiquitous enough to use now
(available since coreutils 8.1 (end of 2009))
As well as being more concise, it will take
account of offline CPUs etc.
Quoted 4 lines
tools/perf/Makefile.parallel new file +4
-0+ ifeq ($(JOBS),) + JOBS := 1 + endif +endif
Re: [PATCH 39/52] tools/perf/build: Automatically build in parallel, based on number of CPUs in the syst
Quoted 9 lines · Pádraig Brady
tools/perf/Makefile.parallel line 8
Quoted 2 lines · Ingo Molnar
tools/perf/Makefile.parallel new file +2
-0+ifeq ($(JOBS),) + JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)nproc is probably ubiquitous enough to use now
(available since coreutils 8.1 (end of 2009))As well as being more concise, it will take
account of offline CPUs etc.
/proc/cpuinfo takes account of offline CPUs as well:
# grep -c ^processor /proc/cpuinfo 2>/dev/null 16
# echo 0 > /sys/devices/system/cpu/cpu11/online # grep -c ^processor /proc/cpuinfo 2>/dev/null 15
# echo 1 > /sys/devices/system/cpu/cpu11/online # grep -c ^processor /proc/cpuinfo 2>/dev/null 16
But nproc is indeed a better choice:
1)
It is scheduler syscall based and will thus will work in limited environments as well, for example when /proc is not mounted.
2)
It will also properly detect affinity-limited environments:
# taskset 1 nproc 1
3)
It is also faster than grepping /proc/cpuinfo:
# perf stat --null --repeat 100 nproc >/dev/null
Performance counter stats for 'nproc' (100 runs):
0.000652928 seconds time elapsed ( +- 0.53% )versus:
# perf stat --null --repeat 100 grep -c ^processor /proc/cpuinfo >/dev/null
Performance counter stats for 'grep -c ^processor /proc/cpuinfo' (100 runs):
0.001037034 seconds time elapsed ( +- 0.32% )so with 0.652 msecs versus 1.037 msecs it's about 60% faster than grep.
Thanks,
Ingo
PATCH 40/52 tools/perf/build: Flip Makefile.parallel and Makefile.perf
In reply to Ingo MolnarTo make it more apparent that there is not change in functionality we introduced Makefile.parallel separately and now flip it with the main Makefile, which moves into Makefile.perf.
The renames are:
Makefile.parallel => Makefile
Makefile => Makefile.perf
--- tools/perf/Makefile | 844 ++------------------------------------------------------------- tools/perf/Makefile.parallel | 26 -- tools/perf/Makefile.perf | 842 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 856 insertions(+), 856 deletions(-)
tools/perf/Makefile +14 -830
@@ -1,841 +1,25 @@ -include ../scripts/Makefile.include - -# The default target of this Makefile is... -all: - -include config/utilities.mak - -# Define V to have a more verbose compile. -# -# Define O to save output files in a separate directory. -# -# Define ARCH as name of target architecture if you want cross-builds. -# -# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds. -# -# Define NO_LIBPERL to disable perl script extension. -# -# Define NO_LIBPYTHON to disable python script extension. -# -# Define PYTHON to point to the python binary if the default -# `python' is not correct; for example: PYTHON=python2 -# -# Define PYTHON_CONFIG to point to the python-config binary if -# the default `$(PYTHON)-config' is not correct. -# -# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8 -# -# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72. -# -# Define LDFLAGS=-static to build a static binary. -# -# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds. -# -# Define NO_DWARF if you do not want debug-info analysis feature at all. -# -# Define WERROR=0 to disable treating any warnings as errors. -# -# Define NO_NEWT if you do not want TUI support. (deprecated) -# -# Define NO_SLANG if you do not want TUI support. -# -# Define NO_GTK2 if you do not want GTK+ GUI support. -# -# Define NO_DEMANGLE if you do not want C++ symbol demangling. -# -# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds) -# -# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf -# backtrace post unwind. # -# Define NO_BACKTRACE if you do not want stack backtrace debug feature +# Do a parallel build with multiple jobs, based on the number of CPUs online +# in this system: 'make -j8' on a 8-CPU system, etc. # -# Define NO_LIBNUMA if you do not want numa perf benchmark +# (To override it, run 'make JOBS=1' and similar.) # -# Define NO_LIBAUDIT if you do not want libaudit support -# -# Define NO_LIBBIONIC if you do not want bionic support - -ifeq ($(srctree),) -srctree := $(patsubst %/,%,$(dir $(shell pwd))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -#$(info Determined 'srctree' to be $(srctree)) -endif - -ifneq ($(objtree),) -#$(info Determined 'objtree' to be $(objtree)) -endif - -ifneq ($(OUTPUT),) -#$(info Determined 'OUTPUT' to be $(OUTPUT)) -endif - -$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD - @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) - @touch $(OUTPUT)PERF-VERSION-FILE - -CC = $(CROSS_COMPILE)gcc -AR = $(CROSS_COMPILE)ar - -RM = rm -f -MKDIR = mkdir -FIND = find -INSTALL = install -FLEX = flex -BISON = bison -STRIP = strip - -LK_DIR = $(srctree)/tools/lib/lk/ -TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ - -# include config/Makefile by default and rule out -# non-config cases -config := 1 - -NON_CONFIG_TARGETS := clean TAGS tags cscope help - -ifdef MAKECMDGOALS -ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),) - config := 0 -endif -endif - -ifeq ($(config),1) -include config/Makefile -endif - -export prefix bindir sharedir sysconfdir - -# sparse is architecture-neutral, which means that we need to tell it -# explicitly what architecture to check for. Fix this up for yours.. -SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ - -# Guard against environment variables -BUILTIN_OBJS = -LIB_H = -LIB_OBJS = -PYRF_OBJS = -SCRIPT_SH = - -SCRIPT_SH += perf-archive.sh - -grep-libs = $(filter -l%,$(1)) -strip-libs = $(filter-out -l%,$(1)) - -ifneq ($(OUTPUT),) - TE_PATH=$(OUTPUT) -ifneq ($(subdir),) - LK_PATH=$(OUTPUT)/../lib/lk/ -else - LK_PATH=$(OUTPUT) -endif -else - TE_PATH=$(TRACE_EVENT_DIR) - LK_PATH=$(LK_DIR) -endif - -LIBTRACEEVENT = $(TE_PATH)libtraceevent.a -export LIBTRACEEVENT - -LIBLK = $(LK_PATH)liblk.a -export LIBLK - -# python extension build directories -PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/ -PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/ -PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/ -export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP - -python-clean := rm -rf $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so - -PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) -PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBLK) - -$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) - $(QUIET_GEN)CFLAGS='$(CFLAGS)' $(PYTHON_WORD) util/setup.py \ - --quiet build_ext; \ - mkdir -p $(OUTPUT)python && \ - cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/ -# -# No Perl scripts right now: -# - -SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) - -# -# Single 'perf' binary right now: -# -PROGRAMS += $(OUTPUT)perf - -# what 'all' will build and 'install' will install, in perfexecdir -ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) - -# what 'all' will build but not install in perfexecdir -OTHER_PROGRAMS = $(OUTPUT)perf - -# Set paths to tools early so that they can be used for version tests. -ifndef SHELL_PATH - SHELL_PATH = /bin/sh -endif -ifndef PERL_PATH - PERL_PATH = /usr/bin/perl -endif - -export PERL_PATH - -$(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-events-bison.c - $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c - -$(OUTPUT)util/parse-events-bison.c: util/parse-events.y - $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c -p parse_events_ - -$(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c - $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c - -$(OUTPUT)util/pmu-bison.c: util/pmu.y - $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c -p perf_pmu_ - -$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c -$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c - -LIB_FILE=$(OUTPUT)libperf.a - -LIB_H += ../../include/uapi/linux/perf_event.h -LIB_H += ../../include/linux/rbtree.h -LIB_H += ../../include/linux/list.h -LIB_H += ../../include/uapi/linux/const.h -LIB_H += ../../include/linux/hash.h -LIB_H += ../../include/linux/stringify.h -LIB_H += util/include/linux/bitmap.h -LIB_H += util/include/linux/bitops.h -LIB_H += util/include/linux/compiler.h -LIB_H += util/include/linux/const.h -LIB_H += util/include/linux/ctype.h -LIB_H += util/include/linux/kernel.h -LIB_H += util/include/linux/list.h -LIB_H += util/include/linux/export.h -LIB_H += util/include/linux/magic.h -LIB_H += util/include/linux/poison.h -LIB_H += util/include/linux/prefetch.h -LIB_H += util/include/linux/rbtree.h -LIB_H += util/include/linux/rbtree_augmented.h -LIB_H += util/include/linux/string.h -LIB_H += util/include/linux/types.h -LIB_H += util/include/linux/linkage.h -LIB_H += util/include/asm/asm-offsets.h -LIB_H += util/include/asm/bug.h -LIB_H += util/include/asm/byteorder.h -LIB_H += util/include/asm/hweight.h -LIB_H += util/include/asm/swab.h -LIB_H += util/include/asm/system.h -LIB_H += util/include/asm/uaccess.h -LIB_H += util/include/dwarf-regs.h -LIB_H += util/include/asm/dwarf2.h -LIB_H += util/include/asm/cpufeature.h -LIB_H += util/include/asm/unistd_32.h -LIB_H += util/include/asm/unistd_64.h -LIB_H += perf.h -LIB_H += util/annotate.h -LIB_H += util/cache.h -LIB_H += util/callchain.h -LIB_H += util/build-id.h -LIB_H += util/debug.h -LIB_H += util/sysfs.h -LIB_H += util/pmu.h -LIB_H += util/event.h -LIB_H += util/evsel.h -LIB_H += util/evlist.h -LIB_H += util/exec_cmd.h -LIB_H += util/types.h -LIB_H += util/levenshtein.h -LIB_H += util/machine.h -LIB_H += util/map.h -LIB_H += util/parse-options.h -LIB_H += util/parse-events.h -LIB_H += util/quote.h -LIB_H += util/util.h -LIB_H += util/xyarray.h -LIB_H += util/header.h -LIB_H += util/help.h -LIB_H += util/session.h -LIB_H += util/strbuf.h -LIB_H += util/strlist.h -LIB_H += util/strfilter.h -LIB_H += util/svghelper.h -LIB_H += util/tool.h -LIB_H += util/run-command.h -LIB_H += util/sigchain.h -LIB_H += util/dso.h -LIB_H += util/symbol.h -LIB_H += util/color.h -LIB_H += util/values.h -LIB_H += util/sort.h -LIB_H += util/hist.h -LIB_H += util/thread.h -LIB_H += util/thread_map.h -LIB_H += util/trace-event.h -LIB_H += util/probe-finder.h -LIB_H += util/dwarf-aux.h -LIB_H += util/probe-event.h -LIB_H += util/pstack.h -LIB_H += util/cpumap.h -LIB_H += util/top.h -LIB_H += $(ARCH_INCLUDE) -LIB_H += util/cgroup.h -LIB_H += $(LIB_INCLUDE)traceevent/event-parse.h -LIB_H += util/target.h -LIB_H += util/rblist.h -LIB_H += util/intlist.h -LIB_H += util/perf_regs.h -LIB_H += util/unwind.h -LIB_H += util/vdso.h -LIB_H += ui/helpline.h -LIB_H += ui/progress.h -LIB_H += ui/util.h -LIB_H += ui/ui.h - -LIB_OBJS += $(OUTPUT)util/abspath.o -LIB_OBJS += $(OUTPUT)util/alias.o -LIB_OBJS += $(OUTPUT)util/annotate.o -LIB_OBJS += $(OUTPUT)util/build-id.o -LIB_OBJS += $(OUTPUT)util/config.o -LIB_OBJS += $(OUTPUT)util/ctype.o -LIB_OBJS += $(OUTPUT)util/sysfs.o -LIB_OBJS += $(OUTPUT)util/pmu.o -LIB_OBJS += $(OUTPUT)util/environment.o -LIB_OBJS += $(OUTPUT)util/event.o -LIB_OBJS += $(OUTPUT)util/evlist.o -LIB_OBJS += $(OUTPUT)util/evsel.o -LIB_OBJS += $(OUTPUT)util/exec_cmd.o -LIB_OBJS += $(OUTPUT)util/help.o -LIB_OBJS += $(OUTPUT)util/levenshtein.o -LIB_OBJS += $(OUTPUT)util/parse-options.o -LIB_OBJS += $(OUTPUT)util/parse-events.o -LIB_OBJS += $(OUTPUT)util/path.o -LIB_OBJS += $(OUTPUT)util/rbtree.o -LIB_OBJS += $(OUTPUT)util/bitmap.o -LIB_OBJS += $(OUTPUT)util/hweight.o -LIB_OBJS += $(OUTPUT)util/run-command.o -LIB_OBJS += $(OUTPUT)util/quote.o -LIB_OBJS += $(OUTPUT)util/strbuf.o -LIB_OBJS += $(OUTPUT)util/string.o -LIB_OBJS += $(OUTPUT)util/strlist.o -LIB_OBJS += $(OUTPUT)util/strfilter.o -LIB_OBJS += $(OUTPUT)util/top.o -LIB_OBJS += $(OUTPUT)util/usage.o -LIB_OBJS += $(OUTPUT)util/wrapper.o -LIB_OBJS += $(OUTPUT)util/sigchain.o -LIB_OBJS += $(OUTPUT)util/dso.o -LIB_OBJS += $(OUTPUT)util/symbol.o -LIB_OBJS += $(OUTPUT)util/symbol-elf.o -LIB_OBJS += $(OUTPUT)util/color.o -LIB_OBJS += $(OUTPUT)util/pager.o -LIB_OBJS += $(OUTPUT)util/header.o -LIB_OBJS += $(OUTPUT)util/callchain.o -LIB_OBJS += $(OUTPUT)util/values.o -LIB_OBJS += $(OUTPUT)util/debug.o -LIB_OBJS += $(OUTPUT)util/machine.o -LIB_OBJS += $(OUTPUT)util/map.o -LIB_OBJS += $(OUTPUT)util/pstack.o -LIB_OBJS += $(OUTPUT)util/session.o -LIB_OBJS += $(OUTPUT)util/thread.o -LIB_OBJS += $(OUTPUT)util/thread_map.o -LIB_OBJS += $(OUTPUT)util/trace-event-parse.o -LIB_OBJS += $(OUTPUT)util/parse-events-flex.o -LIB_OBJS += $(OUTPUT)util/parse-events-bison.o -LIB_OBJS += $(OUTPUT)util/pmu-flex.o -LIB_OBJS += $(OUTPUT)util/pmu-bison.o -LIB_OBJS += $(OUTPUT)util/trace-event-read.o -LIB_OBJS += $(OUTPUT)util/trace-event-info.o -LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o -LIB_OBJS += $(OUTPUT)util/svghelper.o -LIB_OBJS += $(OUTPUT)util/sort.o -LIB_OBJS += $(OUTPUT)util/hist.o -LIB_OBJS += $(OUTPUT)util/probe-event.o -LIB_OBJS += $(OUTPUT)util/util.o -LIB_OBJS += $(OUTPUT)util/xyarray.o -LIB_OBJS += $(OUTPUT)util/cpumap.o -LIB_OBJS += $(OUTPUT)util/cgroup.o -LIB_OBJS += $(OUTPUT)util/target.o -LIB_OBJS += $(OUTPUT)util/rblist.o -LIB_OBJS += $(OUTPUT)util/intlist.o -LIB_OBJS += $(OUTPUT)util/vdso.o -LIB_OBJS += $(OUTPUT)util/stat.o -LIB_OBJS += $(OUTPUT)util/record.o - -LIB_OBJS += $(OUTPUT)ui/setup.o -LIB_OBJS += $(OUTPUT)ui/helpline.o -LIB_OBJS += $(OUTPUT)ui/progress.o -LIB_OBJS += $(OUTPUT)ui/util.o -LIB_OBJS += $(OUTPUT)ui/hist.o -LIB_OBJS += $(OUTPUT)ui/stdio/hist.o - -LIB_OBJS += $(OUTPUT)arch/common.o - -LIB_OBJS += $(OUTPUT)tests/parse-events.o -LIB_OBJS += $(OUTPUT)tests/dso-data.o -LIB_OBJS += $(OUTPUT)tests/attr.o -LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o -LIB_OBJS += $(OUTPUT)tests/open-syscall.o -LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o -LIB_OBJS += $(OUTPUT)tests/open-syscall-tp-fields.o -LIB_OBJS += $(OUTPUT)tests/mmap-basic.o -LIB_OBJS += $(OUTPUT)tests/perf-record.o -LIB_OBJS += $(OUTPUT)tests/rdpmc.o -LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o -LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o -LIB_OBJS += $(OUTPUT)tests/pmu.o -LIB_OBJS += $(OUTPUT)tests/hists_link.o -LIB_OBJS += $(OUTPUT)tests/python-use.o -LIB_OBJS += $(OUTPUT)tests/bp_signal.o -LIB_OBJS += $(OUTPUT)tests/bp_signal_overflow.o -LIB_OBJS += $(OUTPUT)tests/task-exit.o -LIB_OBJS += $(OUTPUT)tests/sw-clock.o -ifeq ($(ARCH),x86) -LIB_OBJS += $(OUTPUT)tests/perf-time-to-tsc.o -endif -LIB_OBJS += $(OUTPUT)tests/code-reading.o -LIB_OBJS += $(OUTPUT)tests/sample-parsing.o -LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o - -BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o -BUILTIN_OBJS += $(OUTPUT)builtin-bench.o -# Benchmark modules -BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o -BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o -ifeq ($(RAW_ARCH),x86_64) -BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o -BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o -endif -BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o -BUILTIN_OBJS += $(OUTPUT)bench/mem-memset.o - -BUILTIN_OBJS += $(OUTPUT)builtin-diff.o -BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o -BUILTIN_OBJS += $(OUTPUT)builtin-help.o -BUILTIN_OBJS += $(OUTPUT)builtin-sched.o -BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o -BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o -BUILTIN_OBJS += $(OUTPUT)builtin-list.o -BUILTIN_OBJS += $(OUTPUT)builtin-record.o -BUILTIN_OBJS += $(OUTPUT)builtin-report.o -BUILTIN_OBJS += $(OUTPUT)builtin-stat.o -BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o -BUILTIN_OBJS += $(OUTPUT)builtin-top.o -BUILTIN_OBJS += $(OUTPUT)builtin-script.o -BUILTIN_OBJS += $(OUTPUT)builtin-probe.o -BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o -BUILTIN_OBJS += $(OUTPUT)builtin-lock.o -BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o -BUILTIN_OBJS += $(OUTPUT)builtin-inject.o -BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o -BUILTIN_OBJS += $(OUTPUT)builtin-mem.o - -PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT) - -# We choose to avoid "if .. else if .. else .. endif endif" -# because maintaining the nesting to match is a pain. If -# we had "elif" things would have been much nicer... - --include arch/$(ARCH)/Makefile - -ifneq ($(OUTPUT),) - CFLAGS += -I$(OUTPUT) -endif - -ifdef NO_LIBELF -EXTLIBS := $(filter-out -lelf,$(EXTLIBS)) - -# Remove ELF/DWARF dependent codes -LIB_OBJS := $(filter-out $(OUTPUT)util/symbol-elf.o,$(LIB_OBJS)) -LIB_OBJS := $(filter-out $(OUTPUT)util/dwarf-aux.o,$(LIB_OBJS)) -LIB_OBJS := $(filter-out $(OUTPUT)util/probe-event.o,$(LIB_OBJS)) -LIB_OBJS := $(filter-out $(OUTPUT)util/probe-finder.o,$(LIB_OBJS)) - -BUILTIN_OBJS := $(filter-out $(OUTPUT)builtin-probe.o,$(BUILTIN_OBJS)) - -# Use minimal symbol handling -LIB_OBJS += $(OUTPUT)util/symbol-minimal.o - -else # NO_LIBELF -ifndef NO_DWARF - LIB_OBJS += $(OUTPUT)util/probe-finder.o - LIB_OBJS += $(OUTPUT)util/dwarf-aux.o -endif # NO_DWARF -endif # NO_LIBELF - -ifndef NO_LIBUNWIND - LIB_OBJS += $(OUTPUT)util/unwind.o -endif -LIB_OBJS += $(OUTPUT)tests/keep-tracking.o - -ifndef NO_LIBAUDIT - BUILTIN_OBJS += $(OUTPUT)builtin-trace.o -endif - -ifndef NO_SLANG - LIB_OBJS += $(OUTPUT)ui/browser.o - LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o - LIB_OBJS += $(OUTPUT)ui/browsers/hists.o - LIB_OBJS += $(OUTPUT)ui/browsers/map.o - LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o - LIB_OBJS += $(OUTPUT)ui/tui/setup.o - LIB_OBJS += $(OUTPUT)ui/tui/util.o - LIB_OBJS += $(OUTPUT)ui/tui/helpline.o - LIB_OBJS += $(OUTPUT)ui/tui/progress.o - LIB_H += ui/browser.h - LIB_H += ui/browsers/map.h - LIB_H += ui/keysyms.h - LIB_H += ui/libslang.h -endif - -ifndef NO_GTK2 - LIB_OBJS += $(OUTPUT)ui/gtk/browser.o - LIB_OBJS += $(OUTPUT)ui/gtk/hists.o - LIB_OBJS += $(OUTPUT)ui/gtk/setup.o - LIB_OBJS += $(OUTPUT)ui/gtk/util.o - LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o - LIB_OBJS += $(OUTPUT)ui/gtk/progress.o - LIB_OBJS += $(OUTPUT)ui/gtk/annotate.o -endif - -ifndef NO_LIBPERL - LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o - LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o -endif - -ifndef NO_LIBPYTHON - LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o - LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o -endif - -ifeq ($(NO_PERF_REGS),0) - ifeq ($(ARCH),x86) - LIB_H += arch/x86/include/perf_regs.h +ifeq ($(JOBS),) + JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null) + ifeq ($(JOBS),) + JOBS := 1 endif endif -ifndef NO_LIBNUMA - BUILTIN_OBJS += $(OUTPUT)bench/numa.o -endif - -ifdef ASCIIDOC8 - export ASCIIDOC8 -endif - -LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group - -export INSTALL SHELL_PATH - -### Build rules - -SHELL = $(SHELL_PATH) - -all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) - -please_set_SHELL_PATH_to_a_more_modern_shell: - @$$(:) - -shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell - -strip: $(PROGRAMS) $(OUTPUT)perf - $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf - -$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -include $(OUTPUT)PERF-VERSION-FILE \ - '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ - $(CFLAGS) -c $(filter %.c,$^) -o $@ - -$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS) - $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(OUTPUT)perf.o \ - $(BUILTIN_OBJS) $(LIBS) -o $@ - -$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ - '-DPERF_MAN_PATH="$(mandir_SQ)"' \ - '-DPERF_INFO_PATH="$(infodir_SQ)"' $< - -$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ - '-DPERF_MAN_PATH="$(mandir_SQ)"' \ - '-DPERF_INFO_PATH="$(infodir_SQ)"' $< - -$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt - -$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt) - $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@ - -$(SCRIPTS) : % : %.sh - $(QUIET_GEN)$(INSTALL) '[email protected]' '$(OUTPUT)$@' - -# These can record PERF_VERSION -$(OUTPUT)perf.o perf.spec \ - $(SCRIPTS) \ - : $(OUTPUT)PERF-VERSION-FILE - -.SUFFIXES: -.SUFFIXES: .o .c .S .s - -# These two need to be here so that when O= is not used they take precedence -# over the general rule for .o - -$(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -w $< - -$(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w $< - -$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $< -$(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $< -$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -S $(CFLAGS) $< -$(OUTPUT)%.o: %.S - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $< -$(OUTPUT)%.s: %.S - $(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $< - -$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \ - '-DPREFIX="$(prefix_SQ)"' \ - $< - -$(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - '-DBINDIR="$(bindir_SQ)"' -DPYTHON='"$(PYTHON_WORD)"' \ - $< - -$(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ - -DPYTHONPATH='"$(OUTPUT)python"' \ - -DPYTHON='"$(PYTHON_WORD)"' \ - $< - -$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< - -$(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< - -$(OUTPUT)ui/browsers/annotate.o: ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< - -$(OUTPUT)ui/browsers/hists.o: ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< - -$(OUTPUT)ui/browsers/map.o: ui/browsers/map.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< +export JOBS -$(OUTPUT)ui/browsers/scripts.o: ui/browsers/scripts.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $< - -$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< - -$(OUTPUT)util/parse-events.o: util/parse-events.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-redundant-decls $< - -$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-undef -Wno-switch-default $< - -$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-undef -Wno-switch-default $< - -$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< - -$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $< - -$(OUTPUT)perf-%: %.o $(PERFLIBS) - $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS) - -$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H) -$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h) - -# we compile into subdirectories. if the target directory is not the source directory, they might not exists. So -# we depend the various files onto their directories. -DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h -$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS))) -# In the second step, we make a rule to actually create these directories -$(sort $(dir $(DIRECTORY_DEPS))): - $(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null - -$(LIB_FILE): $(LIB_OBJS) - $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS) - -# libtraceevent.a -TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch]) - -$(LIBTRACEEVENT): $(TE_SOURCES) - $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libtraceevent.a - -$(LIBTRACEEVENT)-clean: - $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) clean - -LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch]) - -# if subdir is set, we've been called from above so target has been built -# already -$(LIBLK): $(LIBLK_SOURCES) -ifeq ($(subdir),) - $(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) liblk.a -endif - -$(LIBLK)-clean: -ifeq ($(subdir),) - $(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) clean -endif - -help: - @echo 'Perf make targets:' - @echo ' doc - make *all* documentation (see below)' - @echo ' man - make manpage documentation (access with man <foo>)' - @echo ' html - make html documentation' - @echo ' info - make GNU info documentation (access with info <foo>)' - @echo ' pdf - make pdf documentation' - @echo ' TAGS - use etags to make tag information for source browsing' - @echo ' tags - use ctags to make tag information for source browsing' - @echo ' cscope - use cscope to make interactive browsing database' - @echo '' - @echo 'Perf install targets:' - @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed' - @echo ' HINT: use "make prefix=<path> <install target>" to install to a particular' - @echo ' path like make prefix=/usr/local install install-doc' - @echo ' install - install compiled binaries' - @echo ' install-doc - install *all* documentation' - @echo ' install-man - install manpage documentation' - @echo ' install-html - install html documentation' - @echo ' install-info - install GNU info documentation' - @echo ' install-pdf - install pdf documentation' - @echo '' - @echo ' quick-install-doc - alias for quick-install-man' - @echo ' quick-install-man - install the documentation quickly' - @echo ' quick-install-html - install the html documentation quickly' - @echo '' - @echo 'Perf maintainer targets:' - @echo ' clean - clean all binary objects and build output' - - -DOC_TARGETS := doc man html info pdf - -INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man -INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html - -# 'make doc' should call 'make -C Documentation all' -$(DOC_TARGETS): - $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all) - -TAGS: - $(RM) TAGS - $(FIND) . -name '*.[hcS]' -print | xargs etags -a - -tags: - $(RM) tags - $(FIND) . -name '*.[hcS]' -print | xargs ctags -a - -cscope: - $(RM) cscope* - $(FIND) . -name '*.[hcS]' -print | xargs cscope -b - -### Detect prefix changes -TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):\ - $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ) - -$(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS - @FLAGS='$(TRACK_CFLAGS)'; \ - if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \ - echo 1>&2 " * new build flags or prefix"; \ - echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \ - fi - -### Testing rules - -# GNU make supports exporting all variables by "export" without parameters. -# However, the environment gets quite big, and some programs have problems -# with that. - -check: $(OUTPUT)common-cmds.h - if sparse; \ - then \ - for i in *.c */*.c; \ - do \ - sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \ - done; \ - else \ - exit 1; \ - fi - -### Installation rules - -install-bin: all - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)' - $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)' - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' - $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' -ifndef NO_LIBPERL - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace' - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin' - $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace' - $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl' - $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin' -endif -ifndef NO_LIBPYTHON - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace' - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin' - $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace' - $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python' - $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin' -endif - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d' - $(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf' - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests' - $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests' - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' - $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' - -install: install-bin try-install-man - -install-python_ext: - $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' - -# 'make install-doc' should call 'make -C Documentation install' -$(INSTALL_DOC_TARGETS): - $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=) - -### Cleaning rules +$(info $(shell printf '# [ perf build: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build. ]\n')) # -# This is here, not in config/Makefile, because config/Makefile does -# not get included for the clean target: +# Needed if no target specified: # -config-clean: - @$(MAKE) -C config/feature-checks clean - -clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean config-clean - $(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS) - $(RM) $(ALL_PROGRAMS) perf - $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* - $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean - $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS - $(RM) $(OUTPUT)util/*-bison* - $(RM) $(OUTPUT)util/*-flex* - $(python-clean) - -# -# Trick: if ../../.git does not exist - we are building out of tree for example, -# then force version regeneration: -# -ifeq ($(wildcard ../../.git/HEAD),) - GIT-HEAD-PHONY = ../../.git/HEAD -else - GIT-HEAD-PHONY = -endif +all: + @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) $@ -.PHONY: all install clean config-clean strip -.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell -.PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope .FORCE-PERF-CFLAGS +%: + @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) $@
tools/perf/Makefile.parallel deleted +0 -26
@@ -1,26 +0,0 @@ -# -# Do a parallel build with multiple jobs, based on the number of CPUs online -# in this system: 'make -j8' on a 8-CPU system, etc. -# -# (To override it, run 'make JOBS=1' and similar.) -# -ifeq ($(JOBS),) - JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null) - ifeq ($(JOBS),) - JOBS := 1 - endif -endif - -export JOBS - -$(info $(shell printf '# [ perf build: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build. ]\n')) - -# -# Needed if no target specified: -# -all: - @$(MAKE) --no-print-directory -j$(JOBS) $@ - -%: - @$(MAKE) --no-print-directory -j$(JOBS) $@ -
tools/perf/Makefile.perf new file +842 -0
842 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 41/52 tools/perf/build: Standardize the various messages output by parallel make
In reply to Ingo Molnar--- tools/perf/Makefile | 23 ++++++++++++++++++++--- tools/perf/config/Makefile | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-)
tools/perf/Makefile +20 -3
@@ -13,13 +13,30 @@ endif export JOBS -$(info $(shell printf '# [ perf build: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build. ]\n')) +define print_msg + @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n' +endef + +define make + @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) $@ +endef # # Needed if no target specified: # all: - @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) $@ + $(print_msg) + $(make) + +# +# The clean target is not really parallel, don't print the jobs info: +# +clean: + $(make) +# +# All other targets get passed through: +# %: - @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) $@ + $(print_msg) + $(make)
tools/perf/config/Makefile +2 -2
@@ -179,9 +179,9 @@ endif feature_print = $(eval $(feature_print_code)) define feature_print_code ifeq ($(feature-$(1)), 1) - MSG := $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1)) + MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1)) else - MSG := $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1)) + MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1)) endif $(info $(MSG)) endef
Signature · 1 line
1.8.3.1
PATCH 42/52 tools/perf/build: Split out feature checks: 'liberty', 'liberty-z', 'cplus-demangle'
In reply to Ingo MolnarNote that these are rarely executed tests, so we call feature_check() explicitly and don't have them in CORE_FEATURE_CHECKS.
--- tools/perf/config/Makefile | 16 ++++++---------- tools/perf/config/feature-checks/Makefile | 12 ++++++++++++ tools/perf/config/feature-checks/test-cplus-demangle.c | 10 ++++++++++ 3 files changed, 28 insertions(+), 10 deletions(-)
tools/perf/config/Makefile +6 -10
@@ -462,23 +462,19 @@ else EXTLIBS += -liberty CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT else - FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd ifeq ($(feature-libbfd), 1) EXTLIBS += -lbfd else - FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty - has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty) - ifeq ($(has_bfd_iberty),y) + $(feature_check,liberty) + ifeq ($(feature-liberty), 1) EXTLIBS += -lbfd -liberty else - FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz - has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz) - ifeq ($(has_bfd_iberty_z),y) + $(feature_check,liberty-z) + ifeq ($(feature-liberty-z), 1) EXTLIBS += -lbfd -liberty -lz else - FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -liberty - has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle) - ifeq ($(has_cplus_demangle),y) + $(feature_check,cplus-demangle) + ifeq ($(feature-cplus-demangle), 1) EXTLIBS += -liberty CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT else
tools/perf/config/feature-checks/Makefile +12 -0
@@ -11,6 +11,9 @@ FILES= \ test-hello \ test-libaudit \ test-libbfd \ + test-liberty \ + test-liberty-z \ + test-cplus-demangle \ test-libelf \ test-libelf-getphdrnum \ test-libelf-mmap \
@@ -122,6 +125,15 @@ test-libpython-version: test-libbfd: $(BUILD) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl +test-liberty: + $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl -liberty + +test-liberty-z: + $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl -liberty -lz + +test-cplus-demangle: + $(BUILD) -liberty + test-on-exit: $(BUILD)
tools/perf/config/feature-checks/test-cplus-demangle.c new file +10 -0
@@ -0,0 +1,10 @@ + +extern char *cplus_demangle (const char *,int ); + +int main (void ) +{ +cplus_demangle (0 ,0 ); + +return 0 ; +} +
Signature · 1 line
1.8.3.1
PATCH 43/52 tools/perf/build: Remove unused config/feature-tests.mak
In reply to Ingo MolnarAlso remove try-cc et al. These got obsoleted by the split-out feature checks in config/feature-checks/.
--- tools/perf/config/Makefile | 3 +- tools/perf/config/feature-tests.mak | 244 -------------------------------------------------------- tools/perf/config/utilities.mak | 14 ---- 3 files changed, 1 insertion(+), 260 deletions(-)
tools/perf/config/Makefile +1 -2
@@ -51,7 +51,6 @@ LIB_INCLUDE := $(srctree)/tools/lib/ # include ARCH specific config -include $(src-perf)/arch/$(ARCH)/Makefile -include $(src-perf)/config/feature-tests.mak include $(src-perf)/config/utilities.mak ifeq ($(call get-executable,$(FLEX)),)
@@ -274,7 +273,7 @@ else msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); NO_DWARF := 1 endif # Dwarf support - endif # SOURCE_LIBELF + endif # libelf support endif # NO_LIBELF ifndef NO_LIBELF
tools/perf/config/feature-tests.mak +0 -244
246 lines not on this page · raw message
tools/perf/config/utilities.mak +0 -14
@@ -178,17 +178,3 @@ endef _ge_attempt = $(if $(get-executable),$(get-executable),$(_gea_warn)$(call _gea_err,$(2))) _gea_warn = $(warning The path '$(1)' is not executable.) _gea_err = $(if $(1),$(error Please set '$(1)' appropriately)) - -# try-cc -# Usage: option = $(call try-cc, source-to-build, cc-options, msg) -ifneq ($(V),1) -TRY_CC_OUTPUT= > /dev/null 2>&1 -endif -TRY_CC_MSG=echo " CHK $(3)" 1>&2; - -try-cc = $(shell sh -c \ - 'TMP="$(OUTPUT)$(TMPOUT).$$$$"; \ - $(TRY_CC_MSG) \ - echo "$(1)" | \ - $(CC) -x c - $(2) -o "$$TMP" $(TRY_CC_OUTPUT) && echo y; \ - rm -f "$$TMP"')
Signature · 1 line
1.8.3.1
PATCH 44/52 tools/perf/build: Clean up various testcases
In reply to Ingo MolnarPrepare to include them into test-all.c directly, by making sure that they build cleanly and without warnings.
Also make sure they make a certain amount of sense and don't crash when executed.
--- tools/perf/config/feature-checks/test-backtrace.c | 8 ++++++-- tools/perf/config/feature-checks/test-cplus-demangle.c | 9 +++++++-- tools/perf/config/feature-checks/test-gtk2-infobar.c | 3 ++- tools/perf/config/feature-checks/test-gtk2.c | 2 +- tools/perf/config/feature-checks/test-libaudit.c | 2 ++ tools/perf/config/feature-checks/test-libbfd.c | 11 ++++++++++- tools/perf/config/feature-checks/test-libunwind.c | 9 ++++++++- tools/perf/config/feature-checks/test-on-exit.c | 11 ++++++++++- 8 files changed, 46 insertions(+), 9 deletions(-)
tools/perf/config/feature-checks/test-backtrace.c +6 -2
@@ -3,8 +3,12 @@int main (void ) { -backtrace (NULL ,0 ); -backtrace_symbols (NULL ,0 ); +void *backtrace_fns[10 ]; +size_t entries; + + entries =backtrace (backtrace_fns,10 ); +backtrace_symbols_fd (backtrace_fns, entries,1 );return 0 ; } +
tools/perf/config/feature-checks/test-cplus-demangle.c +7 -2
@@ -1,9 +1,14 @@ - +extern int printf (const char *format, ...);extern char *cplus_demangle (const char *,int );int main (void ) { -cplus_demangle (0 ,0 ); +char symbol[4096 ] ="FieldName__9ClassNameFd" ; +char *tmp; + + tmp =cplus_demangle (symbol,0 ); + +printf ("demangled symbol: {%s}\n" , tmp);return 0 ; }
tools/perf/config/feature-checks/test-gtk2-infobar.c +2 -1
@@ -2,8 +2,9 @@#include <gtk/gtk.h> #pragma GCC diagnostic error "-Wstrict-prototypes" -int main (void ) +int main (int argc,char *argv[]) { +gtk_init (&argc, &argv);gtk_info_bar_new ();return 0 ;
tools/perf/config/feature-checks/test-gtk2.c +1 -1
@@ -4,7 +4,7 @@int main (int argc,char *argv[]) { -gtk_init (&argc, &argv); +gtk_init (&argc, &argv);return 0 ; }
tools/perf/config/feature-checks/test-libaudit.c +2 -0
@@ -1,5 +1,7 @@#include <libaudit.h> +extern int printf (const char *format, ...); +int main (void ) {printf ("error message: %s\n" ,audit_errno_to_name (0 ));
tools/perf/config/feature-checks/test-libbfd.c +10 -1
@@ -1,7 +1,16 @@#include <bfd.h> +extern int printf (const char *format, ...); +int main (void ) { -bfd_demangle (0 ,0 ,0 ); +char symbol[4096 ] ="FieldName__9ClassNameFd" ; +char *tmp; + + tmp =bfd_demangle (0 , symbol,0 ); + +printf ("demangled symbol: {%s}\n" , tmp); +return 0 ; } +
tools/perf/config/feature-checks/test-libunwind.c +8 -1
@@ -10,11 +10,18 @@ extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) +static unw_accessors_t accessors; +int main (void ) {unw_addr_space_t addr_space; - addr_space =unw_create_addr_space (NULL ,0 ); + + addr_space =unw_create_addr_space (&accessors,0 ); +if (addr_space) +return 0 ; +unw_init_remote (NULL , addr_space,NULL );dwarf_search_unwind_table (addr_space,0 ,NULL ,NULL ,0 ,NULL ); +return 0 ; }
tools/perf/config/feature-checks/test-on-exit.c +10 -1
@@ -1,6 +1,15 @@#include <stdio.h> +static void exit_fn (int status,void *__data) +{ +printf ("exit status: %d, data: %d\n" , status, *(int *)__data); +} + +static int data =123 ; +int main (void ) { -return on_exit (NULL ,NULL ); +on_exit (exit_fn, &data); + +return 321 ; }
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 44/52] tools/perf/build: Clean up various testcases
tools/perf/config/feature-checks/test-gtk2.c line 10
Quoted 11 lines · Ingo Molnar
tools/perf/config/feature-checks/test-gtk2.c +1
-1@@ -4,7 +4,7 @@int main (int argc,char *argv[]) { -gtk_init (&argc, &argv); +gtk_init (&argc, &argv);return 0 ; }
Whitespace damaged.
Thanks,
Namhyung
Re: [PATCH 44/52] tools/perf/build: Clean up various testcases
Quoted 10 lines · Namhyung Kim
Quoted 9 lines · Ingo Molnar
tools/perf/config/feature-checks/test-gtk2.c +1
-1@@ -4,7 +4,7 @@int main (int argc,char *argv[]) { -gtk_init (&argc, &argv); +gtk_init (&argc, &argv);
Quoted 4 lines
tools/perf/config/feature-checks/test-gtk2.c line 10
Quoted 2 lines
tools/perf/config/feature-checks/test-gtk2.c +0
-0return 0 ; }Whitespace damaged.
What I think this patch does is to _remove_ the whitespace damage that was present in the previous feature-tests.mak method.
This hunk changes spaces to tabs.
Agreed?
Thanks,
Ingo
PATCH 45/52 tools/perf/build: Collapse the test-all.c testcase
In reply to Ingo MolnarSimplify test-all.c by including it all the testcases via #include.
--- tools/perf/config/feature-checks/test-all.c | 290 +++++++++++++++++------------------------------- 1 file changed, 100 insertions(+), 190 deletions(-)
tools/perf/config/feature-checks/test-all.c +100 -190
@@ -1,196 +1,106 @@ - -#pragma GCC diagnostic ignored "-Wstrict-prototypes" - -#include <Python.h> - -#include <EXTERN.h> -#include <perl.h> - -#include <stdio.h> -#include <libelf.h> -#include <gnu/libc-version.h> -#include <dwarf.h> -#include <elfutils/libdw.h> -#include <elfutils/version.h> -#include <libelf.h> -#include <libunwind.h> -#include <stdlib.h> -#include <libaudit.h> -#include <slang.h> -#include <gtk/gtk.h> -#include <bfd.h> -#include <stdio.h> -#include <execinfo.h> -#include <stdio.h> -#include <numa.h> -#include <numaif.h> - -#pragma GCC diagnostic error "-Wstrict-prototypes" - -int main1 (void ) -{ -return puts ("hi" ); -} - -int main2 (void ) -{ -return puts ("hi" ); -} - -int main3 (void ) -{ -return puts ("hi" ); -} - -int main4 (void ) -{ -Elf *elf =elf_begin (0 ,ELF_C_READ ,0 ); -return (long )elf; -} -# -int main5 (void ) -{ -Elf *elf =elf_begin (0 ,ELF_C_READ_MMAP ,0 ); -return (long )elf; -} - -int main6 (void ) -{ -const char *version =gnu_get_libc_version (); -return (long )version; -} - -int main7 (void ) -{ -Dwarf *dbg =dwarf_begin (0 ,DWARF_C_READ ); -return (long )dbg; -} - -int main8 (void ) -{ -size_t dst; -return elf_getphdrnum (0 , &dst); -} - -extern int UNW_OBJ (dwarf_search_unwind_table ) (unw_addr_space_t as, -unw_word_t ip, -unw_dyn_info_t *di, -unw_proc_info_t *pi, -int need_unwind_info,void *arg); - - -#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) - -int main9 (void ) -{ -unw_addr_space_t addr_space; - addr_space =unw_create_addr_space (NULL ,0 ); -unw_init_remote (NULL , addr_space,NULL ); -dwarf_search_unwind_table (addr_space,0 ,NULL ,NULL ,0 ,NULL ); -return 0 ; -} - -int main10 (void ) -{ -printf ("error message: %s\n" ,audit_errno_to_name (0 )); -return audit_open (); -} - -int main11 (void ) -{ -return SLsmg_init_smg (); -} - -int main12 (int argc,char *argv[]) -{ -gtk_init (&argc, &argv); - -return 0 ; -} - -int main13 (void ) -{ -gtk_info_bar_new (); - -return 0 ; -} - -int main14 (void ) -{ -perl_alloc (); - -return 0 ; -} - -int main15 (void ) -{ -Py_Initialize (); -return 0 ; -} - -#if PY_VERSION_HEX >=0x03000000 -#error -#endif - -int main16 (void ) -{ -return 0 ; -} - -int main17 (void ) -{ -bfd_demangle (0 ,0 ,0 ); -return 0 ; -} - -void exit_function (int x,void *y) -{ -} - -int main18 (void ) -{ -return on_exit (exit_function,NULL ); -} - -int main19 (void ) -{ -void *backtrace_fns[1 ]; -size_t entries; - - entries =backtrace (backtrace_fns,1 ); -backtrace_symbols (backtrace_fns, entries); - -return 0 ; -} - -int main20 (void ) -{ -numa_available (); -return 0 ; -} +/* +* test-all.c: Try to build all the main testcases at once. +* +* A well-configured system will have all the prereqs installed, so we can speed +* up auto-detection on such systems. +*/ + +/* +* Quirk: Python and Perl headers cannot be in arbitrary places, so keep +* these 3 testcases at the top: +*/ +#define main main_test_libpython +# include "test-libpython.c" +#undef main + +#define main main_test_libpython_version +# include "test-libpython-version.c" +#undef main + +#define main main_test_libperl +# include "test-libperl.c" +#undef main + +#define main main_test_hello +# include "test-hello.c" +#undef main + +#define main main_test_libelf +# include "test-libelf.c" +#undef main + +#define main main_test_libelf_mmap +# include "test-libelf-mmap.c" +#undef main + +#define main main_test_glibc +# include "test-glibc.c" +#undef main + +#define main main_test_dwarf +# include "test-dwarf.c" +#undef main + +#define main main_test_libelf_getphdrnum +# include "test-libelf-getphdrnum.c" +#undef main + +#define main main_test_libunwind +# include "test-libunwind.c" +#undef main + +#define main main_test_libaudit +# include "test-libaudit.c" +#undef main + +#define main main_test_libslang +# include "test-libslang.c" +#undef main + +#define main main_test_gtk2 +# include "test-gtk2.c" +#undef main + +#define main main_test_gtk2_infobar +# include "test-gtk2-infobar.c" +#undef main + +#define main main_test_libbfd +# include "test-libbfd.c" +#undef main + +#define main main_test_on_exit +# include "test-on-exit.c" +#undef main + +#define main main_test_backtrace +# include "test-backtrace.c" +#undef main + +#define main main_test_libnuma +# include "test-libnuma.c" +#undef mainint main (int argc,char *argv[]) { -main1 (); -main2 (); -main3 (); -main4 (); -main5 (); -main6 (); -main7 (); -main8 (); -main9 (); -main10 (); -main11 (); -main12 (argc, argv); -main13 (); -main14 (); -main15 (); -main16 (); -main17 (); -main18 (); -main19 (); -main20 (); +main_test_libpython (); +main_test_libpython_version (); +main_test_libperl (); +main_test_hello (); +main_test_libelf (); +main_test_libelf_mmap (); +main_test_glibc (); +main_test_dwarf (); +main_test_libelf_getphdrnum (); +main_test_libunwind (); +main_test_libaudit (); +main_test_libslang (); +main_test_gtk2 (argc, argv); +main_test_gtk2_infobar (argc, argv); +main_test_libbfd (); +main_test_on_exit (); +main_test_backtrace (); +main_test_libnuma ();return 0 ; }
Signature · 1 line
1.8.3.1
PATCH 46/52 tools/perf/build: Pass through all targets to Makefile.perf
In reply to Ingo MolnarJiri reported that 'make .o' stopped working:
Quoted 7 lines
[jolsa@krava perf]$ make -f
Makefileperf.o
cc -c -o perf.operf.c
In file included from builtin.h:4:0,from perf.c:9:
util/util.h:74:24: fatal error:lk/debugfs.h: No such file or directory compilation terminated.
make: *** [perf.o] Error 1
This is due to GNU make having built-in rules for popular targets such as *.o. Clear them out so that all targets as passed through to Makefile.perf.
--- tools/perf/Makefile | 7 +++++++ 1 file changed, 7 insertions(+)
tools/perf/Makefile +7 -0
@@ -1,3 +1,10 @@ + +# +# Clear out the built-in rules GNU make defines by default (such as .o targets), +# so that we pass through all targets to Makefile.perf: +# +.SUFFIXES: + # # Do a parallel build with multiple jobs, based on the number of CPUs online # in this system: 'make -j8' on a 8-CPU system, etc.
Signature · 1 line
1.8.3.1
PATCH 47/52 tools/perf/build: Make sure autodep feature binaries honor the O= setting
In reply to Ingo MolnarArnaldo noticed that the feature-check binaries are generated in the config/check-features/ directory even if O= is specified.
Implement $(OUTPUT) logic for config/check-features/Makefile.
--- tools/perf/config/Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/perf/config/Makefile +8 -3
@@ -88,9 +88,14 @@ CFLAGS += -std=gnu99 EXTLIBS = -lelf -lpthread -lrt -lm -ldl +ifneq ($(OUTPUT),) + OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/ + $(shell mkdir -p $(OUTPUT_FEATURES)) +endif + feature_check = $(eval $(feature_check_code)) define feature_check_code - feature-$(1) := $(shell $(MAKE) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) + feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) endef feature_set = $(eval $(feature_set_code))
@@ -138,7 +143,7 @@ CORE_FEATURE_TESTS = \ # to skip the print-out of the long features list if the file # existed before and after it was built: # -ifeq ($(wildcard config/feature-checks/test-all),) +ifeq ($(wildcard $(OUTPUT)config/feature-checks/test-all),) test-all-failed := 1 else test-all-failed := 0
@@ -168,7 +173,7 @@ ifeq ($(feature-all), 1) # $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat))) else - $(shell $(MAKE) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1) + $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1) $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat))) endif
Signature · 1 line
1.8.3.1
PATCH 48/52 tools/perf/build: Exclude MAKEFLAGS from nested invocation
In reply to Ingo MolnarIn case the user specifies MAKEFLAGS as an environment variable, or uses 'make -jN' explicitly, the options can conflict and result in:
BUILD: Doing 'make -j8' parallel build
make[1]: warning: -jN forced in submake: disabling jobserver mode. GEN common-cmds.h
make[1]: *** write jobserver: Bad file descriptor. Stop.
Make sure we invoke the main makefile in a pristine state.
Users who want to do something non-standard can use the:
make -f Makefile.perf
method to invoke the makefile.
--- tools/perf/Makefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
tools/perf/Makefile +13 -3
@@ -1,3 +1,10 @@ +# +# This is a simple wrapper Makefile that calls the main Makefile.perf +# with a -j option to do parallel builds +# +# If you want to invoke the perf build in some non-standard way then +# you can use the 'make -f Makefile.perf' method to invoke it. +# # # Clear out the built-in rules GNU make defines by default (such as .o targets),
@@ -6,6 +13,11 @@ .SUFFIXES: # +# We don't want to pass along options like -j: +# +unexport MAKEFLAGS + +# # Do a parallel build with multiple jobs, based on the number of CPUs online # in this system: 'make -j8' on a 8-CPU system, etc. #
@@ -18,14 +30,12 @@ ifeq ($(JOBS),) endif endif -export JOBS - define print_msg @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n' endef define make - @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) $@ + @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(O) $@ endef #
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 48/52] tools/perf/build: Exclude MAKEFLAGS from nested invocation
Quoted 8 lines · Ingo Molnar
In case the user specifies MAKEFLAGS as an environment variable, or uses 'make -jN' explicitly, the options can conflict and result in:
BUILD: Doing 'make -j8' parallel build
make[1]: warning: -jN forced in submake: disabling jobserver mode. GENcommon-cmds.h
make[1]: *** write jobserver: Bad file descriptor. Stop.
Quoted 7 lines
Make sure we invoke the main makefile in a pristine state.
Users who want to do something non-standard can use the:
make -f Makefile.perf
method to invoke the makefile.
Hmm... it'd be great if there's a way to detect -jN option and convert it to the JOBS.
Thanks,
Namhyung
Re: [PATCH 48/52] tools/perf/build: Exclude MAKEFLAGS from nested invocation
Quoted 11 lines · Namhyung Kim
Quoted 10 lines · Ingo Molnar
In case the user specifies MAKEFLAGS as an environment variable, or uses 'make -jN' explicitly, the options can conflict and result in:
BUILD: Doing 'make -j8' parallel build
make[1]: warning: -jN forced in submake: disabling jobserver mode. GENcommon-cmds.h
make[1]: *** write jobserver: Bad file descriptor. Stop.Make sure we invoke the main makefile in a pristine state.
Quoted 8 lines
Quoted 5 lines
Users who want to do something non-standard can use the:
make -f Makefile.perf
method to invoke the makefile.
Hmm... it'd be great if there's a way to detect -jN option and convert it to the JOBS.
I looked hard but couldn't find any solution for that, GNU Make hides it. It seems to be possible on other Make platforms - so I suspect that will have to be a feature request to the GNU Make folks ...
Thanks,
Ingo
PATCH 49/52 tools/perf/build: Fix non-canonical directory names in O=
In reply to Ingo MolnarThis was a long-standing bug, relative pathnames like O=dir did not fully work in the build system:
$ make O=localdir clean
SUBDIR Documentation
../../scripts/Makefile.include:3: *** O=localdir does not exist. Stop.
make[1]: *** [clean] Error 2
make: *** [clean] Error 2Fix this by canonizing the directory before passing it to Makefile.perf.
--- tools/perf/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/perf/Makefile +8 -1
@@ -30,12 +30,19 @@ ifeq ($(JOBS),) endif endif +# +# Only pass canonical directory names as the output directory: +# +ifneq ($(O),) + FULL_O := $(shell readlink -f $(O)) +endif + define print_msg @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n' endef define make - @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(O) $@ + @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $@ endef #
Signature · 1 line
1.8.3.1
PATCH 50/52 tools/perf/build: Fix O=/some/dir perf.o type of targets
In reply to Ingo MolnarIf someone specifies a single target, mixed with O=, the following way:
hubble:~/tip/tools/perf> make O=/tmp/perf util/stat.o
BUILD: Doing 'make -j8' parallel build
gcc -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k [...]
The build might even fail, if a target depends on other targets:
hubble:~/tip/tools/perf> make O=/tmp/perf perf.o
...
perf.c: In function ‘handle_options’:
perf.c:155:21: error: ‘PERF_HTML_PATH’ undeclared (first use in this function)
The correct way to invoke such targets is:
hubble:~/tip/tools/perf> make O=/tmp/perf /tmp/perf/perf.o
BUILD: Doing 'make -j8' parallel build
GEN /tmp/perf/common-cmds.h
CC /tmp/perf/perf.o
But that's unnecessary typing and it's also easy to mistakenly build into the source directory.
To fix this remove the generic suffix rules and add redirection to $(OUTPUT) for the most popular .o targets.
--- tools/perf/Makefile.perf | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
tools/perf/Makefile.perf +15 -1
@@ -576,7 +576,21 @@ $(OUTPUT)perf.o perf.spec \ : $(OUTPUT)PERF-VERSION-FILE .SUFFIXES: -.SUFFIXES: .o .c .S .s + +# +# If a target does not match any of the later rules then prefix it by $(OUTPUT) +# This makes targets like 'make O=/tmp/perf perf.o' work in a natural way. +# +ifneq ($(OUTPUT),) +%.o: $(OUTPUT)%.o + @echo " # Redirected target $@ => $(OUTPUT)$@" +util/%.o: $(OUTPUT)util/%.o + @echo " # Redirected target $@ => $(OUTPUT)util/$@" +bench/%.o: $(OUTPUT)bench/%.o + @echo " # Redirected target $@ => $(OUTPUT)bench/$@" +tests/%.o: $(OUTPUT)tests/%.o + @echo " # Redirected target $@ => $(OUTPUT)tests/$@" +endif # These two need to be here so that when O= is not used they take precedence # over the general rule for .o
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 50/52] tools/perf/build: Fix O=/some/dir perf.o type of targets
Quoted 20 lines · Ingo Molnar
If someone specifies a single target, mixed with O=, the following way:
hubble:~/tip/tools/perf> make O=/tmp/perf
util/stat.o
BUILD: Doing 'make -j8' parallel build
gcc -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k [...]The build might even fail, if a target depends on other targets:
hubble:~/tip/tools/perf> make O=/tmp/perf perf.o
...
perf.c: In function ‘handle_options’:
perf.c:155:21: error: ‘PERF_HTML_PATH’ undeclared (first use in this function)The correct way to invoke such targets is:
hubble:~/tip/tools/perf> make O=/tmp/perf
/tmp/perf/perf.o
BUILD: Doing 'make -j8' parallel build
GEN/tmp/perf/common-cmds.h
CC/tmp/perf/perf.o
Quoted 5 lines
But that's unnecessary typing and it's also easy to mistakenly build into the source directory.
To fix this remove the generic suffix rules and add redirection to $(OUTPUT) for the most popular .o targets.
I got this:
$ cd tools/perf $ make ... (succeeded)
$ make O=~/build/perf perf.o make: `perf.o' is up to date.
$ rm ~/build/perf/perf.o $ make O=~/build/perf/ perf.o make: `perf.o' is up to date.
Quoted 4 lines
tools/perf/Makefile.perf +4
-0+# +# If a target does not match any of the later rules then prefix it by $(OUTPUT) +# This makes targets like 'make O=/tmp/perf perf.o' work in a natural way. +#
tools/perf/Makefile.perf $(OUTPUT)perf.o perf.spec \ · line 593
Quoted 10 lines
tools/perf/Makefile.perf +10
-0+ifneq ($(OUTPUT),) +%.o: $(OUTPUT)%.o + @echo " # Redirected target $@ => $(OUTPUT)$@" +util/%.o: $(OUTPUT)util/%.o + @echo " # Redirected target $@ => $(OUTPUT)util/$@" +bench/%.o: $(OUTPUT)bench/%.o + @echo " # Redirected target $@ => $(OUTPUT)bench/$@" +tests/%.o: $(OUTPUT)tests/%.o + @echo " # Redirected target $@ => $(OUTPUT)tests/$@" +endif
It also doesn't care about other directories - arch/, scripts/ and ui/ - and their subdirectories. So even on clean build it'll failed to build these files with O=dir.
$ make clean
$ make O=~/build/perf ui/stdio/hist.o
BUILD: Doing 'make -j12' parallel build
make[1]: *** No rule to make target `ui/stdio/hist.o'. Stop.
make: *** [ui/stdio/hist.o] Error 2Thanks,
Namhyung
Re: [PATCH 50/52] tools/perf/build: Fix O=/some/dir perf.o type of targets
Quoted 33 lines · Namhyung Kim
Quoted 20 lines · Ingo Molnar
If someone specifies a single target, mixed with O=, the following way:
hubble:~/tip/tools/perf> make O=/tmp/perf
util/stat.o
BUILD: Doing 'make -j8' parallel build
gcc -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k [...]The build might even fail, if a target depends on other targets:
hubble:~/tip/tools/perf> make O=/tmp/perf perf.o
...
perf.c: In function ‘handle_options’:
perf.c:155:21: error: ‘PERF_HTML_PATH’ undeclared (first use in this function)The correct way to invoke such targets is:
hubble:~/tip/tools/perf> make O=/tmp/perf
/tmp/perf/perf.o
BUILD: Doing 'make -j8' parallel build
GEN/tmp/perf/common-cmds.h
CC/tmp/perf/perf.oQuoted 5 lines
But that's unnecessary typing and it's also easy to mistakenly build into the source directory.
To fix this remove the generic suffix rules and add redirection to $(OUTPUT) for the most popular .o targets.
I got this:
$ cd tools/perf $ make ... (succeeded)
Quoted 6 lines
$ make O=~/build/perf perf.o make: `perf.o' is up to date.$ rm ~/build/perf/perf.o $ make O=~/build/perf/ perf.o make: `perf.o' is up to date.
Yes, this is a limitation: it will only do the redirection if the source repository is clean.
I don't see a simple solution for that, do you?
Quoted 11 lines
tools/perf/Makefile.perf $(OUTPUT)perf.o perf.spec \ · line 593
Quoted 7 lines
tools/perf/Makefile.perf +7
-0+util/%.o: $(OUTPUT)util/%.o + @echo " # Redirected target $@ => $(OUTPUT)util/$@" +bench/%.o: $(OUTPUT)bench/%.o + @echo " # Redirected target $@ => $(OUTPUT)bench/$@" +tests/%.o: $(OUTPUT)tests/%.o + @echo " # Redirected target $@ => $(OUTPUT)tests/$@" +endifIt also doesn't care about other directories -
arch/,scripts/and ui/ - and their subdirectories. So even on clean build it'll failed to build these files with O=dir.
Correct - only tried to cover the most common cases. Could add all the other directories if this is something people would like to use on a regular basis.
I also attempted to do a generic rule that can see into subdirectories, using secondary expansion rules, but my first few attempts failed at producing anything usable ;-) My Make fu still needs working on. Suggestions welcome!
Thanks,
Ingo
Namhyung Kim
maintainerRe: [PATCH 50/52] tools/perf/build: Fix O=/some/dir perf.o type of targets
Hi,
Quoted 17 lines · Ingo Molnar
Yes, this is a limitation: it will only do the redirection if the source repository is clean.
I don't see a simple solution for that, do you?
Quoted 11 lines
tools/perf/Makefile.perf $(OUTPUT)perf.o perf.spec \ · line 593
Quoted 7 lines
tools/perf/Makefile.perf +7
-0+util/%.o: $(OUTPUT)util/%.o + @echo " # Redirected target $@ => $(OUTPUT)util/$@" +bench/%.o: $(OUTPUT)bench/%.o + @echo " # Redirected target $@ => $(OUTPUT)bench/$@" +tests/%.o: $(OUTPUT)tests/%.o + @echo " # Redirected target $@ => $(OUTPUT)tests/$@" +endifIt also doesn't care about other directories -
arch/,scripts/and ui/ - and their subdirectories. So even on clean build it'll failed to build these files with O=dir.
Quoted 3 lines
Correct - only tried to cover the most common cases. Could add all the other directories if this is something people would like to use on a regular basis.
I don't think it's a common usecase.
Quoted 5 lines
I also attempted to do a generic rule that can see into subdirectories, using secondary expansion rules, but my first few attempts failed at producing anything usable ;-) My Make fu still needs working on. Suggestions welcome!
Well, my make fu (make skill?) is also poor. ;)
I'll try to do something about it though.
Thanks,
Namhyung
PATCH 51/52 tools/perf/build: Harmonize the style of the feature testcases
In reply to Ingo MolnarThe various testcases used different styles, which was not really visible as long as they hid in feature-tests.mak. Now that they are out in the open make them prettier.
( Also delete the leftover, empty feature-tests.mak file. )
--- tools/perf/config/feature-checks/test-backtrace.c | 1 - tools/perf/config/feature-checks/test-cplus-demangle.c | 1 - tools/perf/config/feature-checks/test-dwarf.c | 1 + tools/perf/config/feature-checks/test-glibc.c | 2 +- tools/perf/config/feature-checks/test-libaudit.c | 1 + tools/perf/config/feature-checks/test-libbfd.c | 1 - tools/perf/config/feature-checks/test-libelf-getphdrnum.c | 3 ++- tools/perf/config/feature-checks/test-libelf-mmap.c | 3 ++- tools/perf/config/feature-checks/test-libelf.c | 1 + tools/perf/config/feature-checks/test-libnuma.c | 1 + tools/perf/config/feature-checks/test-libpython.c | 3 ++- tools/perf/config/feature-tests.mak | 2 -- 12 files changed, 11 insertions(+), 9 deletions(-)
tools/perf/config/feature-checks/test-backtrace.c +0 -1
@@ -11,4 +11,3 @@ int main(void)return 0 ; } -
tools/perf/config/feature-checks/test-cplus-demangle.c +0 -1
@@ -12,4 +12,3 @@ int main(void)return 0 ; } -
tools/perf/config/feature-checks/test-dwarf.c +1 -0
@@ -5,5 +5,6 @@int main (void ) {Dwarf *dbg =dwarf_begin (0 ,DWARF_C_READ ); +return (long )dbg; }
tools/perf/config/feature-checks/test-glibc.c +1 -1
@@ -3,6 +3,6 @@int main (void ) {const char *version =gnu_get_libc_version (); +return (long )version; } -
tools/perf/config/feature-checks/test-libaudit.c +1 -0
@@ -5,5 +5,6 @@ extern int printf(const char *format, ...);int main (void ) {printf ("error message: %s\n" ,audit_errno_to_name (0 )); +return audit_open (); }
tools/perf/config/feature-checks/test-libbfd.c +0 -1
@@ -13,4 +13,3 @@ int main(void)return 0 ; } -
tools/perf/config/feature-checks/test-libelf-getphdrnum.c +2 -1
@@ -1,7 +1,8 @@#include <libelf.h> -# +int main (void ) {size_t dst; +return elf_getphdrnum (0 , &dst); }
tools/perf/config/feature-checks/test-libelf-mmap.c +2 -1
@@ -1,7 +1,8 @@#include <libelf.h> -# +int main (void ) {Elf *elf =elf_begin (0 ,ELF_C_READ_MMAP ,0 ); +return (long )elf; }
tools/perf/config/feature-checks/test-libelf.c +1 -0
@@ -3,5 +3,6 @@int main (void ) {Elf *elf =elf_begin (0 ,ELF_C_READ ,0 ); +return (long )elf; }
tools/perf/config/feature-checks/test-libnuma.c +1 -0
@@ -4,5 +4,6 @@int main (void ) {numa_available (); +return 0 ; }
tools/perf/config/feature-checks/test-libpython.c +2 -1
@@ -1,7 +1,8 @@#include <Python.h> -# +int main (void ) {Py_Initialize (); +return 0 ; }
tools/perf/config/feature-tests.mak deleted +0 -2
@@ -1,2 +0,0 @@ - -
Signature · 1 line
1.8.3.1
PATCH 52/52 tools/perf/build: Pass through LDFLAGS to feature tests
In reply to Ingo MolnarDavid Ahern reported that when passing in LDFLAGS=-static then the feature checks still succeed - causing build failures down the line because the static libraries are missing.
Solve this by passing through LDFLAGS to the feature-check Makefile.
--- tools/perf/config/Makefile | 4 ++-- tools/perf/config/feature-checks/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/config/Makefile +2 -2
@@ -95,7 +95,7 @@ endif feature_check = $(eval $(feature_check_code)) define feature_check_code - feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) + feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) endef feature_set = $(eval $(feature_set_code))
@@ -173,7 +173,7 @@ ifeq ($(feature-all), 1) # $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat))) else - $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1) + $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1) $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat))) endif
tools/perf/config/feature-checks/Makefile +1 -1
@@ -32,7 +32,7 @@ CC := $(CC) -MD all: $(FILES) -BUILD = $(CC) -o $(OUTPUT)$@ [email protected] +BUILD = $(CC) $(LDFLAGS) -o $(OUTPUT)$@ [email protected] ###############################
Signature · 1 line
1.8.3.1