2013-10-08 10:12:09

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH -v2 00/52] 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

--
1.8.3.1


2013-10-08 10:12:11

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 02/52] tools/perf/build: Add feature check core code

Start 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.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(+)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 34be743..daefe2d 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
new file mode 100644
index 0000000..b3f6372
--- /dev/null
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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)
diff --git a/tools/perf/config/feature-checks/test-hello.c b/tools/perf/config/feature-checks/test-hello.c
new file mode 100644
index 0000000..c9f398d
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-hello.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+ return puts("hi");
+}
--
1.8.3.1

2013-10-08 10:12:16

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 07/52] tools/perf/build: Split out feature check: 'volatile-register-var'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 9f94912..a3de2f8 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 46b7650..5693299 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-volatile-register-var.c b/tools/perf/config/feature-checks/test-volatile-register-var.c
new file mode 100644
index 0000000..c9f398d
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-volatile-register-var.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+ return puts("hi");
+}
--
1.8.3.1

2013-10-08 10:12:30

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 19/52] tools/perf/build: Split out feature check: 'libaudit'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index c3f73be..7fda3a6 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index d6d9570..8e49fa0 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-libaudit.c b/tools/perf/config/feature-checks/test-libaudit.c
new file mode 100644
index 0000000..854a65d
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libaudit.c
@@ -0,0 +1,7 @@
+#include <libaudit.h>
+
+int main(void)
+{
+ printf("error message: %s\n", audit_errno_to_name(0));
+ return audit_open();
+}
--
1.8.3.1

2013-10-08 10:12:27

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 11/52] tools/perf/build: Split out feature check: 'libelf'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index a2e0e1b..6865428 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 191df97..789a38d 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-libelf.c b/tools/perf/config/feature-checks/test-libelf.c
new file mode 100644
index 0000000..1a08f97
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libelf.c
@@ -0,0 +1,7 @@
+#include <libelf.h>
+
+int main(void)
+{
+ Elf *elf = elf_begin(0, ELF_C_READ, 0);
+ return (long)elf;
+}
--
1.8.3.1

2013-10-08 10:12:34

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 18/52] tools/perf/build: Split out feature check: 'libunwind'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 0d75587..c3f73be 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 83b3a02..d6d9570 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-libunwind.c b/tools/perf/config/feature-checks/test-libunwind.c
new file mode 100644
index 0000000..5622746
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libunwind.c
@@ -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;
+}
--
1.8.3.1

2013-10-08 10:12:38

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 23/52] tools/perf/build: Split out feature check: 'libperl'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index ca59b56..145b519 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 017918f..3033c25 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-libperl.c b/tools/perf/config/feature-checks/test-libperl.c
new file mode 100644
index 0000000..8871f6a
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libperl.c
@@ -0,0 +1,9 @@
+#include <EXTERN.h>
+#include <perl.h>
+
+int main(void)
+{
+ perl_alloc();
+
+ return 0;
+}
--
1.8.3.1

2013-10-08 10:12:56

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 39/52] tools/perf/build: Automatically build in parallel, based on number of CPUs in the system

Implement 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. )

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile.parallel | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

diff --git a/tools/perf/Makefile.parallel b/tools/perf/Makefile.parallel
new file mode 100644
index 0000000..ec5e08b
--- /dev/null
+++ b/tools/perf/Makefile.parallel
@@ -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) $@
+
--
1.8.3.1

2013-10-08 10:12:47

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 36/52] tools/perf/build: Invoke feature-checks 'clean' target from the main Makefile

config/Makefile is not included for the 'clean' target, so invoke the
config/feature-checks/Makefile 'clean' target from Makefile.perf.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index df76198..6b7779b 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:12:52

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 41/52] tools/perf/build: Standardize the various messages output by parallel make

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile | 23 ++++++++++++++++++++---
tools/perf/config/Makefile | 4 ++--
2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index ce7874b..3b925ad 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 04d9dc0..65e0fad 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:13:14

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 52/52] tools/perf/build: Pass through LDFLAGS to feature tests

David 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.

Reported-by: David Ahern <[email protected]>
Tested-by: David Ahern <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/Makefile | 4 ++--
tools/perf/config/feature-checks/Makefile | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 593983f..c98ca34 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 69c5f63..604d55c 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -32,7 +32,7 @@ CC := $(CC) -MD

all: $(FILES)

-BUILD = $(CC) -o $(OUTPUT)$@ [email protected]
+BUILD = $(CC) $(LDFLAGS) -o $(OUTPUT)$@ [email protected]

###############################

--
1.8.3.1

2013-10-08 10:13:37

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 51/52] tools/perf/build: Harmonize the style of the feature testcases

The 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. )

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/feature-checks/test-backtrace.c b/tools/perf/config/feature-checks/test-backtrace.c
index 5b33bcf..7124aa1 100644
--- a/tools/perf/config/feature-checks/test-backtrace.c
+++ b/tools/perf/config/feature-checks/test-backtrace.c
@@ -11,4 +11,3 @@ int main(void)

return 0;
}
-
diff --git a/tools/perf/config/feature-checks/test-cplus-demangle.c b/tools/perf/config/feature-checks/test-cplus-demangle.c
index ab29f80..610c686 100644
--- a/tools/perf/config/feature-checks/test-cplus-demangle.c
+++ b/tools/perf/config/feature-checks/test-cplus-demangle.c
@@ -12,4 +12,3 @@ int main(void)

return 0;
}
-
diff --git a/tools/perf/config/feature-checks/test-dwarf.c b/tools/perf/config/feature-checks/test-dwarf.c
index 783dfcd..3fc1801 100644
--- a/tools/perf/config/feature-checks/test-dwarf.c
+++ b/tools/perf/config/feature-checks/test-dwarf.c
@@ -5,5 +5,6 @@
int main(void)
{
Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
+
return (long)dbg;
}
diff --git a/tools/perf/config/feature-checks/test-glibc.c b/tools/perf/config/feature-checks/test-glibc.c
index 13c66a5..b082034 100644
--- a/tools/perf/config/feature-checks/test-glibc.c
+++ b/tools/perf/config/feature-checks/test-glibc.c
@@ -3,6 +3,6 @@
int main(void)
{
const char *version = gnu_get_libc_version();
+
return (long)version;
}
-
diff --git a/tools/perf/config/feature-checks/test-libaudit.c b/tools/perf/config/feature-checks/test-libaudit.c
index f7e791e..afc019f 100644
--- a/tools/perf/config/feature-checks/test-libaudit.c
+++ b/tools/perf/config/feature-checks/test-libaudit.c
@@ -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();
}
diff --git a/tools/perf/config/feature-checks/test-libbfd.c b/tools/perf/config/feature-checks/test-libbfd.c
index 1886c78..2405990 100644
--- a/tools/perf/config/feature-checks/test-libbfd.c
+++ b/tools/perf/config/feature-checks/test-libbfd.c
@@ -13,4 +13,3 @@ int main(void)

return 0;
}
-
diff --git a/tools/perf/config/feature-checks/test-libelf-getphdrnum.c b/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
index 58eca53..d710459 100644
--- a/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
+++ b/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
@@ -1,7 +1,8 @@
#include <libelf.h>
-#
+
int main(void)
{
size_t dst;
+
return elf_getphdrnum(0, &dst);
}
diff --git a/tools/perf/config/feature-checks/test-libelf-mmap.c b/tools/perf/config/feature-checks/test-libelf-mmap.c
index 1c64815..564427d 100644
--- a/tools/perf/config/feature-checks/test-libelf-mmap.c
+++ b/tools/perf/config/feature-checks/test-libelf-mmap.c
@@ -1,7 +1,8 @@
#include <libelf.h>
-#
+
int main(void)
{
Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
+
return (long)elf;
}
diff --git a/tools/perf/config/feature-checks/test-libelf.c b/tools/perf/config/feature-checks/test-libelf.c
index 1a08f97..08db322 100644
--- a/tools/perf/config/feature-checks/test-libelf.c
+++ b/tools/perf/config/feature-checks/test-libelf.c
@@ -3,5 +3,6 @@
int main(void)
{
Elf *elf = elf_begin(0, ELF_C_READ, 0);
+
return (long)elf;
}
diff --git a/tools/perf/config/feature-checks/test-libnuma.c b/tools/perf/config/feature-checks/test-libnuma.c
index 70510a9..4763d9c 100644
--- a/tools/perf/config/feature-checks/test-libnuma.c
+++ b/tools/perf/config/feature-checks/test-libnuma.c
@@ -4,5 +4,6 @@
int main(void)
{
numa_available();
+
return 0;
}
diff --git a/tools/perf/config/feature-checks/test-libpython.c b/tools/perf/config/feature-checks/test-libpython.c
index 7226797..b24b28a 100644
--- a/tools/perf/config/feature-checks/test-libpython.c
+++ b/tools/perf/config/feature-checks/test-libpython.c
@@ -1,7 +1,8 @@
#include <Python.h>
-#
+
int main(void)
{
Py_Initialize();
+
return 0;
}
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak
deleted file mode 100644
index 139597f..0000000
--- a/tools/perf/config/feature-tests.mak
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
--
1.8.3.1

2013-10-08 10:13:55

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 49/52] tools/perf/build: Fix non-canonical directory names in O=

This 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 2

Fix this by canonizing the directory before passing it to Makefile.perf.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 74f52d8..9580ebe 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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

#
--
1.8.3.1

2013-10-08 10:14:01

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 47/52] tools/perf/build: Make sure autodep feature binaries honor the O= setting

Arnaldo 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.

Reported-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/Makefile | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 132cf82..593983f 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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

--
1.8.3.1

2013-10-08 10:13:58

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 48/52] tools/perf/build: Exclude MAKEFLAGS from nested invocation

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.
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.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 6f6f13a..74f52d8 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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

#
--
1.8.3.1

2013-10-08 10:13:54

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 50/52] tools/perf/build: Fix O=/some/dir perf.o type of targets

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

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.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile.perf | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 178a1c8..a24f6c2 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -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
--
1.8.3.1

2013-10-08 10:15:46

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 46/52] tools/perf/build: Pass through all targets to Makefile.perf

Jiri reported that 'make .o' stopped working:

> [jolsa@krava perf]$ make -f Makefile perf.o
> cc -c -o perf.o perf.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.

Reported-by: Jiri Olsa <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 3b925ad..6f6f13a 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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.
--
1.8.3.1

2013-10-08 10:15:50

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 45/52] tools/perf/build: Collapse the test-all.c testcase

Simplify test-all.c by including it all the testcases via #include.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/feature-checks/test-all.c | 290 +++++++++++++++++-------------------------------
1 file changed, 100 insertions(+), 190 deletions(-)

diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
index 9f7c4b1..50d4318 100644
--- a/tools/perf/config/feature-checks/test-all.c
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -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 main

int 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;
}
--
1.8.3.1

2013-10-08 10:16:17

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 43/52] tools/perf/build: Remove unused config/feature-tests.mak

Also remove try-cc et al. These got obsoleted by the split-out feature checks in
config/feature-checks/.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index fdc1cb0..132cf82 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak
index f793057..139597f 100644
--- a/tools/perf/config/feature-tests.mak
+++ b/tools/perf/config/feature-tests.mak
@@ -1,246 +1,2 @@
-define SOURCE_HELLO
-#include <stdio.h>
-int main(void)
-{
- return puts(\"hi\");
-}
-endef

-ifndef NO_DWARF
-define SOURCE_DWARF
-#include <dwarf.h>
-#include <elfutils/libdw.h>
-#include <elfutils/version.h>
-#ifndef _ELFUTILS_PREREQ
-#error
-#endif

-int main(void)
-{
- Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
- return (long)dbg;
-}
-endef
-endif
-
-define SOURCE_LIBELF
-#include <libelf.h>
-
-int main(void)
-{
- Elf *elf = elf_begin(0, ELF_C_READ, 0);
- return (long)elf;
-}
-endef
-
-define SOURCE_GLIBC
-#include <gnu/libc-version.h>
-
-int main(void)
-{
- const char *version = gnu_get_libc_version();
- return (long)version;
-}
-endef
-
-define SOURCE_BIONIC
-#include <android/api-level.h>
-
-int main(void)
-{
- return __ANDROID_API__;
-}
-endef
-
-define SOURCE_ELF_MMAP
-#include <libelf.h>
-int main(void)
-{
- Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
- return (long)elf;
-}
-endef
-
-define SOURCE_ELF_GETPHDRNUM
-#include <libelf.h>
-int main(void)
-{
- size_t dst;
- return elf_getphdrnum(0, &dst);
-}
-endef
-
-ifndef NO_SLANG
-define SOURCE_SLANG
-#include <slang.h>
-
-int main(void)
-{
- return SLsmg_init_smg();
-}
-endef
-endif
-
-ifndef NO_GTK2
-define SOURCE_GTK2
-#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;
-}
-endef
-
-define SOURCE_GTK2_INFOBAR
-#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;
-}
-endef
-endif
-
-ifndef NO_LIBPERL
-define SOURCE_PERL_EMBED
-#include <EXTERN.h>
-#include <perl.h>
-
-int main(void)
-{
-perl_alloc();
-return 0;
-}
-endef
-endif
-
-ifndef NO_LIBPYTHON
-define SOURCE_PYTHON_VERSION
-#include <Python.h>
-#if PY_VERSION_HEX >= 0x03000000
- #error
-#endif
-int main(void)
-{
- return 0;
-}
-endef
-define SOURCE_PYTHON_EMBED
-#include <Python.h>
-int main(void)
-{
- Py_Initialize();
- return 0;
-}
-endef
-endif
-
-define SOURCE_BFD
-#include <bfd.h>
-
-int main(void)
-{
- bfd_demangle(0, 0, 0);
- return 0;
-}
-endef
-
-define SOURCE_CPLUS_DEMANGLE
-extern char *cplus_demangle(const char *, int);
-
-int main(void)
-{
- cplus_demangle(0, 0);
- return 0;
-}
-endef
-
-define SOURCE_STRLCPY
-#include <stdlib.h>
-extern size_t strlcpy(char *dest, const char *src, size_t size);
-
-int main(void)
-{
- strlcpy(NULL, NULL, 0);
- return 0;
-}
-endef
-
-ifndef NO_LIBUNWIND
-define SOURCE_LIBUNWIND
-#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;
-}
-endef
-endif
-
-ifndef NO_BACKTRACE
-define SOURCE_BACKTRACE
-#include <execinfo.h>
-#include <stdio.h>
-
-int main(void)
-{
- backtrace(NULL, 0);
- backtrace_symbols(NULL, 0);
- return 0;
-}
-endef
-endif
-
-ifndef NO_LIBAUDIT
-define SOURCE_LIBAUDIT
-#include <libaudit.h>
-
-int main(void)
-{
- printf(\"error message: %s\", audit_errno_to_name(0));
- return audit_open();
-}
-endef
-endif
-
-define SOURCE_ON_EXIT
-#include <stdio.h>
-
-int main(void)
-{
- return on_exit(NULL, NULL);
-}
-endef
-
-define SOURCE_LIBNUMA
-#include <numa.h>
-#include <numaif.h>
-
-int main(void)
-{
- numa_available();
- return 0;
-}
-endef
diff --git a/tools/perf/config/utilities.mak b/tools/perf/config/utilities.mak
index 94d2d4f..4d985e0 100644
--- a/tools/perf/config/utilities.mak
+++ b/tools/perf/config/utilities.mak
@@ -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"')
--
1.8.3.1

2013-10-08 10:16:34

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 44/52] tools/perf/build: Clean up various testcases

Prepare 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.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/feature-checks/test-backtrace.c b/tools/perf/config/feature-checks/test-backtrace.c
index 5b79468..5b33bcf 100644
--- a/tools/perf/config/feature-checks/test-backtrace.c
+++ b/tools/perf/config/feature-checks/test-backtrace.c
@@ -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;
}
+
diff --git a/tools/perf/config/feature-checks/test-cplus-demangle.c b/tools/perf/config/feature-checks/test-cplus-demangle.c
index 5202f50..ab29f80 100644
--- a/tools/perf/config/feature-checks/test-cplus-demangle.c
+++ b/tools/perf/config/feature-checks/test-cplus-demangle.c
@@ -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;
}
diff --git a/tools/perf/config/feature-checks/test-gtk2-infobar.c b/tools/perf/config/feature-checks/test-gtk2-infobar.c
index eebcfbc..397b464 100644
--- a/tools/perf/config/feature-checks/test-gtk2-infobar.c
+++ b/tools/perf/config/feature-checks/test-gtk2-infobar.c
@@ -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;
diff --git a/tools/perf/config/feature-checks/test-gtk2.c b/tools/perf/config/feature-checks/test-gtk2.c
index 1ac6d8a..6bd80e5 100644
--- a/tools/perf/config/feature-checks/test-gtk2.c
+++ b/tools/perf/config/feature-checks/test-gtk2.c
@@ -4,7 +4,7 @@

int main(int argc, char *argv[])
{
- gtk_init(&argc, &argv);
+ gtk_init(&argc, &argv);

return 0;
}
diff --git a/tools/perf/config/feature-checks/test-libaudit.c b/tools/perf/config/feature-checks/test-libaudit.c
index 854a65d..f7e791e 100644
--- a/tools/perf/config/feature-checks/test-libaudit.c
+++ b/tools/perf/config/feature-checks/test-libaudit.c
@@ -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));
diff --git a/tools/perf/config/feature-checks/test-libbfd.c b/tools/perf/config/feature-checks/test-libbfd.c
index d03339c..1886c78 100644
--- a/tools/perf/config/feature-checks/test-libbfd.c
+++ b/tools/perf/config/feature-checks/test-libbfd.c
@@ -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;
}
+
diff --git a/tools/perf/config/feature-checks/test-libunwind.c b/tools/perf/config/feature-checks/test-libunwind.c
index 5622746..43b9369 100644
--- a/tools/perf/config/feature-checks/test-libunwind.c
+++ b/tools/perf/config/feature-checks/test-libunwind.c
@@ -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;
}
diff --git a/tools/perf/config/feature-checks/test-on-exit.c b/tools/perf/config/feature-checks/test-on-exit.c
index 473f1de..8f64ed3 100644
--- a/tools/perf/config/feature-checks/test-on-exit.c
+++ b/tools/perf/config/feature-checks/test-on-exit.c
@@ -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;
}
--
1.8.3.1

2013-10-08 10:16:40

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 37/52] tools/perf/build: Speed up auto-detection

The 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.)

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/Makefile | 49 +++++++++++++++++++++++++++++--------------------
tools/perf/config/feature-checks/Makefile | 31 ++++++++++++++++---------------
2 files changed, 45 insertions(+), 35 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 9a27aa9..f6ac70c 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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 )
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index b031669..2967a07 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

--
1.8.3.1

2013-10-08 10:16:36

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 38/52] tools/perf/build: Improve printout-of auto-detected features

Change 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. )

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/Makefile | 42 +++++++++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 9 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index f6ac70c..04d9dc0 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:16:28

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 40/52] tools/perf/build: Flip Makefile.parallel and Makefile.perf

To 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

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile | 844 ++-------------------------------------------------------------
tools/perf/Makefile.parallel | 26 --
tools/perf/Makefile.perf | 842 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 856 insertions(+), 856 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 6b7779b..ce7874b 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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) $@
diff --git a/tools/perf/Makefile.parallel b/tools/perf/Makefile.parallel
deleted file mode 100644
index ec5e08b..0000000
--- a/tools/perf/Makefile.parallel
+++ /dev/null
@@ -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) $@
-
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
new file mode 100644
index 0000000..178a1c8
--- /dev/null
+++ b/tools/perf/Makefile.perf
@@ -0,0 +1,842 @@
+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
+#
+# Define NO_LIBNUMA if you do not want numa perf benchmark
+#
+# 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
+ 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 $<
+
+$(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
+
+#
+# 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*
+ $(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
+
+.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
+
--
1.8.3.1

2013-10-08 10:16:19

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 42/52] tools/perf/build: Split out feature checks: 'liberty', 'liberty-z', 'cplus-demangle'

Note that these are rarely executed tests, so we call feature_check() explicitly
and don't have them in CORE_FEATURE_CHECKS.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 65e0fad..fdc1cb0 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 2967a07..69c5f63 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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)

diff --git a/tools/perf/config/feature-checks/test-cplus-demangle.c b/tools/perf/config/feature-checks/test-cplus-demangle.c
new file mode 100644
index 0000000..5202f50
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-cplus-demangle.c
@@ -0,0 +1,10 @@
+
+extern char *cplus_demangle(const char *, int);
+
+int main(void)
+{
+ cplus_demangle(0, 0);
+
+ return 0;
+}
+
--
1.8.3.1

2013-10-08 10:17:55

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 35/52] tools/perf: Fix double/triple-build of the feature detection logic during 'make install' et al

Linus 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.

Reported-by: Linus Torvalds <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Documentation/Makefile | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile
index 5a37a7c..eaa477f 100644
--- a/tools/perf/Documentation/Makefile
+++ b/tools/perf/Documentation/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:18:14

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 34/52] tools/perf/build: Speed up the final link

libtraceevent.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. ]

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 6b5452a..df76198 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:18:34

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target

Concatenate 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.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index cc857fb..9a27aa9 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index c65bdac..b031669 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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)

diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
new file mode 100644
index 0000000..9f7c4b1
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -0,0 +1,196 @@
+
+#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;
+}
+
+int 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();
+
+ return 0;
+}
--
1.8.3.1

2013-10-08 10:18:32

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 33/52] tools/perf/build: Speed up git-version test on re-make

util/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

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 64c043b..6b5452a 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:19:01

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 31/52] tools/perf: Turn strlcpy() into a __weak function

The 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.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 57ec8b6..cc857fb 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 0e4dbc2..c65bdac 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-strlcpy.c b/tools/perf/config/feature-checks/test-strlcpy.c
deleted file mode 100644
index 4a6b6ff..0000000
--- a/tools/perf/config/feature-checks/test-strlcpy.c
+++ /dev/null
@@ -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;
-}
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 442953c..7b176dd 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -70,8 +70,7 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2
extern 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 */
diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
index bef4d3d..b003ad7 100644
--- a/tools/perf/util/include/linux/compiler.h
+++ b/tools/perf/util/include/linux/compiler.h
@@ -23,4 +23,8 @@
# define __force
#endif

+#ifndef __weak
+# define __weak __attribute__((weak))
+#endif
+
#endif
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index f395874..5d13cb4 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -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)
{
--
1.8.3.1

2013-10-08 10:19:28

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 27/52] tools/perf/build: Split out feature check: 'strlcpy'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 15a3bce..079d8aa 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index af65aaa..d348aa0 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-strlcpy.c b/tools/perf/config/feature-checks/test-strlcpy.c
new file mode 100644
index 0000000..4a6b6ff
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-strlcpy.c
@@ -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;
+}
--
1.8.3.1

2013-10-08 10:19:24

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 28/52] tools/perf/build: Split out feature check: 'on-exit'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 079d8aa..2d6fcf4 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index d348aa0..20f1b8c 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-on-exit.c b/tools/perf/config/feature-checks/test-on-exit.c
new file mode 100644
index 0000000..473f1de
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-on-exit.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+ return on_exit(NULL, NULL);
+}
--
1.8.3.1

2013-10-08 10:19:22

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 29/52] tools/perf/build: Split out feature check: 'backtrace'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 2d6fcf4..57ec8b6 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 20f1b8c..0e4dbc2 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-backtrace.c b/tools/perf/config/feature-checks/test-backtrace.c
new file mode 100644
index 0000000..5b79468
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-backtrace.c
@@ -0,0 +1,10 @@
+#include <execinfo.h>
+#include <stdio.h>
+
+int main(void)
+{
+ backtrace(NULL, 0);
+ backtrace_symbols(NULL, 0);
+
+ return 0;
+}
--
1.8.3.1

2013-10-08 10:19:20

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 30/52] tools/perf: Clean up util/include/linux/compiler.h

Use the standard CPP style we use in the kernel:

#ifndef foo
# define foo bar
#endif

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/util/include/linux/compiler.h | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
index 96b919d..bef4d3d 100644
--- a/tools/perf/util/include/linux/compiler.h
+++ b/tools/perf/util/include/linux/compiler.h
@@ -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
--
1.8.3.1

2013-10-08 10:20:34

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 26/52] tools/perf/build: Split out feature check: 'libbfd'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 9585bde..15a3bce 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index d15074d..af65aaa 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-libbfd.c b/tools/perf/config/feature-checks/test-libbfd.c
new file mode 100644
index 0000000..d03339c
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libbfd.c
@@ -0,0 +1,7 @@
+#include <bfd.h>
+
+int main(void)
+{
+ bfd_demangle(0, 0, 0);
+ return 0;
+}
--
1.8.3.1

2013-10-08 10:21:03

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 25/52] tools/perf/build: Split out feature check: 'libpython-version'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 1b3ced4..9585bde 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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)
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index e7ed05a..d15074d 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-libpython-version.c b/tools/perf/config/feature-checks/test-libpython-version.c
new file mode 100644
index 0000000..facea12
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libpython-version.c
@@ -0,0 +1,10 @@
+#include <Python.h>
+
+#if PY_VERSION_HEX >= 0x03000000
+ #error
+#endif
+
+int main(void)
+{
+ return 0;
+}
--
1.8.3.1

2013-10-08 10:21:05

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 24/52] tools/perf/build: Split out feature check: 'libpython'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 145b519..1b3ced4 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 3033c25..e7ed05a 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-libpython.c b/tools/perf/config/feature-checks/test-libpython.c
new file mode 100644
index 0000000..7226797
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libpython.c
@@ -0,0 +1,7 @@
+#include <Python.h>
+#
+int main(void)
+{
+ Py_Initialize();
+ return 0;
+}
--
1.8.3.1

2013-10-08 10:21:43

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 22/52] tools/perf/build: Split out feature check: 'gtk2-infobar'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index c72a6fa..ca59b56 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 920958c..017918f 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-gtk2-infobar.c b/tools/perf/config/feature-checks/test-gtk2-infobar.c
new file mode 100644
index 0000000..eebcfbc
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-gtk2-infobar.c
@@ -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;
+}
--
1.8.3.1

2013-10-08 10:22:24

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 21/52] tools/perf/build: Split out feature check: 'gtk2'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index a8f2d67..c72a6fa 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index c9b15b0..920958c 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-gtk2.c b/tools/perf/config/feature-checks/test-gtk2.c
new file mode 100644
index 0000000..1ac6d8a
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-gtk2.c
@@ -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;
+}
--
1.8.3.1

2013-10-08 10:12:23

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 08/52] tools/perf/build: Split out feature check: 'fortify-source'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index a3de2f8..7a614f9 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 5693299..529317e 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-fortify-source.c b/tools/perf/config/feature-checks/test-fortify-source.c
new file mode 100644
index 0000000..c9f398d
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-fortify-source.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+ return puts("hi");
+}
--
1.8.3.1

2013-10-08 10:22:41

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 20/52] tools/perf/build: Split out feature check: 'libslang'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 7fda3a6..a8f2d67 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 8e49fa0..c9b15b0 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-libslang.c b/tools/perf/config/feature-checks/test-libslang.c
new file mode 100644
index 0000000..22ff22e
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libslang.c
@@ -0,0 +1,6 @@
+#include <slang.h>
+
+int main(void)
+{
+ return SLsmg_init_smg();
+}
--
1.8.3.1

2013-10-08 10:22:58

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 17/52] tools/perf/build: Clean up the libunwind logic in config/Makefile

Nest the rules properly. No change in functionality.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/Makefile | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 718b476..0d75587 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:23:16

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 16/52] tools/perf/build: Split out feature check: 'libelf-getphdrnum'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index bf1f021..718b476 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index bf96e34..83b3a02 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-libelf-getphdrnum.c b/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
new file mode 100644
index 0000000..58eca53
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
@@ -0,0 +1,7 @@
+#include <libelf.h>
+#
+int main(void)
+{
+ size_t dst;
+ return elf_getphdrnum(0, &dst);
+}
--
1.8.3.1

2013-10-08 10:12:20

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 09/52] tools/perf/build: Split out feature check: 'bionic'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 7a614f9..09e2ecc 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 529317e..191df97 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-bionic.c b/tools/perf/config/feature-checks/test-bionic.c
new file mode 100644
index 0000000..eac24e9
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-bionic.c
@@ -0,0 +1,6 @@
+#include <android/api-level.h>
+
+int main(void)
+{
+ return __ANDROID_API__;
+}
--
1.8.3.1

2013-10-08 10:23:58

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 15/52] tools/perf/build: Split out feature check: 'libelf-mmap'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 8a27de2..bf1f021 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 566a71d..bf96e34 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-libelf-mmap.c b/tools/perf/config/feature-checks/test-libelf-mmap.c
new file mode 100644
index 0000000..1c64815
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libelf-mmap.c
@@ -0,0 +1,7 @@
+#include <libelf.h>
+#
+int main(void)
+{
+ Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
+ return (long)elf;
+}
--
1.8.3.1

2013-10-08 10:24:28

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 13/52] tools/perf/build: Split out feature check: 'dwarf'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 8cd0fd8..89630b8 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index c0569c7..566a71d 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-dwarf.c b/tools/perf/config/feature-checks/test-dwarf.c
new file mode 100644
index 0000000..783dfcd
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-dwarf.c
@@ -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;
+}
--
1.8.3.1

2013-10-08 10:24:30

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 12/52] tools/perf/build: Split out feature check: 'glibc'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 6865428..8cd0fd8 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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)
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 789a38d..c0569c7 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-glibc.c b/tools/perf/config/feature-checks/test-glibc.c
new file mode 100644
index 0000000..13c66a5
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-glibc.c
@@ -0,0 +1,8 @@
+#include <gnu/libc-version.h>
+
+int main(void)
+{
+ const char *version = gnu_get_libc_version();
+ return (long)version;
+}
+
--
1.8.3.1

2013-10-08 10:24:25

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 14/52] tools/perf/build: Clean up the mmap logic in config/Makefile

Nest the rules properly. No change in functionality.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/Makefile | 51 ++++++++++++++++++++++++++-------------------------
1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 89630b8..8a27de2 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:25:10

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 10/52] tools/perf/build: Clean up the libelf logic in config/Makefile

Nest the rules properly. No change in functionality.

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/Makefile | 58 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 09e2ecc..a2e0e1b 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:25:57

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 06/52] tools/perf/build: Split out feature check: 'stackprotector'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 1a67371..9f94912 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 7538c14..46b7650 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-stackprotector.c b/tools/perf/config/feature-checks/test-stackprotector.c
new file mode 100644
index 0000000..c9f398d
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-stackprotector.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+ return puts("hi");
+}
--
1.8.3.1

2013-10-08 10:26:16

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 05/52] tools/perf/build: Split out feature check: 'stackprotector-all'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index f39fc22..1a67371 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 6a42ad2..7538c14 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

diff --git a/tools/perf/config/feature-checks/test-stackprotector-all.c b/tools/perf/config/feature-checks/test-stackprotector-all.c
new file mode 100644
index 0000000..c9f398d
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-stackprotector-all.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+ return puts("hi");
+}
--
1.8.3.1

2013-10-08 10:26:37

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 04/52] tools/perf/build: Split out feature check: 'libnuma'

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index daefe2d..f39fc22 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 4708cca..6a42ad2 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

###############################
diff --git a/tools/perf/config/feature-checks/test-libnuma.c b/tools/perf/config/feature-checks/test-libnuma.c
new file mode 100644
index 0000000..70510a9
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-libnuma.c
@@ -0,0 +1,8 @@
+#include <numa.h>
+#include <numaif.h>
+
+int main(void)
+{
+ numa_available();
+ return 0;
+}
--
1.8.3.1

2013-10-08 10:26:43

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 03/52] tools/perf/build: Add 'autodep' functionality, generate feature test dependencies automatically

Use 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

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/feature-checks/Makefile | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index b3f6372..4708cca 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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
--
1.8.3.1

2013-10-08 10:27:26

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH 01/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

Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h
index 7fcdcdb..e84ca76 100644
--- a/tools/perf/arch/x86/include/perf_regs.h
+++ b/tools/perf/arch/x86/include/perf_regs.h
@@ -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;
}
diff --git a/tools/perf/arch/x86/util/unwind.c b/tools/perf/arch/x86/util/unwind.c
index 78d956e..456a88c 100644
--- a/tools/perf/arch/x86/util/unwind.c
+++ b/tools/perf/arch/x86/util/unwind.c
@@ -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 */
diff --git a/tools/perf/bench/mem-memcpy-arch.h b/tools/perf/bench/mem-memcpy-arch.h
index a72e36c..57b4ed8 100644
--- a/tools/perf/bench/mem-memcpy-arch.h
+++ b/tools/perf/bench/mem-memcpy-arch.h
@@ -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);
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c
index 8cdca43..5ce71d3 100644
--- a/tools/perf/bench/mem-memcpy.c
+++ b/tools/perf/bench/mem-memcpy.c
@@ -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"
diff --git a/tools/perf/bench/mem-memset-arch.h b/tools/perf/bench/mem-memset-arch.h
index a040fa7..633800c 100644
--- a/tools/perf/bench/mem-memset-arch.h
+++ b/tools/perf/bench/mem-memset-arch.h
@@ -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);
diff --git a/tools/perf/bench/mem-memset.c b/tools/perf/bench/mem-memset.c
index 4a2f120..9af79d2 100644
--- a/tools/perf/bench/mem-memset.c
+++ b/tools/perf/bench/mem-memset.c
@@ -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"
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index 77298bf..33af80f 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -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 },
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index afe377b..f51a963 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -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);
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index e8a66f9..89acc17 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -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", &params.force_add, "forcibly add events"
" with existing name"),
-#ifdef DWARF_SUPPORT
+#ifdef HAVE_DWARF_SUPPORT
OPT_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"
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index a78db3f..cf36ba2 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -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]";
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 5f6f9b3..34be743 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -23,7 +23,7 @@ ifeq ($(ARCH),x86_64)
endif
ifeq (${IS_X86_64}, 1)
RAW_ARCH := x86_64
- CFLAGS += -DARCH_X86_64
+ CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
endif
NO_PERF_REGS := 0
@@ -31,7 +31,7 @@ ifeq ($(ARCH),x86_64)
endif

ifeq ($(NO_PERF_REGS),0)
- CFLAGS += -DHAVE_PERF_REGS
+ CFLAGS += -DHAVE_PERF_REGS_SUPPORT
endif

ifeq ($(src-perf),)
@@ -175,13 +175,13 @@ endif # SOURCE_LIBELF
endif # NO_LIBELF

ifndef NO_LIBELF
-CFLAGS += -DLIBELF_SUPPORT
+CFLAGS += -DHAVE_LIBELF_SUPPORT
FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
-ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y)
- CFLAGS += -DLIBELF_MMAP
+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),y)
- CFLAGS += -DHAVE_ELF_GETPHDRNUM
+ifeq ($(call try-cc,$(SOURCE_ELF_GETPHDRNUM),$(FLAGS_LIBELF),-DHAVE_ELF_GETPHDRNUM_SUPPORT),y)
+ CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
endif

# include ARCH specific config
@@ -192,7 +192,7 @@ 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 += -DDWARF_SUPPORT $(LIBDW_CFLAGS)
+ CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
LDFLAGS += $(LIBDW_LDFLAGS)
EXTLIBS += -lelf -ldw
endif # PERF_HAVE_DWARF_REGS
@@ -201,10 +201,10 @@ endif # NO_DWARF
endif # NO_LIBELF

ifndef NO_LIBELF
-CFLAGS += -DLIBELF_SUPPORT
+CFLAGS += -DHAVE_LIBELF_SUPPORT
FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
-ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y)
- CFLAGS += -DLIBELF_MMAP
+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

@@ -229,7 +229,7 @@ endif # Libunwind support
endif # NO_LIBUNWIND

ifndef NO_LIBUNWIND
- CFLAGS += -DLIBUNWIND_SUPPORT
+ CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
EXTLIBS += $(LIBUNWIND_LIBS)
CFLAGS += $(LIBUNWIND_CFLAGS)
LDFLAGS += $(LIBUNWIND_LDFLAGS)
@@ -241,7 +241,7 @@ ifndef NO_LIBAUDIT
msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
NO_LIBAUDIT := 1
else
- CFLAGS += -DLIBAUDIT_SUPPORT
+ CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
EXTLIBS += -laudit
endif
endif
@@ -258,7 +258,7 @@ ifndef NO_SLANG
else
# Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
CFLAGS += -I/usr/include/slang
- CFLAGS += -DSLANG_SUPPORT
+ CFLAGS += -DHAVE_SLANG_SUPPORT
EXTLIBS += -lslang
endif
endif
@@ -269,10 +269,10 @@ 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),y)
- CFLAGS += -DHAVE_GTK_INFO_BAR
+ ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR_SUPPORT),y)
+ CFLAGS += -DHAVE_GTK_INFO_BAR_SUPPORT
endif
- CFLAGS += -DGTK2_SUPPORT
+ CFLAGS += -DHAVE_GTK2_SUPPORT
CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
endif
@@ -365,9 +365,9 @@ endif
ifdef NO_DEMANGLE
CFLAGS += -DNO_DEMANGLE
else
- ifdef HAVE_CPLUS_DEMANGLE
+ ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
EXTLIBS += -liberty
- CFLAGS += -DHAVE_CPLUS_DEMANGLE
+ CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
else
FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd
has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd)
@@ -388,7 +388,7 @@ else
has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle)
ifeq ($(has_cplus_demangle),y)
EXTLIBS += -liberty
- CFLAGS += -DHAVE_CPLUS_DEMANGLE
+ CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
else
msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
CFLAGS += -DNO_DEMANGLE
@@ -400,20 +400,20 @@ else
endif

ifndef NO_STRLCPY
- ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y)
- CFLAGS += -DHAVE_STRLCPY
+ ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY_SUPPORT),y)
+ CFLAGS += -DHAVE_STRLCPY_SUPPORT
endif
endif

ifndef NO_ON_EXIT
- ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y)
- CFLAGS += -DHAVE_ON_EXIT
+ ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT_SUPPORT),y)
+ CFLAGS += -DHAVE_ON_EXIT_SUPPORT
endif
endif

ifndef NO_BACKTRACE
- ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y)
- CFLAGS += -DBACKTRACE_SUPPORT
+ ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DHAVE_BACKTRACE_SUPPORT),y)
+ CFLAGS += -DHAVE_BACKTRACE_SUPPORT
endif
endif

@@ -423,7 +423,7 @@ ifndef NO_LIBNUMA
msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev);
NO_LIBNUMA := 1
else
- CFLAGS += -DLIBNUMA_SUPPORT
+ CFLAGS += -DHAVE_LIBNUMA_SUPPORT
EXTLIBS += -lnuma
endif
endif
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 85e1aed..245020c 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -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 },
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c
index c95012c..c24d912 100644
--- a/tools/perf/ui/gtk/browser.c
+++ b/tools/perf/ui/gtk/browser.c
@@ -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;
diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h
index 3d96785..a72acbc 100644
--- a/tools/perf/ui/gtk/gtk.h
+++ b/tools/perf/ui/gtk/gtk.h
@@ -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)
diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c
index c06942a..696c1fb 100644
--- a/tools/perf/ui/gtk/util.c
+++ b/tools/perf/ui/gtk/util.c
@@ -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,
diff --git a/tools/perf/ui/ui.h b/tools/perf/ui/ui.h
index 70cb0d4..1349d14 100644
--- a/tools/perf/ui/ui.h
+++ b/tools/perf/ui/ui.h
@@ -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
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index af75515..f0699e9 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -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);
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 26e3672..442953c 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -70,7 +70,7 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2
extern 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

diff --git a/tools/perf/util/generate-cmdlist.sh b/tools/perf/util/generate-cmdlist.sh
index 3ac3803..36a885d 100755
--- a/tools/perf/util/generate-cmdlist.sh
+++ b/tools/perf/util/generate-cmdlist.sh
@@ -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 "};"
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 6a048c0..ed4f90e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -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);
diff --git a/tools/perf/util/include/dwarf-regs.h b/tools/perf/util/include/dwarf-regs.h
index cf6727e..8f14965 100644
--- a/tools/perf/util/include/dwarf-regs.h
+++ b/tools/perf/util/include/dwarf-regs.h
@@ -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

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 4f6680d..17ee458 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -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);

diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index a8c4954..f395874 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -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);
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h
index 5a4f2b6f..a3d42cd 100644
--- a/tools/perf/util/perf_regs.h
+++ b/tools/perf/util/perf_regs.h
@@ -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 */
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index aa04bf9..779b2da 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -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)
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index 3b7d630..3f0c29d 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -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 */
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index a9c829b..c376930 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -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;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index fd5b70e..2a97bb1 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -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;

diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index cb6bc50..ec0c71a 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -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 */
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 6d17b18..ccfdeb6 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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];
--
1.8.3.1

2013-10-08 12:04:40

by Pádraig Brady

[permalink] [raw]
Subject: RE: [PATCH 39/52] tools/perf/build: Automatically build in parallel, based on number of CPUs in the syst

On 10/08/2013 10:02 AM, Ingo Molnar wrote:
> +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.

> + ifeq ($(JOBS),)
> + JOBS := 1
> + endif
> +endif

2013-10-08 12:22:26

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 39/52] tools/perf/build: Automatically build in parallel, based on number of CPUs in the syst


* P?draig Brady <[email protected]> wrote:

> On 10/08/2013 10:02 AM, Ingo Molnar wrote:
> > +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

2013-10-08 15:21:12

by David Ahern

[permalink] [raw]
Subject: Re: [PATCH 18/52] tools/perf/build: Split out feature check: 'libunwind'

On 10/8/13 4:10 AM, Ingo Molnar wrote:
> @@ -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

2013-10-08 15:51:35

by Jiri Olsa

[permalink] [raw]
Subject: 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

> diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
> index c65bdac..b031669 100644
> --- a/tools/perf/config/feature-checks/Makefile
> +++ b/tools/perf/config/feature-checks/Makefile
> @@ -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

2013-10-09 06:45:10

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 18/52] tools/perf/build: Split out feature check: 'libunwind'


* David Ahern <[email protected]> wrote:

> On 10/8/13 4:10 AM, Ingo Molnar wrote:
> >@@ -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.

Oops - restored it.

Thanks,

Ingo

2013-10-09 06:47:36

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target


* Jiri Olsa <[email protected]> wrote:

> On Tue, Oct 08, 2013 at 12:11:02PM +0200, Ingo Molnar wrote:
>
> SNIP
>
> > diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
> > index c65bdac..b031669 100644
> > --- a/tools/perf/config/feature-checks/Makefile
> > +++ b/tools/perf/config/feature-checks/Makefile
> > @@ -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 ? ;-)

Indeed :-) Fixed.

Thanks,

Ingo

2013-10-10 05:42:50

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 02/52] tools/perf/build: Add feature check core code

Hi Ingo,

On Tue, 8 Oct 2013 12:10:32 +0200, Ingo Molnar wrote:
> +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)))

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

2013-10-10 05:44:24

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 03/52] tools/perf/build: Add 'autodep' functionality, generate feature test dependencies automatically

On Tue, 8 Oct 2013 12:10:33 +0200, Ingo Molnar wrote:
> +-include *.d */*.d

Hmm.. this */*.d part is really needed?

> +
> ###############################
>
> clean:
> - rm -f $(FILES)
> + rm -f $(FILES) *.d

If so, at least it'd be deleted from here IMHO.

Thanks,
Namhyung

2013-10-10 05:50:13

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 06/52] tools/perf/build: Split out feature check: 'stackprotector'

On Tue, 8 Oct 2013 12:10:36 +0200, Ingo Molnar wrote:
> -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y)
> +ifeq ($(feature-stackprotector), 1)
> CFLAGS += -Wstack-protector
> endif

[SNIP]

> +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

2013-10-10 05:56:00

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 07/52] tools/perf/build: Split out feature check: 'volatile-register-var'

On Tue, 8 Oct 2013 12:10:37 +0200, Ingo Molnar wrote:
> -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
>
> diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
> index 46b7650..5693299 100644
> --- a/tools/perf/config/feature-checks/Makefile
> +++ b/tools/perf/config/feature-checks/Makefile
> @@ -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

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

2013-10-10 06:00:26

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 15/52] tools/perf/build: Split out feature check: 'libelf-mmap'

On Tue, 8 Oct 2013 12:10:45 +0200, Ingo Molnar wrote:
> @@ -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

As Ulrich Drepper reported, it seems that this hunk is duplicate.

Thanks,
Namhyung

2013-10-10 06:07:50

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 26/52] tools/perf/build: Split out feature check: 'libbfd'

On Tue, 8 Oct 2013 12:10:56 +0200, Ingo Molnar wrote:
> +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

2013-10-10 06:12:19

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 28/52] tools/perf/build: Split out feature check: 'on-exit'

> diff --git a/tools/perf/config/feature-checks/test-on-exit.c b/tools/perf/config/feature-checks/test-on-exit.c
> new file mode 100644
> index 0000000..473f1de
> --- /dev/null
> +++ b/tools/perf/config/feature-checks/test-on-exit.c
> @@ -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

2013-10-10 06:19:20

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target

On Tue, 8 Oct 2013 12:11:02 +0200, Ingo Molnar wrote:
> +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

2013-10-10 06:20:31

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 44/52] tools/perf/build: Clean up various testcases

On Tue, 8 Oct 2013 12:11:14 +0200, Ingo Molnar wrote:
> --- a/tools/perf/config/feature-checks/test-gtk2.c
> +++ b/tools/perf/config/feature-checks/test-gtk2.c
> @@ -4,7 +4,7 @@
>
> int main(int argc, char *argv[])
> {
> - gtk_init(&argc, &argv);
> + gtk_init(&argc, &argv);
>
> return 0;
> }

Whitespace damaged.

Thanks,
Namhyung

2013-10-10 06:25:01

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 48/52] tools/perf/build: Exclude MAKEFLAGS from nested invocation

On Tue, 8 Oct 2013 12:11:18 +0200, Ingo Molnar wrote:
> 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.
> 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.

Hmm... it'd be great if there's a way to detect -jN option and convert
it to the JOBS.

Thanks,
Namhyung

2013-10-10 06:35:16

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 50/52] tools/perf/build: Fix O=/some/dir perf.o type of targets

On Tue, 8 Oct 2013 12:11:20 +0200, Ingo Molnar wrote:
> 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
>
> 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.

> +#
> +# 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

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 2


Thanks,
Namhyung

2013-10-10 06:36:09

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 48/52] tools/perf/build: Exclude MAKEFLAGS from nested invocation


* Namhyung Kim <[email protected]> wrote:

> On Tue, 8 Oct 2013 12:11:18 +0200, Ingo Molnar wrote:
> > 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.
> > 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.
>
> 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

2013-10-10 06:39:22

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 50/52] tools/perf/build: Fix O=/some/dir perf.o type of targets


* Namhyung Kim <[email protected]> wrote:

> On Tue, 8 Oct 2013 12:11:20 +0200, Ingo Molnar wrote:
> > 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
> >
> > 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.

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?

> > +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.

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

2013-10-10 06:41:51

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 44/52] tools/perf/build: Clean up various testcases


* Namhyung Kim <[email protected]> wrote:

> On Tue, 8 Oct 2013 12:11:14 +0200, Ingo Molnar wrote:
> > --- a/tools/perf/config/feature-checks/test-gtk2.c
> > +++ b/tools/perf/config/feature-checks/test-gtk2.c
> > @@ -4,7 +4,7 @@
> >
> > int main(int argc, char *argv[])
> > {
> > - gtk_init(&argc, &argv);
> > + gtk_init(&argc, &argv);
> >
> > return 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

2013-10-10 06:43:26

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 28/52] tools/perf/build: Split out feature check: 'on-exit'


* Namhyung Kim <[email protected]> wrote:

> > diff --git a/tools/perf/config/feature-checks/test-on-exit.c b/tools/perf/config/feature-checks/test-on-exit.c
> > new file mode 100644
> > index 0000000..473f1de
> > --- /dev/null
> > +++ b/tools/perf/config/feature-checks/test-on-exit.c
> > @@ -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.

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

2013-10-10 06:50:31

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH] 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 -ldl

Fix all affected places and use Namhyung's suggestion that the
definition should look like a normal C string: -DPACKAGE='"perf"'.

Reported-by: Namhyung Kim <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/feature-checks/Makefile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 8ecac19..cf33596 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

2013-10-10 06:50:46

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 26/52] tools/perf/build: Split out feature check: 'libbfd'


* Namhyung Kim <[email protected]> wrote:

> On Tue, 8 Oct 2013 12:10:56 +0200, Ingo Molnar wrote:
> > +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.

Agreed - I sent the fix in a separate mail.

Thanks,

Ingo

2013-10-10 06:56:13

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 15/52] tools/perf/build: Split out feature check: 'libelf-mmap'


* Namhyung Kim <[email protected]> wrote:

> On Tue, 8 Oct 2013 12:10:45 +0200, Ingo Molnar wrote:
> > @@ -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
>
> As 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

2013-10-10 06:57:09

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH] tools/perf/build: Simplify the libelf logic

Ulrich 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.

Reported-by: Ulrich Drepper <[email protected]>
Reported-by: Namhyung Kim <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/Makefile | 8 --------
1 file changed, 8 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 3227107..587dd7e 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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

2013-10-10 07:03:23

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 07/52] tools/perf/build: Split out feature check: 'volatile-register-var'


* Namhyung Kim <[email protected]> wrote:

> > +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.

Good point - I'll send a patch to remove it.

Thanks,

Ingo

2013-10-10 07:03:52

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH] tools/perf/build: Remove the volatile-register-var feature check

Namhyung Kim noticed that the volatile-register-var feature check
is superfluous:

> 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.

Reported-by: Namhyung Kim <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/Makefile | 7 +------
tools/perf/config/feature-checks/Makefile | 8 ++------
2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 587dd7e..d38119f 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -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
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index cf33596..2eb8346 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

2013-10-10 07:09:04

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 06/52] tools/perf/build: Split out feature check: 'stackprotector'


* Namhyung Kim <[email protected]> wrote:

> On Tue, 8 Oct 2013 12:10:36 +0200, Ingo Molnar wrote:
> > -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y)
> > +ifeq ($(feature-stackprotector), 1)
> > CFLAGS += -Wstack-protector
> > endif
>
> [SNIP]
>
> > +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

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

2013-10-10 07:10:02

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH] tools/perf/build: Improve the 'stackprotector' feature test

Namhyung Kim noticed that the stackprotector testcase was incomplete:

> 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.

Reported-by: Namhyung Kim <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/feature-checks/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 2eb8346..c70d23e 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -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

2013-10-10 07:12:24

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 03/52] tools/perf/build: Add 'autodep' functionality, generate feature test dependencies automatically


* Namhyung Kim <[email protected]> wrote:

> On Tue, 8 Oct 2013 12:10:33 +0200, Ingo Molnar wrote:
> > +-include *.d */*.d
>
> Hmm.. this */*.d part is really needed?

Indeed! :-) I'll remove it.

Thanks,

Ingo

2013-10-10 07:12:58

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH] tools/perf/build: Simplify the autodep inclusion rule

Namhyung Kim noticed that the autodep .d file inclusion rule was
unnecessarily complicated:

> > +-include *.d */*.d
>
> Hmm.. this */*.d part is really needed?

Only include *.d files.

Reported-by: Namhyung Kim <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/config/feature-checks/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index c70d23e..452b67c 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -136,7 +136,7 @@ test-on-exit:
test-backtrace:
$(BUILD)

--include *.d */*.d
+-include *.d

###############################

2013-10-10 07:21:26

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 02/52] tools/perf/build: Add feature check core code


* Namhyung Kim <[email protected]> wrote:

> Hi Ingo,
>
> On Tue, 8 Oct 2013 12:10:32 +0200, Ingo Molnar wrote:
> > +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)))
>
> 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?

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

2013-10-10 07:24:18

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target


* Namhyung Kim <[email protected]> wrote:

> On Tue, 8 Oct 2013 12:11:02 +0200, Ingo Molnar wrote:
> > +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.

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

2013-10-10 08:22:11

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 02/52] tools/perf/build: Add feature check core code

On Thu, 10 Oct 2013 09:21:21 +0200, Ingo Molnar wrote:
> * Namhyung Kim <[email protected]> wrote:
>
>> Hi Ingo,
>>
>> On Tue, 8 Oct 2013 12:10:32 +0200, Ingo Molnar wrote:
>> > +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)))
>>
>> 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?
>
> 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.

Okay, got it. Thanks for the explanation! :)

>
> 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

2013-10-10 08:28:25

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 32/52] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target

On Thu, 10 Oct 2013 09:24:13 +0200, Ingo Molnar wrote:
> * Namhyung Kim <[email protected]> wrote:
>
>> On Tue, 8 Oct 2013 12:11:02 +0200, Ingo Molnar wrote:
>> > +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.
>
> 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?

Well, I'll try to do it tomorrow. :)

Thanks,
Namhyung

2013-10-10 08:43:09

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 50/52] tools/perf/build: Fix O=/some/dir perf.o type of targets

Hi,

On Thu, 10 Oct 2013 08:39:18 +0200, Ingo Molnar wrote:
> 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?
>
>> > +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.
>
> 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.

>
> 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