LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 00/14] tools build: Move features framework into tools/build
@ 2015-03-03 14:26 Jiri Olsa
  2015-03-03 14:26 ` [PATCH 01/14] tools build: Remove Copyright from credits message Jiri Olsa
                   ` (14 more replies)
  0 siblings, 15 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

hi,
moving features detection framework from perf to 'tools/build'
plus other minor fixes.

It's also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/build

thanks,
jirka


Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
Jiri Olsa (14):
      tools build: Remove Copyright from credits message
      perf build: Get rid of LIB_INCLUDE variable
      perf build: Rename CORE_FEATURE_TESTS to FEATURE_TESTS
      perf build: Get rid of VF_FEATURE_TESTS
      perf build: Rename display_lib into feature_display
      perf build: Rename display_vf to feature_verbose
      perf build: Rename PERF-FEATURES into FEATURE-DUMP
      perf build: Rename feature_print_var_code to print_var_code
      perf build: Separate feature make support into config/Makefile.feature
      perf build: Make features checks directory configurable
      tools build: Move feature checks code under tools/build
      tools build: Allow to override feature checks setup
      tools build: Fix feature_check name clash
      tools build: Disable default check for libbabeltrace

 tools/build/Documentation/Feature.txt              |  93 +++++++++
 tools/build/Makefile.build                         |   9 +-
 tools/build/Makefile.feature                       | 169 ++++++++++++++++
 .../feature-checks => build/feature}/.gitignore    |   0
 .../feature-checks => build/feature}/Makefile      |   2 +-
 .../feature-checks => build/feature}/test-all.c    |   8 +
 .../feature}/test-backtrace.c                      |   0
 .../feature-checks => build/feature}/test-bionic.c |   0
 .../feature}/test-compile.c                        |   0
 .../feature}/test-cplus-demangle.c                 |   0
 .../feature-checks => build/feature}/test-dwarf.c  |   0
 .../feature}/test-fortify-source.c                 |   0
 .../feature-checks => build/feature}/test-glibc.c  |   0
 .../feature}/test-gtk2-infobar.c                   |   0
 .../feature-checks => build/feature}/test-gtk2.c   |   0
 .../feature-checks => build/feature}/test-hello.c  |   0
 .../feature}/test-libaudit.c                       |   0
 .../feature}/test-libbabeltrace.c                  |   0
 .../feature-checks => build/feature}/test-libbfd.c |   0
 .../feature}/test-libdw-dwarf-unwind.c             |   0
 .../feature}/test-libelf-getphdrnum.c              |   0
 .../feature}/test-libelf-mmap.c                    |   0
 .../feature-checks => build/feature}/test-libelf.c |   0
 .../feature}/test-libnuma.c                        |   0
 .../feature}/test-libperl.c                        |   0
 .../feature}/test-libpython-version.c              |   0
 .../feature}/test-libpython.c                      |   0
 .../feature}/test-libslang.c                       |   0
 .../feature}/test-libunwind-debug-frame.c          |   0
 .../feature}/test-libunwind.c                      |   0
 .../feature}/test-pthread-attr-setaffinity-np.c    |   0
 .../feature}/test-stackprotector-all.c             |   0
 .../feature}/test-sync-compare-and-swap.c          |   0
 .../feature}/test-timerfd.c                        |   0
 .../feature-checks => build/feature}/test-zlib.c   |   0
 tools/build/tests/features/Makefile                |  23 +++
 tools/build/tests/features/Makefile.test1          |  16 ++
 tools/build/tests/run.sh                           |   4 +-
 tools/perf/Makefile.perf                           |   4 +-
 tools/perf/config/Makefile                         | 212 ++-------------------
 40 files changed, 334 insertions(+), 206 deletions(-)
 create mode 100644 tools/build/Documentation/Feature.txt
 create mode 100644 tools/build/Makefile.feature
 rename tools/{perf/config/feature-checks => build/feature}/.gitignore (100%)
 rename tools/{perf/config/feature-checks => build/feature}/Makefile (97%)
 rename tools/{perf/config/feature-checks => build/feature}/test-all.c (94%)
 rename tools/{perf/config/feature-checks => build/feature}/test-backtrace.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-bionic.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-compile.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-cplus-demangle.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-dwarf.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-fortify-source.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-glibc.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-gtk2-infobar.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-gtk2.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-hello.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libaudit.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libbabeltrace.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libbfd.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libdw-dwarf-unwind.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libelf-getphdrnum.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libelf-mmap.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libelf.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libnuma.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libperl.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libpython-version.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libpython.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libslang.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libunwind-debug-frame.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libunwind.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-pthread-attr-setaffinity-np.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-stackprotector-all.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-sync-compare-and-swap.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-timerfd.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-zlib.c (100%)
 create mode 100644 tools/build/tests/features/Makefile
 create mode 100644 tools/build/tests/features/Makefile.test1

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 01/14] tools build: Remove Copyright from credits message
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 02/14] perf build: Get rid of LIB_INCLUDE variable Jiri Olsa
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

It's not a 'Copyright' message just credits.

Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/build/Makefile.build | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build
index 10df57237a66..8700cc313061 100644
--- a/tools/build/Makefile.build
+++ b/tools/build/Makefile.build
@@ -1,12 +1,11 @@
 ###
 # Main build makefile.
 #
-#  Lots of this code have been borrowed or heavily inspired from parts
-#  of kbuild code, which is not credited, but mostly developed by:
-#
-#  Copyright (C) Sam Ravnborg <sam@mars.ravnborg.org>, 2015
-#  Copyright (C) Linus Torvalds <torvalds@linux-foundation.org>, 2015
+#  Lots of this code have been borrowed or heavily inspired
+#  from parts of kbuild code, which was mostly developed by:
 #
+#   Sam Ravnborg <sam@mars.ravnborg.org>
+#   Linus Torvalds <torvalds@linux-foundation.org>
 
 PHONY := __build
 __build:
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 02/14] perf build: Get rid of LIB_INCLUDE variable
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
  2015-03-03 14:26 ` [PATCH 01/14] tools build: Remove Copyright from credits message Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 03/14] perf build: Rename CORE_FEATURE_TESTS to FEATURE_TESTS Jiri Olsa
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

It has no use, so we can directly use the value for CFLAGS.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/config/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index d44c64d64465..661316a367c7 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -15,7 +15,6 @@ $(shell echo -n > .config-detected)
 detected     = $(shell echo "$(1)=y"       >> .config-detected)
 detected_var = $(shell echo "$(1)=$($(1))" >> .config-detected)
 
-LIB_INCLUDE := $(srctree)/tools/lib/
 CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
 
 include $(src-perf)/config/Makefile.arch
@@ -322,7 +321,7 @@ endif
 
 CFLAGS += -I$(src-perf)/util
 CFLAGS += -I$(src-perf)
-CFLAGS += -I$(LIB_INCLUDE)
+CFLAGS += -I$(srctree)/tools/lib/
 
 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 03/14] perf build: Rename CORE_FEATURE_TESTS to FEATURE_TESTS
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
  2015-03-03 14:26 ` [PATCH 01/14] tools build: Remove Copyright from credits message Jiri Olsa
  2015-03-03 14:26 ` [PATCH 02/14] perf build: Get rid of LIB_INCLUDE variable Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 04/14] perf build: Get rid of VF_FEATURE_TESTS Jiri Olsa
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Preparing for feature checks separation, moving related
stuff under 'FEATURE*' namespace.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/config/Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 661316a367c7..8f0b9c319187 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -203,7 +203,7 @@ endef
 #   the rule that uses them - an example for that is the 'bionic'
 #   feature check. ]
 #
-CORE_FEATURE_TESTS =			\
+FEATURE_TESTS =			\
 	backtrace			\
 	dwarf				\
 	fortify-source			\
@@ -264,7 +264,7 @@ VF_FEATURE_TESTS =			\
 	compile-32			\
 	compile-x32
 
-# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
+# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
 # If in the future we need per-feature checks/flags for features not
 # mentioned in this list we need to refactor this ;-).
 set_test_all_flags = $(eval $(set_test_all_flags_code))
@@ -273,7 +273,7 @@ define set_test_all_flags_code
   FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
 endef
 
-$(foreach feat,$(CORE_FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
+$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
 
 #
 # Special fast-path for the 'all features are available' case:
@@ -288,10 +288,10 @@ ifeq ($(feature-all), 1)
   #
   # test-all.c passed - just set all the core feature flags to 1:
   #
-  $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
 else
-  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(CORE_FEATURE_TESTS)) >/dev/null 2>&1)
-  $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
+  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
 endif
 
 ifeq ($(feature-stackprotector-all), 1)
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 04/14] perf build: Get rid of VF_FEATURE_TESTS
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (2 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 03/14] perf build: Rename CORE_FEATURE_TESTS to FEATURE_TESTS Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 05/14] perf build: Rename display_lib into feature_display Jiri Olsa
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

It only contains (FEATURE_TESTS - FEATURE_DISPLAY) tests to display
the rest of the checks on 'make VF=1'. But we can actually compute
this list, which is less confusing.

Also renaming LIB_FEATURE_TESTS into FEATURE_DISPLAY, so it reflects
what this variable actually does - display its tests status to user.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/config/Makefile | 32 +++++++-------------------------
 1 file changed, 7 insertions(+), 25 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 8f0b9c319187..09135b763e6d 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -229,7 +229,7 @@ FEATURE_TESTS =			\
 	libbabeltrace			\
 	zlib
 
-LIB_FEATURE_TESTS =			\
+FEATURE_DISPLAY =			\
 	dwarf				\
 	glibc				\
 	gtk2				\
@@ -245,25 +245,6 @@ LIB_FEATURE_TESTS =			\
 	libbabeltrace			\
 	zlib
 
-VF_FEATURE_TESTS =			\
-	backtrace			\
-	fortify-source			\
-	sync-compare-and-swap		\
-	gtk2-infobar			\
-	libelf-getphdrnum		\
-	libelf-mmap			\
-	libpython-version		\
-	pthread-attr-setaffinity-np	\
-	stackprotector-all		\
-	timerfd				\
-	libunwind-debug-frame		\
-	bionic				\
-	liberty				\
-	liberty-z			\
-	cplus-demangle			\
-	compile-32			\
-	compile-x32
-
 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
 # If in the future we need per-feature checks/flags for features not
 # mentioned in this list we need to refactor this ;-).
@@ -806,7 +787,7 @@ define feature_print_text_code
     MSG = $(shell printf '...%30s: %s' $(1) $(2))
 endef
 
-PERF_FEATURES := $(foreach feat,$(LIB_FEATURE_TESTS),feature-$(feat)($(feature-$(feat))))
+PERF_FEATURES := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
 PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
 
 ifeq ($(dwarf-post-unwind),1)
@@ -817,7 +798,7 @@ endif
 # output. It's set if:
 # - detected features differes from stored features from
 #   last build (in PERF-FEATURES file)
-# - one of the $(LIB_FEATURE_TESTS) is not detected
+# - one of the $(FEATURE_DISPLAY) is not detected
 # - VF is enabled
 
 ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
@@ -832,7 +813,7 @@ define feature_check_code
   endif
 endef
 
-$(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_check,$(feat)))
+$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
 
 ifeq ($(VF),1)
   display_lib := 1
@@ -842,7 +823,7 @@ endif
 ifeq ($(display_lib),1)
   $(info )
   $(info Auto-detecting system features:)
-  $(foreach feat,$(LIB_FEATURE_TESTS),$(call feature_print_status,$(feat),))
+  $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
 
   ifeq ($(dwarf-post-unwind),1)
     $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
@@ -850,7 +831,8 @@ ifeq ($(display_lib),1)
 endif
 
 ifeq ($(display_vf),1)
-  $(foreach feat,$(VF_FEATURE_TESTS),$(call feature_print_status,$(feat),))
+  TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
+  $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
   $(info )
   $(call feature_print_var,prefix)
   $(call feature_print_var,bindir)
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 05/14] perf build: Rename display_lib into feature_display
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (3 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 04/14] perf build: Get rid of VF_FEATURE_TESTS Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 06/14] perf build: Rename display_vf to feature_verbose Jiri Olsa
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Preparing for feature checks separation, moving related
stuff under 'feature*' namespace.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/config/Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 09135b763e6d..03d420570d6c 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -794,7 +794,7 @@ ifeq ($(dwarf-post-unwind),1)
   PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
 endif
 
-# The $(display_lib) controls the default detection message
+# The $(feature_display) controls the default detection message
 # output. It's set if:
 # - detected features differes from stored features from
 #   last build (in PERF-FEATURES file)
@@ -803,24 +803,24 @@ endif
 
 ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
   $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
-  display_lib := 1
+  feature_display := 1
 endif
 
 feature_check = $(eval $(feature_check_code))
 define feature_check_code
   ifneq ($(feature-$(1)), 1)
-    display_lib := 1
+    feature_display := 1
   endif
 endef
 
 $(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
 
 ifeq ($(VF),1)
-  display_lib := 1
+  feature_display := 1
   display_vf := 1
 endif
 
-ifeq ($(display_lib),1)
+ifeq ($(feature_display),1)
   $(info )
   $(info Auto-detecting system features:)
   $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
@@ -842,7 +842,7 @@ ifeq ($(display_vf),1)
   $(call feature_print_var,LIBDW_DIR)
 endif
 
-ifeq ($(display_lib),1)
+ifeq ($(feature_display),1)
   $(info )
 endif
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 06/14] perf build: Rename display_vf to feature_verbose
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (4 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 05/14] perf build: Rename display_lib into feature_display Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 07/14] perf build: Rename PERF-FEATURES into FEATURE-DUMP Jiri Olsa
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Preparing for feature checks separation, moving related
stuff under 'feature*' namespace.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/config/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 03d420570d6c..7b6e712d98a6 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -817,7 +817,7 @@ $(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
 
 ifeq ($(VF),1)
   feature_display := 1
-  display_vf := 1
+  feature_verbose := 1
 endif
 
 ifeq ($(feature_display),1)
@@ -830,7 +830,7 @@ ifeq ($(feature_display),1)
   endif
 endif
 
-ifeq ($(display_vf),1)
+ifeq ($(feature_verbose),1)
   TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
   $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
   $(info )
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 07/14] perf build: Rename PERF-FEATURES into FEATURE-DUMP
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (5 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 06/14] perf build: Rename display_vf to feature_verbose Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 08/14] perf build: Rename feature_print_var_code to print_var_code Jiri Olsa
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Preparing for feature checks separation, moving related
stuff under 'FEATURE*' namespace.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/Makefile.perf   |  2 +-
 tools/perf/config/Makefile | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index ec4c063ed9f3..e323eab10694 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -528,7 +528,7 @@ clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean
 	$(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
 	$(Q)$(RM) .config-detected
 	$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32
-	$(call QUIET_CLEAN, core-gen)   $(RM)  *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-FEATURES $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex*
+	$(call QUIET_CLEAN, core-gen)   $(RM)  *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex*
 	$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
 	$(python-clean)
 
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 7b6e712d98a6..7906b795e2d8 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -787,22 +787,22 @@ define feature_print_text_code
     MSG = $(shell printf '...%30s: %s' $(1) $(2))
 endef
 
-PERF_FEATURES := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
-PERF_FEATURES_FILE := $(shell touch $(OUTPUT)PERF-FEATURES; cat $(OUTPUT)PERF-FEATURES)
+FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
+FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
 
 ifeq ($(dwarf-post-unwind),1)
-  PERF_FEATURES += dwarf-post-unwind($(dwarf-post-unwind-text))
+  FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
 endif
 
 # The $(feature_display) controls the default detection message
 # output. It's set if:
 # - detected features differes from stored features from
-#   last build (in PERF-FEATURES file)
+#   last build (in FEATURE-DUMP file)
 # - one of the $(FEATURE_DISPLAY) is not detected
 # - VF is enabled
 
-ifneq ("$(PERF_FEATURES)","$(PERF_FEATURES_FILE)")
-  $(shell echo "$(PERF_FEATURES)" > $(OUTPUT)PERF-FEATURES)
+ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
+  $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
   feature_display := 1
 endif
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 08/14] perf build: Rename feature_print_var_code to print_var_code
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (6 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 07/14] perf build: Rename PERF-FEATURES into FEATURE-DUMP Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 09/14] perf build: Separate feature make support into config/Makefile.feature Jiri Olsa
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

As it has nothing to do with features and won't be moved
into tools/build.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/config/Makefile | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 7906b795e2d8..3706d29b4d99 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -777,8 +777,8 @@ define feature_print_status_code
   endif
 endef
 
-feature_print_var = $(eval $(feature_print_var_code)) $(info $(MSG))
-define feature_print_var_code
+print_var = $(eval $(print_var_code)) $(info $(MSG))
+define print_var_code
     MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
 endef
 
@@ -828,21 +828,22 @@ ifeq ($(feature_display),1)
   ifeq ($(dwarf-post-unwind),1)
     $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
   endif
+
+  ifneq ($(feature_verbose),1)
+    $(info )
+  endif
 endif
 
 ifeq ($(feature_verbose),1)
   TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
   $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
   $(info )
-  $(call feature_print_var,prefix)
-  $(call feature_print_var,bindir)
-  $(call feature_print_var,libdir)
-  $(call feature_print_var,sysconfdir)
-  $(call feature_print_var,LIBUNWIND_DIR)
-  $(call feature_print_var,LIBDW_DIR)
-endif
-
-ifeq ($(feature_display),1)
+  $(call print_var,prefix)
+  $(call print_var,bindir)
+  $(call print_var,libdir)
+  $(call print_var,sysconfdir)
+  $(call print_var,LIBUNWIND_DIR)
+  $(call print_var,LIBDW_DIR)
   $(info )
 endif
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 09/14] perf build: Separate feature make support into config/Makefile.feature
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (7 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 08/14] perf build: Rename feature_print_var_code to print_var_code Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 10/14] perf build: Make features checks directory configurable Jiri Olsa
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Move feature related code into separate makefile. The new
Makefile.feature is included from config/Makefile. It will
be moved later into tools/build.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/config/Makefile         | 167 +-----------------------------------
 tools/perf/config/Makefile.feature | 169 +++++++++++++++++++++++++++++++++++++
 2 files changed, 170 insertions(+), 166 deletions(-)
 create mode 100644 tools/perf/config/Makefile.feature

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 3706d29b4d99..01d8acc5453e 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -176,104 +176,7 @@ LDFLAGS += -Wl,-z,noexecstack
 
 EXTLIBS = -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) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin >/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:
-#
-
-#
-# 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. ]
-#
-FEATURE_TESTS =			\
-	backtrace			\
-	dwarf				\
-	fortify-source			\
-	sync-compare-and-swap		\
-	glibc				\
-	gtk2				\
-	gtk2-infobar			\
-	libaudit			\
-	libbfd				\
-	libelf				\
-	libelf-getphdrnum		\
-	libelf-mmap			\
-	libnuma				\
-	libperl				\
-	libpython			\
-	libpython-version		\
-	libslang			\
-	libunwind			\
-	pthread-attr-setaffinity-np	\
-	stackprotector-all		\
-	timerfd				\
-	libdw-dwarf-unwind		\
-	libbabeltrace			\
-	zlib
-
-FEATURE_DISPLAY =			\
-	dwarf				\
-	glibc				\
-	gtk2				\
-	libaudit			\
-	libbfd				\
-	libelf				\
-	libnuma				\
-	libperl				\
-	libpython			\
-	libslang			\
-	libunwind			\
-	libdw-dwarf-unwind		\
-	libbabeltrace			\
-	zlib
-
-# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
-# If in the future we need per-feature checks/flags for features not
-# mentioned in this list we need to refactor this ;-).
-set_test_all_flags = $(eval $(set_test_all_flags_code))
-define set_test_all_flags_code
-  FEATURE_CHECK_CFLAGS-all  += $(FEATURE_CHECK_CFLAGS-$(1))
-  FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
-endef
-
-$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
-
-#
-# Special fast-path for the 'all features are available' case:
-#
-$(call feature_check,all,$(MSG))
-
-#
-# Just in case the build freshly failed, make sure we print the
-# feature matrix:
-#
-ifeq ($(feature-all), 1)
-  #
-  # test-all.c passed - just set all the core feature flags to 1:
-  #
-  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
-else
-  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
-  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
-endif
+include $(src-perf)/config/Makefile.feature
 
 ifeq ($(feature-stackprotector-all), 1)
   CFLAGS += -fstack-protector-all
@@ -764,80 +667,12 @@ plugindir=$(libdir)/traceevent/plugins
 plugindir_SQ= $(subst ','\'',$(plugindir))
 endif
 
-#
-# Print the result of the feature test:
-#
-feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
-
-define feature_print_status_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
-endef
-
 print_var = $(eval $(print_var_code)) $(info $(MSG))
 define print_var_code
     MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
 endef
 
-feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
-define feature_print_text_code
-    MSG = $(shell printf '...%30s: %s' $(1) $(2))
-endef
-
-FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
-FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
-
-ifeq ($(dwarf-post-unwind),1)
-  FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
-endif
-
-# The $(feature_display) controls the default detection message
-# output. It's set if:
-# - detected features differes from stored features from
-#   last build (in FEATURE-DUMP file)
-# - one of the $(FEATURE_DISPLAY) is not detected
-# - VF is enabled
-
-ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
-  $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
-  feature_display := 1
-endif
-
-feature_check = $(eval $(feature_check_code))
-define feature_check_code
-  ifneq ($(feature-$(1)), 1)
-    feature_display := 1
-  endif
-endef
-
-$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
-
 ifeq ($(VF),1)
-  feature_display := 1
-  feature_verbose := 1
-endif
-
-ifeq ($(feature_display),1)
-  $(info )
-  $(info Auto-detecting system features:)
-  $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
-
-  ifeq ($(dwarf-post-unwind),1)
-    $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
-  endif
-
-  ifneq ($(feature_verbose),1)
-    $(info )
-  endif
-endif
-
-ifeq ($(feature_verbose),1)
-  TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
-  $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
-  $(info )
   $(call print_var,prefix)
   $(call print_var,bindir)
   $(call print_var,libdir)
diff --git a/tools/perf/config/Makefile.feature b/tools/perf/config/Makefile.feature
new file mode 100644
index 000000000000..32f4f453f3d1
--- /dev/null
+++ b/tools/perf/config/Makefile.feature
@@ -0,0 +1,169 @@
+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) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin >/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:
+#
+
+#
+# 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. ]
+#
+FEATURE_TESTS =			\
+	backtrace			\
+	dwarf				\
+	fortify-source			\
+	sync-compare-and-swap		\
+	glibc				\
+	gtk2				\
+	gtk2-infobar			\
+	libaudit			\
+	libbfd				\
+	libelf				\
+	libelf-getphdrnum		\
+	libelf-mmap			\
+	libnuma				\
+	libperl				\
+	libpython			\
+	libpython-version		\
+	libslang			\
+	libunwind			\
+	pthread-attr-setaffinity-np	\
+	stackprotector-all		\
+	timerfd				\
+	libdw-dwarf-unwind		\
+	libbabeltrace			\
+	zlib
+
+FEATURE_DISPLAY =			\
+	dwarf				\
+	glibc				\
+	gtk2				\
+	libaudit			\
+	libbfd				\
+	libelf				\
+	libnuma				\
+	libperl				\
+	libpython			\
+	libslang			\
+	libunwind			\
+	libdw-dwarf-unwind		\
+	libbabeltrace			\
+	zlib
+
+# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
+# If in the future we need per-feature checks/flags for features not
+# mentioned in this list we need to refactor this ;-).
+set_test_all_flags = $(eval $(set_test_all_flags_code))
+define set_test_all_flags_code
+  FEATURE_CHECK_CFLAGS-all  += $(FEATURE_CHECK_CFLAGS-$(1))
+  FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
+endef
+
+$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
+
+#
+# Special fast-path for the 'all features are available' case:
+#
+$(call feature_check,all,$(MSG))
+
+#
+# Just in case the build freshly failed, make sure we print the
+# feature matrix:
+#
+ifeq ($(feature-all), 1)
+  #
+  # test-all.c passed - just set all the core feature flags to 1:
+  #
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
+else
+  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
+endif
+
+#
+# Print the result of the feature test:
+#
+feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
+
+define feature_print_status_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
+endef
+
+feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
+define feature_print_text_code
+    MSG = $(shell printf '...%30s: %s' $(1) $(2))
+endef
+
+FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
+FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
+
+ifeq ($(dwarf-post-unwind),1)
+  FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
+endif
+
+# The $(feature_display) controls the default detection message
+# output. It's set if:
+# - detected features differes from stored features from
+#   last build (in FEATURE-DUMP file)
+# - one of the $(FEATURE_DISPLAY) is not detected
+# - VF is enabled
+
+ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
+  $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
+  feature_display := 1
+endif
+
+feature_check = $(eval $(feature_check_code))
+define feature_check_code
+  ifneq ($(feature-$(1)), 1)
+    feature_display := 1
+  endif
+endef
+
+$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
+
+ifeq ($(VF),1)
+  feature_display := 1
+  feature_verbose := 1
+endif
+
+ifeq ($(feature_display),1)
+  $(info )
+  $(info Auto-detecting system features:)
+  $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
+
+  ifeq ($(dwarf-post-unwind),1)
+    $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
+  endif
+
+  ifneq ($(feature_verbose),1)
+    $(info )
+  endif
+endif
+
+ifeq ($(feature_verbose),1)
+  TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
+  $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
+  $(info )
+endif
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 10/14] perf build: Make features checks directory configurable
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (8 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 09/14] perf build: Separate feature make support into config/Makefile.feature Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 11/14] tools build: Move feature checks code under tools/build Jiri Olsa
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Putting feature checks directory into $feature_dir, so it's
easy to configure when we move it to bools/build later.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/config/Makefile.feature | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/config/Makefile.feature b/tools/perf/config/Makefile.feature
index 32f4f453f3d1..55b671a93d67 100644
--- a/tools/perf/config/Makefile.feature
+++ b/tools/perf/config/Makefile.feature
@@ -1,3 +1,5 @@
+feature_dir := $(srctree)/tools/perf/config/feature-checks
+
 ifneq ($(OUTPUT),)
   OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
   $(shell mkdir -p $(OUTPUT_FEATURES))
@@ -5,7 +7,7 @@ endif
 
 feature_check = $(eval $(feature_check_code))
 define feature_check_code
-  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
+  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
 endef
 
 feature_set = $(eval $(feature_set_code))
@@ -93,7 +95,7 @@ ifeq ($(feature-all), 1)
   #
   $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
 else
-  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
+  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C $(feature_dir) $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
   $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
 endif
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 11/14] tools build: Move feature checks code under tools/build
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (9 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 10/14] perf build: Make features checks directory configurable Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 17:18   ` David Ahern
  2015-03-03 14:26 ` [PATCH 12/14] tools build: Allow to override feature checks setup Jiri Olsa
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Moving feature checks code under tools/build directory.

Changing also $feature_dir to point to new feature directory
location and perf Makefiles to include Makefile.feature from
new location.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/build/Makefile.feature                       | 171 +++++++++++++++++++++
 tools/build/feature/.gitignore                     |   2 +
 tools/build/feature/Makefile                       | 159 +++++++++++++++++++
 tools/build/feature/test-all.c                     | 136 ++++++++++++++++
 tools/build/feature/test-backtrace.c               |  13 ++
 tools/build/feature/test-bionic.c                  |   6 +
 tools/build/feature/test-compile.c                 |   4 +
 tools/build/feature/test-cplus-demangle.c          |  14 ++
 tools/build/feature/test-dwarf.c                   |  10 ++
 tools/build/feature/test-fortify-source.c          |   6 +
 tools/build/feature/test-glibc.c                   |   8 +
 tools/build/feature/test-gtk2-infobar.c            |  11 ++
 tools/build/feature/test-gtk2.c                    |  10 ++
 tools/build/feature/test-hello.c                   |   6 +
 tools/build/feature/test-libaudit.c                |  10 ++
 tools/build/feature/test-libbabeltrace.c           |   8 +
 tools/build/feature/test-libbfd.c                  |  15 ++
 tools/build/feature/test-libdw-dwarf-unwind.c      |  13 ++
 tools/build/feature/test-libelf-getphdrnum.c       |   8 +
 tools/build/feature/test-libelf-mmap.c             |   8 +
 tools/build/feature/test-libelf.c                  |   8 +
 tools/build/feature/test-libnuma.c                 |   9 ++
 tools/build/feature/test-libperl.c                 |   9 ++
 tools/build/feature/test-libpython-version.c       |  10 ++
 tools/build/feature/test-libpython.c               |   8 +
 tools/build/feature/test-libslang.c                |   6 +
 tools/build/feature/test-libunwind-debug-frame.c   |  16 ++
 tools/build/feature/test-libunwind.c               |  27 ++++
 .../feature/test-pthread-attr-setaffinity-np.c     |  17 ++
 tools/build/feature/test-stackprotector-all.c      |   6 +
 tools/build/feature/test-sync-compare-and-swap.c   |  14 ++
 tools/build/feature/test-timerfd.c                 |  18 +++
 tools/build/feature/test-zlib.c                    |   9 ++
 tools/perf/Makefile.perf                           |   2 +-
 tools/perf/config/Makefile                         |   2 +-
 tools/perf/config/Makefile.feature                 | 171 ---------------------
 tools/perf/config/feature-checks/.gitignore        |   2 -
 tools/perf/config/feature-checks/Makefile          | 159 -------------------
 tools/perf/config/feature-checks/test-all.c        | 136 ----------------
 tools/perf/config/feature-checks/test-backtrace.c  |  13 --
 tools/perf/config/feature-checks/test-bionic.c     |   6 -
 tools/perf/config/feature-checks/test-compile.c    |   4 -
 .../config/feature-checks/test-cplus-demangle.c    |  14 --
 tools/perf/config/feature-checks/test-dwarf.c      |  10 --
 .../config/feature-checks/test-fortify-source.c    |   6 -
 tools/perf/config/feature-checks/test-glibc.c      |   8 -
 .../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 --
 .../config/feature-checks/test-libbabeltrace.c     |   8 -
 tools/perf/config/feature-checks/test-libbfd.c     |  15 --
 .../feature-checks/test-libdw-dwarf-unwind.c       |  13 --
 .../config/feature-checks/test-libelf-getphdrnum.c |   8 -
 .../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 --
 .../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 -
 .../feature-checks/test-libunwind-debug-frame.c    |  16 --
 tools/perf/config/feature-checks/test-libunwind.c  |  27 ----
 .../test-pthread-attr-setaffinity-np.c             |  17 --
 .../feature-checks/test-stackprotector-all.c       |   6 -
 .../feature-checks/test-sync-compare-and-swap.c    |  14 --
 tools/perf/config/feature-checks/test-timerfd.c    |  18 ---
 tools/perf/config/feature-checks/test-zlib.c       |   9 --
 68 files changed, 777 insertions(+), 777 deletions(-)
 create mode 100644 tools/build/Makefile.feature
 create mode 100644 tools/build/feature/.gitignore
 create mode 100644 tools/build/feature/Makefile
 create mode 100644 tools/build/feature/test-all.c
 create mode 100644 tools/build/feature/test-backtrace.c
 create mode 100644 tools/build/feature/test-bionic.c
 create mode 100644 tools/build/feature/test-compile.c
 create mode 100644 tools/build/feature/test-cplus-demangle.c
 create mode 100644 tools/build/feature/test-dwarf.c
 create mode 100644 tools/build/feature/test-fortify-source.c
 create mode 100644 tools/build/feature/test-glibc.c
 create mode 100644 tools/build/feature/test-gtk2-infobar.c
 create mode 100644 tools/build/feature/test-gtk2.c
 create mode 100644 tools/build/feature/test-hello.c
 create mode 100644 tools/build/feature/test-libaudit.c
 create mode 100644 tools/build/feature/test-libbabeltrace.c
 create mode 100644 tools/build/feature/test-libbfd.c
 create mode 100644 tools/build/feature/test-libdw-dwarf-unwind.c
 create mode 100644 tools/build/feature/test-libelf-getphdrnum.c
 create mode 100644 tools/build/feature/test-libelf-mmap.c
 create mode 100644 tools/build/feature/test-libelf.c
 create mode 100644 tools/build/feature/test-libnuma.c
 create mode 100644 tools/build/feature/test-libperl.c
 create mode 100644 tools/build/feature/test-libpython-version.c
 create mode 100644 tools/build/feature/test-libpython.c
 create mode 100644 tools/build/feature/test-libslang.c
 create mode 100644 tools/build/feature/test-libunwind-debug-frame.c
 create mode 100644 tools/build/feature/test-libunwind.c
 create mode 100644 tools/build/feature/test-pthread-attr-setaffinity-np.c
 create mode 100644 tools/build/feature/test-stackprotector-all.c
 create mode 100644 tools/build/feature/test-sync-compare-and-swap.c
 create mode 100644 tools/build/feature/test-timerfd.c
 create mode 100644 tools/build/feature/test-zlib.c
 delete mode 100644 tools/perf/config/Makefile.feature
 delete mode 100644 tools/perf/config/feature-checks/.gitignore
 delete mode 100644 tools/perf/config/feature-checks/Makefile
 delete mode 100644 tools/perf/config/feature-checks/test-all.c
 delete mode 100644 tools/perf/config/feature-checks/test-backtrace.c
 delete mode 100644 tools/perf/config/feature-checks/test-bionic.c
 delete mode 100644 tools/perf/config/feature-checks/test-compile.c
 delete mode 100644 tools/perf/config/feature-checks/test-cplus-demangle.c
 delete mode 100644 tools/perf/config/feature-checks/test-dwarf.c
 delete mode 100644 tools/perf/config/feature-checks/test-fortify-source.c
 delete mode 100644 tools/perf/config/feature-checks/test-glibc.c
 delete mode 100644 tools/perf/config/feature-checks/test-gtk2-infobar.c
 delete mode 100644 tools/perf/config/feature-checks/test-gtk2.c
 delete mode 100644 tools/perf/config/feature-checks/test-hello.c
 delete mode 100644 tools/perf/config/feature-checks/test-libaudit.c
 delete mode 100644 tools/perf/config/feature-checks/test-libbabeltrace.c
 delete mode 100644 tools/perf/config/feature-checks/test-libbfd.c
 delete mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
 delete mode 100644 tools/perf/config/feature-checks/test-libelf-getphdrnum.c
 delete mode 100644 tools/perf/config/feature-checks/test-libelf-mmap.c
 delete mode 100644 tools/perf/config/feature-checks/test-libelf.c
 delete mode 100644 tools/perf/config/feature-checks/test-libnuma.c
 delete mode 100644 tools/perf/config/feature-checks/test-libperl.c
 delete mode 100644 tools/perf/config/feature-checks/test-libpython-version.c
 delete mode 100644 tools/perf/config/feature-checks/test-libpython.c
 delete mode 100644 tools/perf/config/feature-checks/test-libslang.c
 delete mode 100644 tools/perf/config/feature-checks/test-libunwind-debug-frame.c
 delete mode 100644 tools/perf/config/feature-checks/test-libunwind.c
 delete mode 100644 tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
 delete mode 100644 tools/perf/config/feature-checks/test-stackprotector-all.c
 delete mode 100644 tools/perf/config/feature-checks/test-sync-compare-and-swap.c
 delete mode 100644 tools/perf/config/feature-checks/test-timerfd.c
 delete mode 100644 tools/perf/config/feature-checks/test-zlib.c

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
new file mode 100644
index 000000000000..3249fad27993
--- /dev/null
+++ b/tools/build/Makefile.feature
@@ -0,0 +1,171 @@
+feature_dir := $(srctree)/tools/build/feature
+
+ifneq ($(OUTPUT),)
+  OUTPUT_FEATURES = $(OUTPUT)feature/
+  $(shell mkdir -p $(OUTPUT_FEATURES))
+endif
+
+feature_check = $(eval $(feature_check_code))
+define feature_check_code
+  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/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:
+#
+
+#
+# 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. ]
+#
+FEATURE_TESTS =			\
+	backtrace			\
+	dwarf				\
+	fortify-source			\
+	sync-compare-and-swap		\
+	glibc				\
+	gtk2				\
+	gtk2-infobar			\
+	libaudit			\
+	libbfd				\
+	libelf				\
+	libelf-getphdrnum		\
+	libelf-mmap			\
+	libnuma				\
+	libperl				\
+	libpython			\
+	libpython-version		\
+	libslang			\
+	libunwind			\
+	pthread-attr-setaffinity-np	\
+	stackprotector-all		\
+	timerfd				\
+	libdw-dwarf-unwind		\
+	libbabeltrace			\
+	zlib
+
+FEATURE_DISPLAY =			\
+	dwarf				\
+	glibc				\
+	gtk2				\
+	libaudit			\
+	libbfd				\
+	libelf				\
+	libnuma				\
+	libperl				\
+	libpython			\
+	libslang			\
+	libunwind			\
+	libdw-dwarf-unwind		\
+	libbabeltrace			\
+	zlib
+
+# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
+# If in the future we need per-feature checks/flags for features not
+# mentioned in this list we need to refactor this ;-).
+set_test_all_flags = $(eval $(set_test_all_flags_code))
+define set_test_all_flags_code
+  FEATURE_CHECK_CFLAGS-all  += $(FEATURE_CHECK_CFLAGS-$(1))
+  FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
+endef
+
+$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
+
+#
+# Special fast-path for the 'all features are available' case:
+#
+$(call feature_check,all,$(MSG))
+
+#
+# Just in case the build freshly failed, make sure we print the
+# feature matrix:
+#
+ifeq ($(feature-all), 1)
+  #
+  # test-all.c passed - just set all the core feature flags to 1:
+  #
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
+else
+  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C $(feature_dir) $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
+endif
+
+#
+# Print the result of the feature test:
+#
+feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
+
+define feature_print_status_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
+endef
+
+feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
+define feature_print_text_code
+    MSG = $(shell printf '...%30s: %s' $(1) $(2))
+endef
+
+FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
+FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
+
+ifeq ($(dwarf-post-unwind),1)
+  FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
+endif
+
+# The $(feature_display) controls the default detection message
+# output. It's set if:
+# - detected features differes from stored features from
+#   last build (in FEATURE-DUMP file)
+# - one of the $(FEATURE_DISPLAY) is not detected
+# - VF is enabled
+
+ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
+  $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
+  feature_display := 1
+endif
+
+feature_check = $(eval $(feature_check_code))
+define feature_check_code
+  ifneq ($(feature-$(1)), 1)
+    feature_display := 1
+  endif
+endef
+
+$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
+
+ifeq ($(VF),1)
+  feature_display := 1
+  feature_verbose := 1
+endif
+
+ifeq ($(feature_display),1)
+  $(info )
+  $(info Auto-detecting system features:)
+  $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
+
+  ifeq ($(dwarf-post-unwind),1)
+    $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
+  endif
+
+  ifneq ($(feature_verbose),1)
+    $(info )
+  endif
+endif
+
+ifeq ($(feature_verbose),1)
+  TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
+  $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
+  $(info )
+endif
diff --git a/tools/build/feature/.gitignore b/tools/build/feature/.gitignore
new file mode 100644
index 000000000000..80f3da0c3515
--- /dev/null
+++ b/tools/build/feature/.gitignore
@@ -0,0 +1,2 @@
+*.d
+*.bin
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
new file mode 100644
index 000000000000..8fe067864957
--- /dev/null
+++ b/tools/build/feature/Makefile
@@ -0,0 +1,159 @@
+
+FILES=					\
+	test-all.bin			\
+	test-backtrace.bin		\
+	test-bionic.bin			\
+	test-dwarf.bin			\
+	test-fortify-source.bin		\
+	test-sync-compare-and-swap.bin	\
+	test-glibc.bin			\
+	test-gtk2.bin			\
+	test-gtk2-infobar.bin		\
+	test-hello.bin			\
+	test-libaudit.bin		\
+	test-libbfd.bin			\
+	test-liberty.bin		\
+	test-liberty-z.bin		\
+	test-cplus-demangle.bin		\
+	test-libelf.bin			\
+	test-libelf-getphdrnum.bin	\
+	test-libelf-mmap.bin		\
+	test-libnuma.bin		\
+	test-libperl.bin		\
+	test-libpython.bin		\
+	test-libpython-version.bin	\
+	test-libslang.bin		\
+	test-libunwind.bin		\
+	test-libunwind-debug-frame.bin	\
+	test-pthread-attr-setaffinity-np.bin	\
+	test-stackprotector-all.bin	\
+	test-timerfd.bin		\
+	test-libdw-dwarf-unwind.bin	\
+	test-libbabeltrace.bin		\
+	test-compile-32.bin		\
+	test-compile-x32.bin		\
+	test-zlib.bin
+
+CC := $(CROSS_COMPILE)gcc -MD
+PKG_CONFIG := $(CROSS_COMPILE)pkg-config
+
+all: $(FILES)
+
+BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
+
+###############################
+
+test-all.bin:
+	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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 -lz -lbabeltrace
+
+test-hello.bin:
+	$(BUILD)
+
+test-pthread-attr-setaffinity-np.bin:
+	$(BUILD) -D_GNU_SOURCE -lpthread
+
+test-stackprotector-all.bin:
+	$(BUILD) -fstack-protector-all
+
+test-fortify-source.bin:
+	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
+
+test-bionic.bin:
+	$(BUILD)
+
+test-libelf.bin:
+	$(BUILD) -lelf
+
+test-glibc.bin:
+	$(BUILD)
+
+test-dwarf.bin:
+	$(BUILD) -ldw
+
+test-libelf-mmap.bin:
+	$(BUILD) -lelf
+
+test-libelf-getphdrnum.bin:
+	$(BUILD) -lelf
+
+test-libnuma.bin:
+	$(BUILD) -lnuma
+
+test-libunwind.bin:
+	$(BUILD) -lelf
+
+test-libunwind-debug-frame.bin:
+	$(BUILD) -lelf
+
+test-libaudit.bin:
+	$(BUILD) -laudit
+
+test-libslang.bin:
+	$(BUILD) -I/usr/include/slang -lslang
+
+test-gtk2.bin:
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
+
+test-gtk2-infobar.bin:
+	$(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.bin:
+	$(BUILD) $(FLAGS_PERL_EMBED)
+
+test-libpython.bin:
+	$(BUILD)
+
+test-libpython-version.bin:
+	$(BUILD)
+
+test-libbfd.bin:
+	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
+
+test-liberty.bin:
+	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
+
+test-liberty-z.bin:
+	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
+
+test-cplus-demangle.bin:
+	$(BUILD) -liberty
+
+test-backtrace.bin:
+	$(BUILD)
+
+test-timerfd.bin:
+	$(BUILD)
+
+test-libdw-dwarf-unwind.bin:
+	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
+
+test-libbabeltrace.bin:
+	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
+
+test-sync-compare-and-swap.bin:
+	$(BUILD)
+
+test-compile-32.bin:
+	$(CC) -m32 -o $(OUTPUT)$@ test-compile.c
+
+test-compile-x32.bin:
+	$(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
+
+test-zlib.bin:
+	$(BUILD) -lz
+
+-include *.d
+
+###############################
+
+clean:
+	rm -f $(FILES) *.d
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
new file mode 100644
index 000000000000..1ffc3da5ca10
--- /dev/null
+++ b/tools/build/feature/test-all.c
@@ -0,0 +1,136 @@
+/*
+ * 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_backtrace
+# include "test-backtrace.c"
+#undef main
+
+#define main main_test_libnuma
+# include "test-libnuma.c"
+#undef main
+
+#define main main_test_timerfd
+# include "test-timerfd.c"
+#undef main
+
+#define main main_test_stackprotector_all
+# include "test-stackprotector-all.c"
+#undef main
+
+#define main main_test_libdw_dwarf_unwind
+# include "test-libdw-dwarf-unwind.c"
+#undef main
+
+#define main main_test_sync_compare_and_swap
+# include "test-sync-compare-and-swap.c"
+#undef main
+
+#define main main_test_zlib
+# include "test-zlib.c"
+#undef main
+
+#define main main_test_pthread_attr_setaffinity_np
+# include "test-pthread_attr_setaffinity_np.c"
+#undef main
+
+#define main main_test_libbabeltrace
+# include "test-libbabeltrace.c"
+#undef main
+
+int main(int argc, char *argv[])
+{
+	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_backtrace();
+	main_test_libnuma();
+	main_test_timerfd();
+	main_test_stackprotector_all();
+	main_test_libdw_dwarf_unwind();
+	main_test_sync_compare_and_swap(argc, argv);
+	main_test_zlib();
+	main_test_pthread_attr_setaffinity_np();
+	main_test_libbabeltrace();
+
+	return 0;
+}
diff --git a/tools/build/feature/test-backtrace.c b/tools/build/feature/test-backtrace.c
new file mode 100644
index 000000000000..7124aa1dc8fb
--- /dev/null
+++ b/tools/build/feature/test-backtrace.c
@@ -0,0 +1,13 @@
+#include <execinfo.h>
+#include <stdio.h>
+
+int main(void)
+{
+	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/build/feature/test-bionic.c b/tools/build/feature/test-bionic.c
new file mode 100644
index 000000000000..eac24e9513eb
--- /dev/null
+++ b/tools/build/feature/test-bionic.c
@@ -0,0 +1,6 @@
+#include <android/api-level.h>
+
+int main(void)
+{
+	return __ANDROID_API__;
+}
diff --git a/tools/build/feature/test-compile.c b/tools/build/feature/test-compile.c
new file mode 100644
index 000000000000..31dbf45bf99c
--- /dev/null
+++ b/tools/build/feature/test-compile.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+	return 0;
+}
diff --git a/tools/build/feature/test-cplus-demangle.c b/tools/build/feature/test-cplus-demangle.c
new file mode 100644
index 000000000000..610c686e0009
--- /dev/null
+++ b/tools/build/feature/test-cplus-demangle.c
@@ -0,0 +1,14 @@
+extern int printf(const char *format, ...);
+extern char *cplus_demangle(const char *, int);
+
+int main(void)
+{
+	char symbol[4096] = "FieldName__9ClassNameFd";
+	char *tmp;
+
+	tmp = cplus_demangle(symbol, 0);
+
+	printf("demangled symbol: {%s}\n", tmp);
+
+	return 0;
+}
diff --git a/tools/build/feature/test-dwarf.c b/tools/build/feature/test-dwarf.c
new file mode 100644
index 000000000000..3fc1801ce4a9
--- /dev/null
+++ b/tools/build/feature/test-dwarf.c
@@ -0,0 +1,10 @@
+#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;
+}
diff --git a/tools/build/feature/test-fortify-source.c b/tools/build/feature/test-fortify-source.c
new file mode 100644
index 000000000000..c9f398d87868
--- /dev/null
+++ b/tools/build/feature/test-fortify-source.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+	return puts("hi");
+}
diff --git a/tools/build/feature/test-glibc.c b/tools/build/feature/test-glibc.c
new file mode 100644
index 000000000000..b0820345cd98
--- /dev/null
+++ b/tools/build/feature/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;
+}
diff --git a/tools/build/feature/test-gtk2-infobar.c b/tools/build/feature/test-gtk2-infobar.c
new file mode 100644
index 000000000000..397b4646d066
--- /dev/null
+++ b/tools/build/feature/test-gtk2-infobar.c
@@ -0,0 +1,11 @@
+#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);
+	gtk_info_bar_new();
+
+	return 0;
+}
diff --git a/tools/build/feature/test-gtk2.c b/tools/build/feature/test-gtk2.c
new file mode 100644
index 000000000000..6bd80e509439
--- /dev/null
+++ b/tools/build/feature/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;
+}
diff --git a/tools/build/feature/test-hello.c b/tools/build/feature/test-hello.c
new file mode 100644
index 000000000000..c9f398d87868
--- /dev/null
+++ b/tools/build/feature/test-hello.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+	return puts("hi");
+}
diff --git a/tools/build/feature/test-libaudit.c b/tools/build/feature/test-libaudit.c
new file mode 100644
index 000000000000..afc019f08641
--- /dev/null
+++ b/tools/build/feature/test-libaudit.c
@@ -0,0 +1,10 @@
+#include <libaudit.h>
+
+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/build/feature/test-libbabeltrace.c b/tools/build/feature/test-libbabeltrace.c
new file mode 100644
index 000000000000..3b7dd68a4d52
--- /dev/null
+++ b/tools/build/feature/test-libbabeltrace.c
@@ -0,0 +1,8 @@
+
+#include <babeltrace/ctf-writer/writer.h>
+
+int main(void)
+{
+	bt_ctf_stream_class_get_packet_context_type((void *) 0);
+	return 0;
+}
diff --git a/tools/build/feature/test-libbfd.c b/tools/build/feature/test-libbfd.c
new file mode 100644
index 000000000000..24059907e990
--- /dev/null
+++ b/tools/build/feature/test-libbfd.c
@@ -0,0 +1,15 @@
+#include <bfd.h>
+
+extern int printf(const char *format, ...);
+
+int main(void)
+{
+	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/build/feature/test-libdw-dwarf-unwind.c b/tools/build/feature/test-libdw-dwarf-unwind.c
new file mode 100644
index 000000000000..f676a3ff442a
--- /dev/null
+++ b/tools/build/feature/test-libdw-dwarf-unwind.c
@@ -0,0 +1,13 @@
+
+#include <elfutils/libdwfl.h>
+
+int main(void)
+{
+	/*
+	 * This function is guarded via: __nonnull_attribute__ (1, 2).
+	 * Passing '1' as arguments value. This code is never executed,
+	 * only compiled.
+	 */
+	dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
+	return 0;
+}
diff --git a/tools/build/feature/test-libelf-getphdrnum.c b/tools/build/feature/test-libelf-getphdrnum.c
new file mode 100644
index 000000000000..d710459306c3
--- /dev/null
+++ b/tools/build/feature/test-libelf-getphdrnum.c
@@ -0,0 +1,8 @@
+#include <libelf.h>
+
+int main(void)
+{
+	size_t dst;
+
+	return elf_getphdrnum(0, &dst);
+}
diff --git a/tools/build/feature/test-libelf-mmap.c b/tools/build/feature/test-libelf-mmap.c
new file mode 100644
index 000000000000..564427d7ef18
--- /dev/null
+++ b/tools/build/feature/test-libelf-mmap.c
@@ -0,0 +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/build/feature/test-libelf.c b/tools/build/feature/test-libelf.c
new file mode 100644
index 000000000000..08db322d8957
--- /dev/null
+++ b/tools/build/feature/test-libelf.c
@@ -0,0 +1,8 @@
+#include <libelf.h>
+
+int main(void)
+{
+	Elf *elf = elf_begin(0, ELF_C_READ, 0);
+
+	return (long)elf;
+}
diff --git a/tools/build/feature/test-libnuma.c b/tools/build/feature/test-libnuma.c
new file mode 100644
index 000000000000..4763d9cd587d
--- /dev/null
+++ b/tools/build/feature/test-libnuma.c
@@ -0,0 +1,9 @@
+#include <numa.h>
+#include <numaif.h>
+
+int main(void)
+{
+	numa_available();
+
+	return 0;
+}
diff --git a/tools/build/feature/test-libperl.c b/tools/build/feature/test-libperl.c
new file mode 100644
index 000000000000..8871f6a0fdb4
--- /dev/null
+++ b/tools/build/feature/test-libperl.c
@@ -0,0 +1,9 @@
+#include <EXTERN.h>
+#include <perl.h>
+
+int main(void)
+{
+	perl_alloc();
+
+	return 0;
+}
diff --git a/tools/build/feature/test-libpython-version.c b/tools/build/feature/test-libpython-version.c
new file mode 100644
index 000000000000..facea122d812
--- /dev/null
+++ b/tools/build/feature/test-libpython-version.c
@@ -0,0 +1,10 @@
+#include <Python.h>
+
+#if PY_VERSION_HEX >= 0x03000000
+	#error
+#endif
+
+int main(void)
+{
+	return 0;
+}
diff --git a/tools/build/feature/test-libpython.c b/tools/build/feature/test-libpython.c
new file mode 100644
index 000000000000..b24b28ad6324
--- /dev/null
+++ b/tools/build/feature/test-libpython.c
@@ -0,0 +1,8 @@
+#include <Python.h>
+
+int main(void)
+{
+	Py_Initialize();
+
+	return 0;
+}
diff --git a/tools/build/feature/test-libslang.c b/tools/build/feature/test-libslang.c
new file mode 100644
index 000000000000..22ff22ed94d1
--- /dev/null
+++ b/tools/build/feature/test-libslang.c
@@ -0,0 +1,6 @@
+#include <slang.h>
+
+int main(void)
+{
+	return SLsmg_init_smg();
+}
diff --git a/tools/build/feature/test-libunwind-debug-frame.c b/tools/build/feature/test-libunwind-debug-frame.c
new file mode 100644
index 000000000000..0ef8087a104a
--- /dev/null
+++ b/tools/build/feature/test-libunwind-debug-frame.c
@@ -0,0 +1,16 @@
+#include <libunwind.h>
+#include <stdlib.h>
+
+extern int
+UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
+				 unw_word_t ip, unw_word_t segbase,
+				 const char *obj_name, unw_word_t start,
+				 unw_word_t end);
+
+#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
+
+int main(void)
+{
+	dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
+	return 0;
+}
diff --git a/tools/build/feature/test-libunwind.c b/tools/build/feature/test-libunwind.c
new file mode 100644
index 000000000000..43b9369bcab7
--- /dev/null
+++ b/tools/build/feature/test-libunwind.c
@@ -0,0 +1,27 @@
+#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)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+	unw_addr_space_t addr_space;
+
+	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/build/feature/test-pthread-attr-setaffinity-np.c b/tools/build/feature/test-pthread-attr-setaffinity-np.c
new file mode 100644
index 000000000000..fdada5e8d454
--- /dev/null
+++ b/tools/build/feature/test-pthread-attr-setaffinity-np.c
@@ -0,0 +1,17 @@
+#include <stdint.h>
+#include <pthread.h>
+#include <sched.h>
+
+int main(void)
+{
+	int ret = 0;
+	pthread_attr_t thread_attr;
+	cpu_set_t cs;
+
+	pthread_attr_init(&thread_attr);
+	CPU_ZERO(&cs);
+
+	ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
+
+	return ret;
+}
diff --git a/tools/build/feature/test-stackprotector-all.c b/tools/build/feature/test-stackprotector-all.c
new file mode 100644
index 000000000000..c9f398d87868
--- /dev/null
+++ b/tools/build/feature/test-stackprotector-all.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+	return puts("hi");
+}
diff --git a/tools/build/feature/test-sync-compare-and-swap.c b/tools/build/feature/test-sync-compare-and-swap.c
new file mode 100644
index 000000000000..c34d4ca4af56
--- /dev/null
+++ b/tools/build/feature/test-sync-compare-and-swap.c
@@ -0,0 +1,14 @@
+#include <stdint.h>
+
+volatile uint64_t x;
+
+int main(int argc, char *argv[])
+{
+	uint64_t old, new = argc;
+
+	argv = argv;
+	do {
+		old = __sync_val_compare_and_swap(&x, 0, 0);
+	} while (!__sync_bool_compare_and_swap(&x, old, new));
+	return old == new;
+}
diff --git a/tools/build/feature/test-timerfd.c b/tools/build/feature/test-timerfd.c
new file mode 100644
index 000000000000..8c5c083b4d3c
--- /dev/null
+++ b/tools/build/feature/test-timerfd.c
@@ -0,0 +1,18 @@
+/*
+ * test for timerfd functions used by perf-kvm-stat-live
+ */
+#include <sys/timerfd.h>
+
+int main(void)
+{
+	struct itimerspec new_value;
+
+	int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
+	if (fd < 0)
+		return 1;
+
+	if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
+		return 1;
+
+	return 0;
+}
diff --git a/tools/build/feature/test-zlib.c b/tools/build/feature/test-zlib.c
new file mode 100644
index 000000000000..e111fff6240e
--- /dev/null
+++ b/tools/build/feature/test-zlib.c
@@ -0,0 +1,9 @@
+#include <zlib.h>
+
+int main(void)
+{
+	z_stream zs;
+
+	inflateInit(&zs);
+	return 0;
+}
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index e323eab10694..d5b9e0dae334 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -521,7 +521,7 @@ $(INSTALL_DOC_TARGETS):
 #
 config-clean:
 	$(call QUIET_CLEAN, config)
-	$(Q)$(MAKE) -C config/feature-checks clean >/dev/null
+	$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
 
 clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean
 	$(call QUIET_CLEAN, core-objs)  $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 01d8acc5453e..df666a596c2a 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -176,7 +176,7 @@ LDFLAGS += -Wl,-z,noexecstack
 
 EXTLIBS = -lpthread -lrt -lm -ldl
 
-include $(src-perf)/config/Makefile.feature
+include $(srctree)/tools/build/Makefile.feature
 
 ifeq ($(feature-stackprotector-all), 1)
   CFLAGS += -fstack-protector-all
diff --git a/tools/perf/config/Makefile.feature b/tools/perf/config/Makefile.feature
deleted file mode 100644
index 55b671a93d67..000000000000
--- a/tools/perf/config/Makefile.feature
+++ /dev/null
@@ -1,171 +0,0 @@
-feature_dir := $(srctree)/tools/perf/config/feature-checks
-
-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) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/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:
-#
-
-#
-# 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. ]
-#
-FEATURE_TESTS =			\
-	backtrace			\
-	dwarf				\
-	fortify-source			\
-	sync-compare-and-swap		\
-	glibc				\
-	gtk2				\
-	gtk2-infobar			\
-	libaudit			\
-	libbfd				\
-	libelf				\
-	libelf-getphdrnum		\
-	libelf-mmap			\
-	libnuma				\
-	libperl				\
-	libpython			\
-	libpython-version		\
-	libslang			\
-	libunwind			\
-	pthread-attr-setaffinity-np	\
-	stackprotector-all		\
-	timerfd				\
-	libdw-dwarf-unwind		\
-	libbabeltrace			\
-	zlib
-
-FEATURE_DISPLAY =			\
-	dwarf				\
-	glibc				\
-	gtk2				\
-	libaudit			\
-	libbfd				\
-	libelf				\
-	libnuma				\
-	libperl				\
-	libpython			\
-	libslang			\
-	libunwind			\
-	libdw-dwarf-unwind		\
-	libbabeltrace			\
-	zlib
-
-# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
-# If in the future we need per-feature checks/flags for features not
-# mentioned in this list we need to refactor this ;-).
-set_test_all_flags = $(eval $(set_test_all_flags_code))
-define set_test_all_flags_code
-  FEATURE_CHECK_CFLAGS-all  += $(FEATURE_CHECK_CFLAGS-$(1))
-  FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
-endef
-
-$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
-
-#
-# Special fast-path for the 'all features are available' case:
-#
-$(call feature_check,all,$(MSG))
-
-#
-# Just in case the build freshly failed, make sure we print the
-# feature matrix:
-#
-ifeq ($(feature-all), 1)
-  #
-  # test-all.c passed - just set all the core feature flags to 1:
-  #
-  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
-else
-  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C $(feature_dir) $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
-  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
-endif
-
-#
-# Print the result of the feature test:
-#
-feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
-
-define feature_print_status_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
-endef
-
-feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
-define feature_print_text_code
-    MSG = $(shell printf '...%30s: %s' $(1) $(2))
-endef
-
-FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
-FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
-
-ifeq ($(dwarf-post-unwind),1)
-  FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
-endif
-
-# The $(feature_display) controls the default detection message
-# output. It's set if:
-# - detected features differes from stored features from
-#   last build (in FEATURE-DUMP file)
-# - one of the $(FEATURE_DISPLAY) is not detected
-# - VF is enabled
-
-ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
-  $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
-  feature_display := 1
-endif
-
-feature_check = $(eval $(feature_check_code))
-define feature_check_code
-  ifneq ($(feature-$(1)), 1)
-    feature_display := 1
-  endif
-endef
-
-$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
-
-ifeq ($(VF),1)
-  feature_display := 1
-  feature_verbose := 1
-endif
-
-ifeq ($(feature_display),1)
-  $(info )
-  $(info Auto-detecting system features:)
-  $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
-
-  ifeq ($(dwarf-post-unwind),1)
-    $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
-  endif
-
-  ifneq ($(feature_verbose),1)
-    $(info )
-  endif
-endif
-
-ifeq ($(feature_verbose),1)
-  TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
-  $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
-  $(info )
-endif
diff --git a/tools/perf/config/feature-checks/.gitignore b/tools/perf/config/feature-checks/.gitignore
deleted file mode 100644
index 80f3da0c3515..000000000000
--- a/tools/perf/config/feature-checks/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*.d
-*.bin
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
deleted file mode 100644
index 8fe067864957..000000000000
--- a/tools/perf/config/feature-checks/Makefile
+++ /dev/null
@@ -1,159 +0,0 @@
-
-FILES=					\
-	test-all.bin			\
-	test-backtrace.bin		\
-	test-bionic.bin			\
-	test-dwarf.bin			\
-	test-fortify-source.bin		\
-	test-sync-compare-and-swap.bin	\
-	test-glibc.bin			\
-	test-gtk2.bin			\
-	test-gtk2-infobar.bin		\
-	test-hello.bin			\
-	test-libaudit.bin		\
-	test-libbfd.bin			\
-	test-liberty.bin		\
-	test-liberty-z.bin		\
-	test-cplus-demangle.bin		\
-	test-libelf.bin			\
-	test-libelf-getphdrnum.bin	\
-	test-libelf-mmap.bin		\
-	test-libnuma.bin		\
-	test-libperl.bin		\
-	test-libpython.bin		\
-	test-libpython-version.bin	\
-	test-libslang.bin		\
-	test-libunwind.bin		\
-	test-libunwind-debug-frame.bin	\
-	test-pthread-attr-setaffinity-np.bin	\
-	test-stackprotector-all.bin	\
-	test-timerfd.bin		\
-	test-libdw-dwarf-unwind.bin	\
-	test-libbabeltrace.bin		\
-	test-compile-32.bin		\
-	test-compile-x32.bin		\
-	test-zlib.bin
-
-CC := $(CROSS_COMPILE)gcc -MD
-PKG_CONFIG := $(CROSS_COMPILE)pkg-config
-
-all: $(FILES)
-
-BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
-
-###############################
-
-test-all.bin:
-	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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 -lz -lbabeltrace
-
-test-hello.bin:
-	$(BUILD)
-
-test-pthread-attr-setaffinity-np.bin:
-	$(BUILD) -D_GNU_SOURCE -lpthread
-
-test-stackprotector-all.bin:
-	$(BUILD) -fstack-protector-all
-
-test-fortify-source.bin:
-	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
-
-test-bionic.bin:
-	$(BUILD)
-
-test-libelf.bin:
-	$(BUILD) -lelf
-
-test-glibc.bin:
-	$(BUILD)
-
-test-dwarf.bin:
-	$(BUILD) -ldw
-
-test-libelf-mmap.bin:
-	$(BUILD) -lelf
-
-test-libelf-getphdrnum.bin:
-	$(BUILD) -lelf
-
-test-libnuma.bin:
-	$(BUILD) -lnuma
-
-test-libunwind.bin:
-	$(BUILD) -lelf
-
-test-libunwind-debug-frame.bin:
-	$(BUILD) -lelf
-
-test-libaudit.bin:
-	$(BUILD) -laudit
-
-test-libslang.bin:
-	$(BUILD) -I/usr/include/slang -lslang
-
-test-gtk2.bin:
-	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
-
-test-gtk2-infobar.bin:
-	$(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.bin:
-	$(BUILD) $(FLAGS_PERL_EMBED)
-
-test-libpython.bin:
-	$(BUILD)
-
-test-libpython-version.bin:
-	$(BUILD)
-
-test-libbfd.bin:
-	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
-
-test-liberty.bin:
-	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
-
-test-liberty-z.bin:
-	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
-
-test-cplus-demangle.bin:
-	$(BUILD) -liberty
-
-test-backtrace.bin:
-	$(BUILD)
-
-test-timerfd.bin:
-	$(BUILD)
-
-test-libdw-dwarf-unwind.bin:
-	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
-
-test-libbabeltrace.bin:
-	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
-
-test-sync-compare-and-swap.bin:
-	$(BUILD)
-
-test-compile-32.bin:
-	$(CC) -m32 -o $(OUTPUT)$@ test-compile.c
-
-test-compile-x32.bin:
-	$(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
-
-test-zlib.bin:
-	$(BUILD) -lz
-
--include *.d
-
-###############################
-
-clean:
-	rm -f $(FILES) *.d
diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
deleted file mode 100644
index 1ffc3da5ca10..000000000000
--- a/tools/perf/config/feature-checks/test-all.c
+++ /dev/null
@@ -1,136 +0,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_backtrace
-# include "test-backtrace.c"
-#undef main
-
-#define main main_test_libnuma
-# include "test-libnuma.c"
-#undef main
-
-#define main main_test_timerfd
-# include "test-timerfd.c"
-#undef main
-
-#define main main_test_stackprotector_all
-# include "test-stackprotector-all.c"
-#undef main
-
-#define main main_test_libdw_dwarf_unwind
-# include "test-libdw-dwarf-unwind.c"
-#undef main
-
-#define main main_test_sync_compare_and_swap
-# include "test-sync-compare-and-swap.c"
-#undef main
-
-#define main main_test_zlib
-# include "test-zlib.c"
-#undef main
-
-#define main main_test_pthread_attr_setaffinity_np
-# include "test-pthread_attr_setaffinity_np.c"
-#undef main
-
-#define main main_test_libbabeltrace
-# include "test-libbabeltrace.c"
-#undef main
-
-int main(int argc, char *argv[])
-{
-	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_backtrace();
-	main_test_libnuma();
-	main_test_timerfd();
-	main_test_stackprotector_all();
-	main_test_libdw_dwarf_unwind();
-	main_test_sync_compare_and_swap(argc, argv);
-	main_test_zlib();
-	main_test_pthread_attr_setaffinity_np();
-	main_test_libbabeltrace();
-
-	return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-backtrace.c b/tools/perf/config/feature-checks/test-backtrace.c
deleted file mode 100644
index 7124aa1dc8fb..000000000000
--- a/tools/perf/config/feature-checks/test-backtrace.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <execinfo.h>
-#include <stdio.h>
-
-int main(void)
-{
-	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-bionic.c b/tools/perf/config/feature-checks/test-bionic.c
deleted file mode 100644
index eac24e9513eb..000000000000
--- a/tools/perf/config/feature-checks/test-bionic.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <android/api-level.h>
-
-int main(void)
-{
-	return __ANDROID_API__;
-}
diff --git a/tools/perf/config/feature-checks/test-compile.c b/tools/perf/config/feature-checks/test-compile.c
deleted file mode 100644
index 31dbf45bf99c..000000000000
--- a/tools/perf/config/feature-checks/test-compile.c
+++ /dev/null
@@ -1,4 +0,0 @@
-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
deleted file mode 100644
index 610c686e0009..000000000000
--- a/tools/perf/config/feature-checks/test-cplus-demangle.c
+++ /dev/null
@@ -1,14 +0,0 @@
-extern int printf(const char *format, ...);
-extern char *cplus_demangle(const char *, int);
-
-int main(void)
-{
-	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-dwarf.c b/tools/perf/config/feature-checks/test-dwarf.c
deleted file mode 100644
index 3fc1801ce4a9..000000000000
--- a/tools/perf/config/feature-checks/test-dwarf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#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;
-}
diff --git a/tools/perf/config/feature-checks/test-fortify-source.c b/tools/perf/config/feature-checks/test-fortify-source.c
deleted file mode 100644
index c9f398d87868..000000000000
--- a/tools/perf/config/feature-checks/test-fortify-source.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
-	return puts("hi");
-}
diff --git a/tools/perf/config/feature-checks/test-glibc.c b/tools/perf/config/feature-checks/test-glibc.c
deleted file mode 100644
index b0820345cd98..000000000000
--- a/tools/perf/config/feature-checks/test-glibc.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <gnu/libc-version.h>
-
-int main(void)
-{
-	const char *version = gnu_get_libc_version();
-
-	return (long)version;
-}
diff --git a/tools/perf/config/feature-checks/test-gtk2-infobar.c b/tools/perf/config/feature-checks/test-gtk2-infobar.c
deleted file mode 100644
index 397b4646d066..000000000000
--- a/tools/perf/config/feature-checks/test-gtk2-infobar.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#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);
-	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
deleted file mode 100644
index 6bd80e509439..000000000000
--- a/tools/perf/config/feature-checks/test-gtk2.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#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;
-}
diff --git a/tools/perf/config/feature-checks/test-hello.c b/tools/perf/config/feature-checks/test-hello.c
deleted file mode 100644
index c9f398d87868..000000000000
--- a/tools/perf/config/feature-checks/test-hello.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
-	return puts("hi");
-}
diff --git a/tools/perf/config/feature-checks/test-libaudit.c b/tools/perf/config/feature-checks/test-libaudit.c
deleted file mode 100644
index afc019f08641..000000000000
--- a/tools/perf/config/feature-checks/test-libaudit.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <libaudit.h>
-
-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-libbabeltrace.c b/tools/perf/config/feature-checks/test-libbabeltrace.c
deleted file mode 100644
index 3b7dd68a4d52..000000000000
--- a/tools/perf/config/feature-checks/test-libbabeltrace.c
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#include <babeltrace/ctf-writer/writer.h>
-
-int main(void)
-{
-	bt_ctf_stream_class_get_packet_context_type((void *) 0);
-	return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libbfd.c b/tools/perf/config/feature-checks/test-libbfd.c
deleted file mode 100644
index 24059907e990..000000000000
--- a/tools/perf/config/feature-checks/test-libbfd.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <bfd.h>
-
-extern int printf(const char *format, ...);
-
-int main(void)
-{
-	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-libdw-dwarf-unwind.c b/tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
deleted file mode 100644
index f676a3ff442a..000000000000
--- a/tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
+++ /dev/null
@@ -1,13 +0,0 @@
-
-#include <elfutils/libdwfl.h>
-
-int main(void)
-{
-	/*
-	 * This function is guarded via: __nonnull_attribute__ (1, 2).
-	 * Passing '1' as arguments value. This code is never executed,
-	 * only compiled.
-	 */
-	dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
-	return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libelf-getphdrnum.c b/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
deleted file mode 100644
index d710459306c3..000000000000
--- a/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#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
deleted file mode 100644
index 564427d7ef18..000000000000
--- a/tools/perf/config/feature-checks/test-libelf-mmap.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#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
deleted file mode 100644
index 08db322d8957..000000000000
--- a/tools/perf/config/feature-checks/test-libelf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <libelf.h>
-
-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
deleted file mode 100644
index 4763d9cd587d..000000000000
--- a/tools/perf/config/feature-checks/test-libnuma.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <numa.h>
-#include <numaif.h>
-
-int main(void)
-{
-	numa_available();
-
-	return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libperl.c b/tools/perf/config/feature-checks/test-libperl.c
deleted file mode 100644
index 8871f6a0fdb4..000000000000
--- a/tools/perf/config/feature-checks/test-libperl.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <EXTERN.h>
-#include <perl.h>
-
-int main(void)
-{
-	perl_alloc();
-
-	return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libpython-version.c b/tools/perf/config/feature-checks/test-libpython-version.c
deleted file mode 100644
index facea122d812..000000000000
--- a/tools/perf/config/feature-checks/test-libpython-version.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <Python.h>
-
-#if PY_VERSION_HEX >= 0x03000000
-	#error
-#endif
-
-int main(void)
-{
-	return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libpython.c b/tools/perf/config/feature-checks/test-libpython.c
deleted file mode 100644
index b24b28ad6324..000000000000
--- a/tools/perf/config/feature-checks/test-libpython.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <Python.h>
-
-int main(void)
-{
-	Py_Initialize();
-
-	return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libslang.c b/tools/perf/config/feature-checks/test-libslang.c
deleted file mode 100644
index 22ff22ed94d1..000000000000
--- a/tools/perf/config/feature-checks/test-libslang.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <slang.h>
-
-int main(void)
-{
-	return SLsmg_init_smg();
-}
diff --git a/tools/perf/config/feature-checks/test-libunwind-debug-frame.c b/tools/perf/config/feature-checks/test-libunwind-debug-frame.c
deleted file mode 100644
index 0ef8087a104a..000000000000
--- a/tools/perf/config/feature-checks/test-libunwind-debug-frame.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <libunwind.h>
-#include <stdlib.h>
-
-extern int
-UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
-				 unw_word_t ip, unw_word_t segbase,
-				 const char *obj_name, unw_word_t start,
-				 unw_word_t end);
-
-#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
-
-int main(void)
-{
-	dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
-	return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libunwind.c b/tools/perf/config/feature-checks/test-libunwind.c
deleted file mode 100644
index 43b9369bcab7..000000000000
--- a/tools/perf/config/feature-checks/test-libunwind.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#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)
-
-static unw_accessors_t accessors;
-
-int main(void)
-{
-	unw_addr_space_t addr_space;
-
-	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-pthread-attr-setaffinity-np.c b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
deleted file mode 100644
index fdada5e8d454..000000000000
--- a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <stdint.h>
-#include <pthread.h>
-#include <sched.h>
-
-int main(void)
-{
-	int ret = 0;
-	pthread_attr_t thread_attr;
-	cpu_set_t cs;
-
-	pthread_attr_init(&thread_attr);
-	CPU_ZERO(&cs);
-
-	ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
-
-	return ret;
-}
diff --git a/tools/perf/config/feature-checks/test-stackprotector-all.c b/tools/perf/config/feature-checks/test-stackprotector-all.c
deleted file mode 100644
index c9f398d87868..000000000000
--- a/tools/perf/config/feature-checks/test-stackprotector-all.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
-	return puts("hi");
-}
diff --git a/tools/perf/config/feature-checks/test-sync-compare-and-swap.c b/tools/perf/config/feature-checks/test-sync-compare-and-swap.c
deleted file mode 100644
index c34d4ca4af56..000000000000
--- a/tools/perf/config/feature-checks/test-sync-compare-and-swap.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <stdint.h>
-
-volatile uint64_t x;
-
-int main(int argc, char *argv[])
-{
-	uint64_t old, new = argc;
-
-	argv = argv;
-	do {
-		old = __sync_val_compare_and_swap(&x, 0, 0);
-	} while (!__sync_bool_compare_and_swap(&x, old, new));
-	return old == new;
-}
diff --git a/tools/perf/config/feature-checks/test-timerfd.c b/tools/perf/config/feature-checks/test-timerfd.c
deleted file mode 100644
index 8c5c083b4d3c..000000000000
--- a/tools/perf/config/feature-checks/test-timerfd.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * test for timerfd functions used by perf-kvm-stat-live
- */
-#include <sys/timerfd.h>
-
-int main(void)
-{
-	struct itimerspec new_value;
-
-	int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
-	if (fd < 0)
-		return 1;
-
-	if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
-		return 1;
-
-	return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-zlib.c b/tools/perf/config/feature-checks/test-zlib.c
deleted file mode 100644
index e111fff6240e..000000000000
--- a/tools/perf/config/feature-checks/test-zlib.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <zlib.h>
-
-int main(void)
-{
-	z_stream zs;
-
-	inflateInit(&zs);
-	return 0;
-}
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 12/14] tools build: Allow to override feature checks setup
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (10 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 11/14] tools build: Move feature checks code under tools/build Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 17:49   ` David Ahern
  2015-03-04 12:23   ` Namhyung Kim
  2015-03-03 14:26 ` [PATCH 13/14] tools build: Fix feature_check name clash Jiri Olsa
                   ` (2 subsequent siblings)
  14 siblings, 2 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Allowing to override configuration variables for feature
checks. Also adding automated test and documentation.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/build/Documentation/Feature.txt     | 93 +++++++++++++++++++++++++++++++
 tools/build/Makefile.feature              |  4 +-
 tools/build/tests/features/Makefile       | 23 ++++++++
 tools/build/tests/features/Makefile.test1 | 16 ++++++
 tools/build/tests/run.sh                  |  4 +-
 5 files changed, 137 insertions(+), 3 deletions(-)
 create mode 100644 tools/build/Documentation/Feature.txt
 create mode 100644 tools/build/tests/features/Makefile
 create mode 100644 tools/build/tests/features/Makefile.test1

diff --git a/tools/build/Documentation/Feature.txt b/tools/build/Documentation/Feature.txt
new file mode 100644
index 000000000000..0c75419ba803
--- /dev/null
+++ b/tools/build/Documentation/Feature.txt
@@ -0,0 +1,93 @@
+Feature Framework
+=================
+The 'feature' framework provides information for makefiles about
+installed libraries and interfaces in the system.
+
+The 'feature' is represented by its name and simple source located
+in 'tools/build/feature/test-$(name).c' file. The framework builds
+each such source for configured feature and sets $(feature-$(name))
+variable to 0 or 1 if it fails or succeeds to build respectively.
+
+The current usage example of the feature framework is:
+
+--- Makefile.test
+  FEATURE_TESTS   := glibc backtrace
+  FEATURE_DISPLAY := glibc
+
+  srctree := ../../../..
+  include $(srctree)/tools/build/Makefile.feature
+
+  ifndef feature-glibc
+    $(error FAILED feature-glibc variable not defined)
+  endif
+
+  ifndef feature-backtrace
+    $(error FAILED feature-backtrace variable not defined)
+  endif
+---
+
+User defines list of features to check in FEATURE_TESTS variable:
+
+  FEATURE_TESTS   := glibc backtrace
+
+and list of features she wishes to display in FEATURE_DISPLAY variable:
+
+  FEATURE_DISPLAY := glibc
+
+then user includes Makefile.feature makefile:
+
+  include $(srctree)/tools/build/Makefile.feature
+
+following output is displayed on processing of the makefile:
+
+  $ make -f Makefile.test
+
+  Auto-detecting system features:
+  ...                         glibc: [ on  ]
+
+Plus following variables are defined indicating the
+requested feature status:
+
+  $(feature-glibc)
+  $(feature-backtrace)
+
+Following features are currently available for FEATURE_TESTS:
+
+      backtrace
+      dwarf
+      fortify-source
+      sync-compare-and-swap
+      glibc
+      gtk2
+      gtk2-infobar
+      libaudit
+      libbfd
+      libelf
+      libelf-getphdrnum
+      libelf-mmap
+      libnuma
+      libperl
+      libpython
+      libpython-version
+      libslang
+      libunwind
+      pthread-attr-setaffinity-np
+      stackprotector-all
+      timerfd
+      libdw-dwarf-unwind
+      libbabeltrace
+      zlib
+
+It's also possible to pass options for checks compilation and linking
+by using following variables:
+
+  FEATURE_CHECK_CFLAGS-$(name)
+  FEATURE_CHECK_LDFLAGS-$(name)
+
+where $(anem) represents feature name from above list.
+
+For example following settings will provide options for 'libunwind'
+feature compilation and linking:
+
+    FEATURE_CHECK_CFLAGS-libunwind  = $(LIBUNWIND_CFLAGS)
+    FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 3249fad27993..5b712ed7e4c7 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -27,7 +27,7 @@ endef
 #   the rule that uses them - an example for that is the 'bionic'
 #   feature check. ]
 #
-FEATURE_TESTS =			\
+FEATURE_TESTS ?=			\
 	backtrace			\
 	dwarf				\
 	fortify-source			\
@@ -53,7 +53,7 @@ FEATURE_TESTS =			\
 	libbabeltrace			\
 	zlib
 
-FEATURE_DISPLAY =			\
+FEATURE_DISPLAY ?=			\
 	dwarf				\
 	glibc				\
 	gtk2				\
diff --git a/tools/build/tests/features/Makefile b/tools/build/tests/features/Makefile
new file mode 100644
index 000000000000..31782a1d3758
--- /dev/null
+++ b/tools/build/tests/features/Makefile
@@ -0,0 +1,23 @@
+all: test1
+
+test1:
+	rm -f FEATURE-DUMP
+	make -f Makefile.test1 > out
+	# we should get one line with 'glibc' feature status
+	features=`cat out | grep '\.\.\.' | wc -l`; \
+	if [ "$$features" != "1" ]; then echo FAILED; exit 1; fi
+	# we should NOT get any feature status line on second run
+	make -f Makefile.test1 > out
+	features=`cat out | grep '\.\.\.' | wc -l`; \
+	if [ "$$features" == "1" ]; then echo FAILED; exit 1; fi
+	# we should get both 'glibc' and 'backtrace' status lines now
+	make -f Makefile.test1 VF=1 > out
+	features=`cat out | grep '\.\.\.' | wc -l`; \
+	if [ "$$features" != "2" ]; then echo FAILED; exit 1; fi
+	# and fresh start without FEATURE-DUMP, expecting 'glibc' status line
+	rm -f FEATURE-DUMP
+	make -f Makefile.test1 > out
+	features=`cat out | grep '\.\.\.' | wc -l`; \
+	if [ "$$features" != "1" ]; then echo FAILED; exit 1; fi
+	# cleanup
+	rm -f FEATURE-DUMP out
diff --git a/tools/build/tests/features/Makefile.test1 b/tools/build/tests/features/Makefile.test1
new file mode 100644
index 000000000000..101b78f777c1
--- /dev/null
+++ b/tools/build/tests/features/Makefile.test1
@@ -0,0 +1,16 @@
+
+FEATURE_TESTS   := glibc backtrace
+FEATURE_DISPLAY := glibc
+
+srctree := ../../../..
+include $(srctree)/tools/build/Makefile.feature
+
+ifndef feature-glibc
+  $(error FAILED feature-glibc variable not defined)
+endif
+
+ifndef feature-backtrace
+  $(error FAILED feature-backtrace variable not defined)
+endif
+
+all:
diff --git a/tools/build/tests/run.sh b/tools/build/tests/run.sh
index 5494f8ea7567..bd6dc8ee1830 100755
--- a/tools/build/tests/run.sh
+++ b/tools/build/tests/run.sh
@@ -39,4 +39,6 @@ echo -n Testing..
 test_ex
 test_ex_suffix
 
-echo OK
+cd features && make -s -f Makefile
+
+if [ $? -eq 0 ]; then echo OK; fi
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 13/14] tools build: Fix feature_check name clash
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (11 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 12/14] tools build: Allow to override feature checks setup Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-03 14:26 ` [PATCH 14/14] tools build: Disable default check for libbabeltrace Jiri Olsa
  2015-03-04  4:41 ` [PATCH 00/14] tools build: Move features framework into tools/build Ingo Molnar
  14 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

We have 2 feature_check functions, which conflict with each other.
Fixing it by renaming the latter to feature_display_check.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/build/Makefile.feature | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 5b712ed7e4c7..7b587178efea 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -136,14 +136,14 @@ ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
   feature_display := 1
 endif
 
-feature_check = $(eval $(feature_check_code))
-define feature_check_code
+feature_display_check = $(eval $(feature_check_code))
+define feature_display_check_code
   ifneq ($(feature-$(1)), 1)
     feature_display := 1
   endif
 endef
 
-$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
+$(foreach feat,$(FEATURE_DISPLAY),$(call feature_display_check,$(feat)))
 
 ifeq ($(VF),1)
   feature_display := 1
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 14/14] tools build: Disable default check for libbabeltrace
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (12 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 13/14] tools build: Fix feature_check name clash Jiri Olsa
@ 2015-03-03 14:26 ` Jiri Olsa
  2015-03-04 10:40   ` [PATCHv2 " Jiri Olsa
  2015-03-04  4:41 ` [PATCH 00/14] tools build: Move features framework into tools/build Ingo Molnar
  14 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 14:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Remove libbabeltrace check from default features set, because the
requested version is not released yet in most distributions. We'll
enable later.

Calling libbabeltrace check manually via feature_check
before $(feature-libbabeltrace) is used.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/build/Makefile.feature   | 2 --
 tools/build/feature/Makefile   | 2 +-
 tools/build/feature/test-all.c | 8 ++++++++
 tools/perf/config/Makefile     | 9 +++++----
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 7b587178efea..12e58703a364 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -50,7 +50,6 @@ FEATURE_TESTS ?=			\
 	stackprotector-all		\
 	timerfd				\
 	libdw-dwarf-unwind		\
-	libbabeltrace			\
 	zlib
 
 FEATURE_DISPLAY ?=			\
@@ -66,7 +65,6 @@ FEATURE_DISPLAY ?=			\
 	libslang			\
 	libunwind			\
 	libdw-dwarf-unwind		\
-	libbabeltrace			\
 	zlib
 
 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 8fe067864957..b6e2e312ba54 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -44,7 +44,7 @@ BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(
 ###############################
 
 test-all.bin:
-	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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 -lz -lbabeltrace
+	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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 -lz
 
 test-hello.bin:
 	$(BUILD)
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 1ffc3da5ca10..0c312280d36b 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -101,9 +101,17 @@
 # include "test-pthread_attr_setaffinity_np.c"
 #undef main
 
+# if 0
+/*
+ * Disable libbabeltrace check for test-all, because the requested
+ * library version is not released yet in most distributions. Will
+ * reenable later.
+ */
+
 #define main main_test_libbabeltrace
 # include "test-libbabeltrace.c"
 #undef main
+#endif
 
 int main(int argc, char *argv[])
 {
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index df666a596c2a..480631eccf50 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -588,14 +588,15 @@ else
 endif
 
 ifndef NO_LIBBABELTRACE
-  ifeq ($(feature-libbabeltrace), 0)
-    msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
-    NO_LIBBABELTRACE := 1
-  else
+  $(call feature_check,libbabeltrace)
+  ifeq ($(feature-libbabeltrace), 1)
     CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
     LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
     EXTLIBS += -lbabeltrace-ctf
     $(call detected,CONFIG_LIBBABELTRACE)
+  else
+    msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
+    NO_LIBBABELTRACE := 1
   endif
 endif
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 11/14] tools build: Move feature checks code under tools/build
  2015-03-03 14:26 ` [PATCH 11/14] tools build: Move feature checks code under tools/build Jiri Olsa
@ 2015-03-03 17:18   ` David Ahern
  2015-03-03 17:34     ` Jiri Olsa
  0 siblings, 1 reply; 25+ messages in thread
From: David Ahern @ 2015-03-03 17:18 UTC (permalink / raw)
  To: Jiri Olsa, linux-kernel
  Cc: Arnaldo Carvalho de Melo, Corey Ashford, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra

On 3/3/15 7:26 AM, Jiri Olsa wrote:
> Moving feature checks code under tools/build directory.

How does a specific tool specify which features are of interest? I can't 
imagine all features for perf are wanted by other tools.

David

>
> Changing also $feature_dir to point to new feature directory
> location and perf Makefiles to include Makefile.feature from
> new location.
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: David Ahern <david.ahern@oracle.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> ---
>   tools/build/Makefile.feature                       | 171 +++++++++++++++++++++
>   tools/build/feature/.gitignore                     |   2 +
>   tools/build/feature/Makefile                       | 159 +++++++++++++++++++
>   tools/build/feature/test-all.c                     | 136 ++++++++++++++++
>   tools/build/feature/test-backtrace.c               |  13 ++
>   tools/build/feature/test-bionic.c                  |   6 +
>   tools/build/feature/test-compile.c                 |   4 +
>   tools/build/feature/test-cplus-demangle.c          |  14 ++
>   tools/build/feature/test-dwarf.c                   |  10 ++
>   tools/build/feature/test-fortify-source.c          |   6 +
>   tools/build/feature/test-glibc.c                   |   8 +
>   tools/build/feature/test-gtk2-infobar.c            |  11 ++
>   tools/build/feature/test-gtk2.c                    |  10 ++
>   tools/build/feature/test-hello.c                   |   6 +
>   tools/build/feature/test-libaudit.c                |  10 ++
>   tools/build/feature/test-libbabeltrace.c           |   8 +
>   tools/build/feature/test-libbfd.c                  |  15 ++
>   tools/build/feature/test-libdw-dwarf-unwind.c      |  13 ++
>   tools/build/feature/test-libelf-getphdrnum.c       |   8 +
>   tools/build/feature/test-libelf-mmap.c             |   8 +
>   tools/build/feature/test-libelf.c                  |   8 +
>   tools/build/feature/test-libnuma.c                 |   9 ++
>   tools/build/feature/test-libperl.c                 |   9 ++
>   tools/build/feature/test-libpython-version.c       |  10 ++
>   tools/build/feature/test-libpython.c               |   8 +
>   tools/build/feature/test-libslang.c                |   6 +
>   tools/build/feature/test-libunwind-debug-frame.c   |  16 ++
>   tools/build/feature/test-libunwind.c               |  27 ++++
>   .../feature/test-pthread-attr-setaffinity-np.c     |  17 ++
>   tools/build/feature/test-stackprotector-all.c      |   6 +
>   tools/build/feature/test-sync-compare-and-swap.c   |  14 ++
>   tools/build/feature/test-timerfd.c                 |  18 +++
>   tools/build/feature/test-zlib.c                    |   9 ++
>   tools/perf/Makefile.perf                           |   2 +-
>   tools/perf/config/Makefile                         |   2 +-
>   tools/perf/config/Makefile.feature                 | 171 ---------------------
>   tools/perf/config/feature-checks/.gitignore        |   2 -
>   tools/perf/config/feature-checks/Makefile          | 159 -------------------
>   tools/perf/config/feature-checks/test-all.c        | 136 ----------------
>   tools/perf/config/feature-checks/test-backtrace.c  |  13 --
>   tools/perf/config/feature-checks/test-bionic.c     |   6 -
>   tools/perf/config/feature-checks/test-compile.c    |   4 -
>   .../config/feature-checks/test-cplus-demangle.c    |  14 --
>   tools/perf/config/feature-checks/test-dwarf.c      |  10 --
>   .../config/feature-checks/test-fortify-source.c    |   6 -
>   tools/perf/config/feature-checks/test-glibc.c      |   8 -
>   .../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 --
>   .../config/feature-checks/test-libbabeltrace.c     |   8 -
>   tools/perf/config/feature-checks/test-libbfd.c     |  15 --
>   .../feature-checks/test-libdw-dwarf-unwind.c       |  13 --
>   .../config/feature-checks/test-libelf-getphdrnum.c |   8 -
>   .../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 --
>   .../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 -
>   .../feature-checks/test-libunwind-debug-frame.c    |  16 --
>   tools/perf/config/feature-checks/test-libunwind.c  |  27 ----
>   .../test-pthread-attr-setaffinity-np.c             |  17 --
>   .../feature-checks/test-stackprotector-all.c       |   6 -
>   .../feature-checks/test-sync-compare-and-swap.c    |  14 --
>   tools/perf/config/feature-checks/test-timerfd.c    |  18 ---
>   tools/perf/config/feature-checks/test-zlib.c       |   9 --
>   68 files changed, 777 insertions(+), 777 deletions(-)
>   create mode 100644 tools/build/Makefile.feature
>   create mode 100644 tools/build/feature/.gitignore
>   create mode 100644 tools/build/feature/Makefile
>   create mode 100644 tools/build/feature/test-all.c
>   create mode 100644 tools/build/feature/test-backtrace.c
>   create mode 100644 tools/build/feature/test-bionic.c
>   create mode 100644 tools/build/feature/test-compile.c
>   create mode 100644 tools/build/feature/test-cplus-demangle.c
>   create mode 100644 tools/build/feature/test-dwarf.c
>   create mode 100644 tools/build/feature/test-fortify-source.c
>   create mode 100644 tools/build/feature/test-glibc.c
>   create mode 100644 tools/build/feature/test-gtk2-infobar.c
>   create mode 100644 tools/build/feature/test-gtk2.c
>   create mode 100644 tools/build/feature/test-hello.c
>   create mode 100644 tools/build/feature/test-libaudit.c
>   create mode 100644 tools/build/feature/test-libbabeltrace.c
>   create mode 100644 tools/build/feature/test-libbfd.c
>   create mode 100644 tools/build/feature/test-libdw-dwarf-unwind.c
>   create mode 100644 tools/build/feature/test-libelf-getphdrnum.c
>   create mode 100644 tools/build/feature/test-libelf-mmap.c
>   create mode 100644 tools/build/feature/test-libelf.c
>   create mode 100644 tools/build/feature/test-libnuma.c
>   create mode 100644 tools/build/feature/test-libperl.c
>   create mode 100644 tools/build/feature/test-libpython-version.c
>   create mode 100644 tools/build/feature/test-libpython.c
>   create mode 100644 tools/build/feature/test-libslang.c
>   create mode 100644 tools/build/feature/test-libunwind-debug-frame.c
>   create mode 100644 tools/build/feature/test-libunwind.c
>   create mode 100644 tools/build/feature/test-pthread-attr-setaffinity-np.c
>   create mode 100644 tools/build/feature/test-stackprotector-all.c
>   create mode 100644 tools/build/feature/test-sync-compare-and-swap.c
>   create mode 100644 tools/build/feature/test-timerfd.c
>   create mode 100644 tools/build/feature/test-zlib.c
>   delete mode 100644 tools/perf/config/Makefile.feature
>   delete mode 100644 tools/perf/config/feature-checks/.gitignore
>   delete mode 100644 tools/perf/config/feature-checks/Makefile
>   delete mode 100644 tools/perf/config/feature-checks/test-all.c
>   delete mode 100644 tools/perf/config/feature-checks/test-backtrace.c
>   delete mode 100644 tools/perf/config/feature-checks/test-bionic.c
>   delete mode 100644 tools/perf/config/feature-checks/test-compile.c
>   delete mode 100644 tools/perf/config/feature-checks/test-cplus-demangle.c
>   delete mode 100644 tools/perf/config/feature-checks/test-dwarf.c
>   delete mode 100644 tools/perf/config/feature-checks/test-fortify-source.c
>   delete mode 100644 tools/perf/config/feature-checks/test-glibc.c
>   delete mode 100644 tools/perf/config/feature-checks/test-gtk2-infobar.c
>   delete mode 100644 tools/perf/config/feature-checks/test-gtk2.c
>   delete mode 100644 tools/perf/config/feature-checks/test-hello.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libaudit.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libbabeltrace.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libbfd.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libelf-getphdrnum.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libelf-mmap.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libelf.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libnuma.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libperl.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libpython-version.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libpython.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libslang.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libunwind-debug-frame.c
>   delete mode 100644 tools/perf/config/feature-checks/test-libunwind.c
>   delete mode 100644 tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
>   delete mode 100644 tools/perf/config/feature-checks/test-stackprotector-all.c
>   delete mode 100644 tools/perf/config/feature-checks/test-sync-compare-and-swap.c
>   delete mode 100644 tools/perf/config/feature-checks/test-timerfd.c
>   delete mode 100644 tools/perf/config/feature-checks/test-zlib.c
>
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> new file mode 100644
> index 000000000000..3249fad27993
> --- /dev/null
> +++ b/tools/build/Makefile.feature
> @@ -0,0 +1,171 @@
> +feature_dir := $(srctree)/tools/build/feature
> +
> +ifneq ($(OUTPUT),)
> +  OUTPUT_FEATURES = $(OUTPUT)feature/
> +  $(shell mkdir -p $(OUTPUT_FEATURES))
> +endif
> +
> +feature_check = $(eval $(feature_check_code))
> +define feature_check_code
> +  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/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:
> +#
> +
> +#
> +# 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. ]
> +#
> +FEATURE_TESTS =			\
> +	backtrace			\
> +	dwarf				\
> +	fortify-source			\
> +	sync-compare-and-swap		\
> +	glibc				\
> +	gtk2				\
> +	gtk2-infobar			\
> +	libaudit			\
> +	libbfd				\
> +	libelf				\
> +	libelf-getphdrnum		\
> +	libelf-mmap			\
> +	libnuma				\
> +	libperl				\
> +	libpython			\
> +	libpython-version		\
> +	libslang			\
> +	libunwind			\
> +	pthread-attr-setaffinity-np	\
> +	stackprotector-all		\
> +	timerfd				\
> +	libdw-dwarf-unwind		\
> +	libbabeltrace			\
> +	zlib
> +
> +FEATURE_DISPLAY =			\
> +	dwarf				\
> +	glibc				\
> +	gtk2				\
> +	libaudit			\
> +	libbfd				\
> +	libelf				\
> +	libnuma				\
> +	libperl				\
> +	libpython			\
> +	libslang			\
> +	libunwind			\
> +	libdw-dwarf-unwind		\
> +	libbabeltrace			\
> +	zlib
> +
> +# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
> +# If in the future we need per-feature checks/flags for features not
> +# mentioned in this list we need to refactor this ;-).
> +set_test_all_flags = $(eval $(set_test_all_flags_code))
> +define set_test_all_flags_code
> +  FEATURE_CHECK_CFLAGS-all  += $(FEATURE_CHECK_CFLAGS-$(1))
> +  FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
> +endef
> +
> +$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
> +
> +#
> +# Special fast-path for the 'all features are available' case:
> +#
> +$(call feature_check,all,$(MSG))
> +
> +#
> +# Just in case the build freshly failed, make sure we print the
> +# feature matrix:
> +#
> +ifeq ($(feature-all), 1)
> +  #
> +  # test-all.c passed - just set all the core feature flags to 1:
> +  #
> +  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
> +else
> +  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C $(feature_dir) $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
> +  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
> +endif
> +
> +#
> +# Print the result of the feature test:
> +#
> +feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
> +
> +define feature_print_status_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
> +endef
> +
> +feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
> +define feature_print_text_code
> +    MSG = $(shell printf '...%30s: %s' $(1) $(2))
> +endef
> +
> +FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
> +FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
> +
> +ifeq ($(dwarf-post-unwind),1)
> +  FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
> +endif
> +
> +# The $(feature_display) controls the default detection message
> +# output. It's set if:
> +# - detected features differes from stored features from
> +#   last build (in FEATURE-DUMP file)
> +# - one of the $(FEATURE_DISPLAY) is not detected
> +# - VF is enabled
> +
> +ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
> +  $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
> +  feature_display := 1
> +endif
> +
> +feature_check = $(eval $(feature_check_code))
> +define feature_check_code
> +  ifneq ($(feature-$(1)), 1)
> +    feature_display := 1
> +  endif
> +endef
> +
> +$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
> +
> +ifeq ($(VF),1)
> +  feature_display := 1
> +  feature_verbose := 1
> +endif
> +
> +ifeq ($(feature_display),1)
> +  $(info )
> +  $(info Auto-detecting system features:)
> +  $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
> +
> +  ifeq ($(dwarf-post-unwind),1)
> +    $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
> +  endif
> +
> +  ifneq ($(feature_verbose),1)
> +    $(info )
> +  endif
> +endif
> +
> +ifeq ($(feature_verbose),1)
> +  TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
> +  $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
> +  $(info )
> +endif
> diff --git a/tools/build/feature/.gitignore b/tools/build/feature/.gitignore
> new file mode 100644
> index 000000000000..80f3da0c3515
> --- /dev/null
> +++ b/tools/build/feature/.gitignore
> @@ -0,0 +1,2 @@
> +*.d
> +*.bin
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> new file mode 100644
> index 000000000000..8fe067864957
> --- /dev/null
> +++ b/tools/build/feature/Makefile
> @@ -0,0 +1,159 @@
> +
> +FILES=					\
> +	test-all.bin			\
> +	test-backtrace.bin		\
> +	test-bionic.bin			\
> +	test-dwarf.bin			\
> +	test-fortify-source.bin		\
> +	test-sync-compare-and-swap.bin	\
> +	test-glibc.bin			\
> +	test-gtk2.bin			\
> +	test-gtk2-infobar.bin		\
> +	test-hello.bin			\
> +	test-libaudit.bin		\
> +	test-libbfd.bin			\
> +	test-liberty.bin		\
> +	test-liberty-z.bin		\
> +	test-cplus-demangle.bin		\
> +	test-libelf.bin			\
> +	test-libelf-getphdrnum.bin	\
> +	test-libelf-mmap.bin		\
> +	test-libnuma.bin		\
> +	test-libperl.bin		\
> +	test-libpython.bin		\
> +	test-libpython-version.bin	\
> +	test-libslang.bin		\
> +	test-libunwind.bin		\
> +	test-libunwind-debug-frame.bin	\
> +	test-pthread-attr-setaffinity-np.bin	\
> +	test-stackprotector-all.bin	\
> +	test-timerfd.bin		\
> +	test-libdw-dwarf-unwind.bin	\
> +	test-libbabeltrace.bin		\
> +	test-compile-32.bin		\
> +	test-compile-x32.bin		\
> +	test-zlib.bin
> +
> +CC := $(CROSS_COMPILE)gcc -MD
> +PKG_CONFIG := $(CROSS_COMPILE)pkg-config
> +
> +all: $(FILES)
> +
> +BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
> +
> +###############################
> +
> +test-all.bin:
> +	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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 -lz -lbabeltrace
> +
> +test-hello.bin:
> +	$(BUILD)
> +
> +test-pthread-attr-setaffinity-np.bin:
> +	$(BUILD) -D_GNU_SOURCE -lpthread
> +
> +test-stackprotector-all.bin:
> +	$(BUILD) -fstack-protector-all
> +
> +test-fortify-source.bin:
> +	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
> +
> +test-bionic.bin:
> +	$(BUILD)
> +
> +test-libelf.bin:
> +	$(BUILD) -lelf
> +
> +test-glibc.bin:
> +	$(BUILD)
> +
> +test-dwarf.bin:
> +	$(BUILD) -ldw
> +
> +test-libelf-mmap.bin:
> +	$(BUILD) -lelf
> +
> +test-libelf-getphdrnum.bin:
> +	$(BUILD) -lelf
> +
> +test-libnuma.bin:
> +	$(BUILD) -lnuma
> +
> +test-libunwind.bin:
> +	$(BUILD) -lelf
> +
> +test-libunwind-debug-frame.bin:
> +	$(BUILD) -lelf
> +
> +test-libaudit.bin:
> +	$(BUILD) -laudit
> +
> +test-libslang.bin:
> +	$(BUILD) -I/usr/include/slang -lslang
> +
> +test-gtk2.bin:
> +	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
> +
> +test-gtk2-infobar.bin:
> +	$(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.bin:
> +	$(BUILD) $(FLAGS_PERL_EMBED)
> +
> +test-libpython.bin:
> +	$(BUILD)
> +
> +test-libpython-version.bin:
> +	$(BUILD)
> +
> +test-libbfd.bin:
> +	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
> +
> +test-liberty.bin:
> +	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
> +
> +test-liberty-z.bin:
> +	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
> +
> +test-cplus-demangle.bin:
> +	$(BUILD) -liberty
> +
> +test-backtrace.bin:
> +	$(BUILD)
> +
> +test-timerfd.bin:
> +	$(BUILD)
> +
> +test-libdw-dwarf-unwind.bin:
> +	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
> +
> +test-libbabeltrace.bin:
> +	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
> +
> +test-sync-compare-and-swap.bin:
> +	$(BUILD)
> +
> +test-compile-32.bin:
> +	$(CC) -m32 -o $(OUTPUT)$@ test-compile.c
> +
> +test-compile-x32.bin:
> +	$(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
> +
> +test-zlib.bin:
> +	$(BUILD) -lz
> +
> +-include *.d
> +
> +###############################
> +
> +clean:
> +	rm -f $(FILES) *.d
> diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
> new file mode 100644
> index 000000000000..1ffc3da5ca10
> --- /dev/null
> +++ b/tools/build/feature/test-all.c
> @@ -0,0 +1,136 @@
> +/*
> + * 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_backtrace
> +# include "test-backtrace.c"
> +#undef main
> +
> +#define main main_test_libnuma
> +# include "test-libnuma.c"
> +#undef main
> +
> +#define main main_test_timerfd
> +# include "test-timerfd.c"
> +#undef main
> +
> +#define main main_test_stackprotector_all
> +# include "test-stackprotector-all.c"
> +#undef main
> +
> +#define main main_test_libdw_dwarf_unwind
> +# include "test-libdw-dwarf-unwind.c"
> +#undef main
> +
> +#define main main_test_sync_compare_and_swap
> +# include "test-sync-compare-and-swap.c"
> +#undef main
> +
> +#define main main_test_zlib
> +# include "test-zlib.c"
> +#undef main
> +
> +#define main main_test_pthread_attr_setaffinity_np
> +# include "test-pthread_attr_setaffinity_np.c"
> +#undef main
> +
> +#define main main_test_libbabeltrace
> +# include "test-libbabeltrace.c"
> +#undef main
> +
> +int main(int argc, char *argv[])
> +{
> +	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_backtrace();
> +	main_test_libnuma();
> +	main_test_timerfd();
> +	main_test_stackprotector_all();
> +	main_test_libdw_dwarf_unwind();
> +	main_test_sync_compare_and_swap(argc, argv);
> +	main_test_zlib();
> +	main_test_pthread_attr_setaffinity_np();
> +	main_test_libbabeltrace();
> +
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-backtrace.c b/tools/build/feature/test-backtrace.c
> new file mode 100644
> index 000000000000..7124aa1dc8fb
> --- /dev/null
> +++ b/tools/build/feature/test-backtrace.c
> @@ -0,0 +1,13 @@
> +#include <execinfo.h>
> +#include <stdio.h>
> +
> +int main(void)
> +{
> +	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/build/feature/test-bionic.c b/tools/build/feature/test-bionic.c
> new file mode 100644
> index 000000000000..eac24e9513eb
> --- /dev/null
> +++ b/tools/build/feature/test-bionic.c
> @@ -0,0 +1,6 @@
> +#include <android/api-level.h>
> +
> +int main(void)
> +{
> +	return __ANDROID_API__;
> +}
> diff --git a/tools/build/feature/test-compile.c b/tools/build/feature/test-compile.c
> new file mode 100644
> index 000000000000..31dbf45bf99c
> --- /dev/null
> +++ b/tools/build/feature/test-compile.c
> @@ -0,0 +1,4 @@
> +int main(void)
> +{
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-cplus-demangle.c b/tools/build/feature/test-cplus-demangle.c
> new file mode 100644
> index 000000000000..610c686e0009
> --- /dev/null
> +++ b/tools/build/feature/test-cplus-demangle.c
> @@ -0,0 +1,14 @@
> +extern int printf(const char *format, ...);
> +extern char *cplus_demangle(const char *, int);
> +
> +int main(void)
> +{
> +	char symbol[4096] = "FieldName__9ClassNameFd";
> +	char *tmp;
> +
> +	tmp = cplus_demangle(symbol, 0);
> +
> +	printf("demangled symbol: {%s}\n", tmp);
> +
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-dwarf.c b/tools/build/feature/test-dwarf.c
> new file mode 100644
> index 000000000000..3fc1801ce4a9
> --- /dev/null
> +++ b/tools/build/feature/test-dwarf.c
> @@ -0,0 +1,10 @@
> +#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;
> +}
> diff --git a/tools/build/feature/test-fortify-source.c b/tools/build/feature/test-fortify-source.c
> new file mode 100644
> index 000000000000..c9f398d87868
> --- /dev/null
> +++ b/tools/build/feature/test-fortify-source.c
> @@ -0,0 +1,6 @@
> +#include <stdio.h>
> +
> +int main(void)
> +{
> +	return puts("hi");
> +}
> diff --git a/tools/build/feature/test-glibc.c b/tools/build/feature/test-glibc.c
> new file mode 100644
> index 000000000000..b0820345cd98
> --- /dev/null
> +++ b/tools/build/feature/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;
> +}
> diff --git a/tools/build/feature/test-gtk2-infobar.c b/tools/build/feature/test-gtk2-infobar.c
> new file mode 100644
> index 000000000000..397b4646d066
> --- /dev/null
> +++ b/tools/build/feature/test-gtk2-infobar.c
> @@ -0,0 +1,11 @@
> +#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);
> +	gtk_info_bar_new();
> +
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-gtk2.c b/tools/build/feature/test-gtk2.c
> new file mode 100644
> index 000000000000..6bd80e509439
> --- /dev/null
> +++ b/tools/build/feature/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;
> +}
> diff --git a/tools/build/feature/test-hello.c b/tools/build/feature/test-hello.c
> new file mode 100644
> index 000000000000..c9f398d87868
> --- /dev/null
> +++ b/tools/build/feature/test-hello.c
> @@ -0,0 +1,6 @@
> +#include <stdio.h>
> +
> +int main(void)
> +{
> +	return puts("hi");
> +}
> diff --git a/tools/build/feature/test-libaudit.c b/tools/build/feature/test-libaudit.c
> new file mode 100644
> index 000000000000..afc019f08641
> --- /dev/null
> +++ b/tools/build/feature/test-libaudit.c
> @@ -0,0 +1,10 @@
> +#include <libaudit.h>
> +
> +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/build/feature/test-libbabeltrace.c b/tools/build/feature/test-libbabeltrace.c
> new file mode 100644
> index 000000000000..3b7dd68a4d52
> --- /dev/null
> +++ b/tools/build/feature/test-libbabeltrace.c
> @@ -0,0 +1,8 @@
> +
> +#include <babeltrace/ctf-writer/writer.h>
> +
> +int main(void)
> +{
> +	bt_ctf_stream_class_get_packet_context_type((void *) 0);
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-libbfd.c b/tools/build/feature/test-libbfd.c
> new file mode 100644
> index 000000000000..24059907e990
> --- /dev/null
> +++ b/tools/build/feature/test-libbfd.c
> @@ -0,0 +1,15 @@
> +#include <bfd.h>
> +
> +extern int printf(const char *format, ...);
> +
> +int main(void)
> +{
> +	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/build/feature/test-libdw-dwarf-unwind.c b/tools/build/feature/test-libdw-dwarf-unwind.c
> new file mode 100644
> index 000000000000..f676a3ff442a
> --- /dev/null
> +++ b/tools/build/feature/test-libdw-dwarf-unwind.c
> @@ -0,0 +1,13 @@
> +
> +#include <elfutils/libdwfl.h>
> +
> +int main(void)
> +{
> +	/*
> +	 * This function is guarded via: __nonnull_attribute__ (1, 2).
> +	 * Passing '1' as arguments value. This code is never executed,
> +	 * only compiled.
> +	 */
> +	dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-libelf-getphdrnum.c b/tools/build/feature/test-libelf-getphdrnum.c
> new file mode 100644
> index 000000000000..d710459306c3
> --- /dev/null
> +++ b/tools/build/feature/test-libelf-getphdrnum.c
> @@ -0,0 +1,8 @@
> +#include <libelf.h>
> +
> +int main(void)
> +{
> +	size_t dst;
> +
> +	return elf_getphdrnum(0, &dst);
> +}
> diff --git a/tools/build/feature/test-libelf-mmap.c b/tools/build/feature/test-libelf-mmap.c
> new file mode 100644
> index 000000000000..564427d7ef18
> --- /dev/null
> +++ b/tools/build/feature/test-libelf-mmap.c
> @@ -0,0 +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/build/feature/test-libelf.c b/tools/build/feature/test-libelf.c
> new file mode 100644
> index 000000000000..08db322d8957
> --- /dev/null
> +++ b/tools/build/feature/test-libelf.c
> @@ -0,0 +1,8 @@
> +#include <libelf.h>
> +
> +int main(void)
> +{
> +	Elf *elf = elf_begin(0, ELF_C_READ, 0);
> +
> +	return (long)elf;
> +}
> diff --git a/tools/build/feature/test-libnuma.c b/tools/build/feature/test-libnuma.c
> new file mode 100644
> index 000000000000..4763d9cd587d
> --- /dev/null
> +++ b/tools/build/feature/test-libnuma.c
> @@ -0,0 +1,9 @@
> +#include <numa.h>
> +#include <numaif.h>
> +
> +int main(void)
> +{
> +	numa_available();
> +
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-libperl.c b/tools/build/feature/test-libperl.c
> new file mode 100644
> index 000000000000..8871f6a0fdb4
> --- /dev/null
> +++ b/tools/build/feature/test-libperl.c
> @@ -0,0 +1,9 @@
> +#include <EXTERN.h>
> +#include <perl.h>
> +
> +int main(void)
> +{
> +	perl_alloc();
> +
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-libpython-version.c b/tools/build/feature/test-libpython-version.c
> new file mode 100644
> index 000000000000..facea122d812
> --- /dev/null
> +++ b/tools/build/feature/test-libpython-version.c
> @@ -0,0 +1,10 @@
> +#include <Python.h>
> +
> +#if PY_VERSION_HEX >= 0x03000000
> +	#error
> +#endif
> +
> +int main(void)
> +{
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-libpython.c b/tools/build/feature/test-libpython.c
> new file mode 100644
> index 000000000000..b24b28ad6324
> --- /dev/null
> +++ b/tools/build/feature/test-libpython.c
> @@ -0,0 +1,8 @@
> +#include <Python.h>
> +
> +int main(void)
> +{
> +	Py_Initialize();
> +
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-libslang.c b/tools/build/feature/test-libslang.c
> new file mode 100644
> index 000000000000..22ff22ed94d1
> --- /dev/null
> +++ b/tools/build/feature/test-libslang.c
> @@ -0,0 +1,6 @@
> +#include <slang.h>
> +
> +int main(void)
> +{
> +	return SLsmg_init_smg();
> +}
> diff --git a/tools/build/feature/test-libunwind-debug-frame.c b/tools/build/feature/test-libunwind-debug-frame.c
> new file mode 100644
> index 000000000000..0ef8087a104a
> --- /dev/null
> +++ b/tools/build/feature/test-libunwind-debug-frame.c
> @@ -0,0 +1,16 @@
> +#include <libunwind.h>
> +#include <stdlib.h>
> +
> +extern int
> +UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
> +				 unw_word_t ip, unw_word_t segbase,
> +				 const char *obj_name, unw_word_t start,
> +				 unw_word_t end);
> +
> +#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
> +
> +int main(void)
> +{
> +	dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-libunwind.c b/tools/build/feature/test-libunwind.c
> new file mode 100644
> index 000000000000..43b9369bcab7
> --- /dev/null
> +++ b/tools/build/feature/test-libunwind.c
> @@ -0,0 +1,27 @@
> +#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)
> +
> +static unw_accessors_t accessors;
> +
> +int main(void)
> +{
> +	unw_addr_space_t addr_space;
> +
> +	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/build/feature/test-pthread-attr-setaffinity-np.c b/tools/build/feature/test-pthread-attr-setaffinity-np.c
> new file mode 100644
> index 000000000000..fdada5e8d454
> --- /dev/null
> +++ b/tools/build/feature/test-pthread-attr-setaffinity-np.c
> @@ -0,0 +1,17 @@
> +#include <stdint.h>
> +#include <pthread.h>
> +#include <sched.h>
> +
> +int main(void)
> +{
> +	int ret = 0;
> +	pthread_attr_t thread_attr;
> +	cpu_set_t cs;
> +
> +	pthread_attr_init(&thread_attr);
> +	CPU_ZERO(&cs);
> +
> +	ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
> +
> +	return ret;
> +}
> diff --git a/tools/build/feature/test-stackprotector-all.c b/tools/build/feature/test-stackprotector-all.c
> new file mode 100644
> index 000000000000..c9f398d87868
> --- /dev/null
> +++ b/tools/build/feature/test-stackprotector-all.c
> @@ -0,0 +1,6 @@
> +#include <stdio.h>
> +
> +int main(void)
> +{
> +	return puts("hi");
> +}
> diff --git a/tools/build/feature/test-sync-compare-and-swap.c b/tools/build/feature/test-sync-compare-and-swap.c
> new file mode 100644
> index 000000000000..c34d4ca4af56
> --- /dev/null
> +++ b/tools/build/feature/test-sync-compare-and-swap.c
> @@ -0,0 +1,14 @@
> +#include <stdint.h>
> +
> +volatile uint64_t x;
> +
> +int main(int argc, char *argv[])
> +{
> +	uint64_t old, new = argc;
> +
> +	argv = argv;
> +	do {
> +		old = __sync_val_compare_and_swap(&x, 0, 0);
> +	} while (!__sync_bool_compare_and_swap(&x, old, new));
> +	return old == new;
> +}
> diff --git a/tools/build/feature/test-timerfd.c b/tools/build/feature/test-timerfd.c
> new file mode 100644
> index 000000000000..8c5c083b4d3c
> --- /dev/null
> +++ b/tools/build/feature/test-timerfd.c
> @@ -0,0 +1,18 @@
> +/*
> + * test for timerfd functions used by perf-kvm-stat-live
> + */
> +#include <sys/timerfd.h>
> +
> +int main(void)
> +{
> +	struct itimerspec new_value;
> +
> +	int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
> +	if (fd < 0)
> +		return 1;
> +
> +	if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
> +		return 1;
> +
> +	return 0;
> +}
> diff --git a/tools/build/feature/test-zlib.c b/tools/build/feature/test-zlib.c
> new file mode 100644
> index 000000000000..e111fff6240e
> --- /dev/null
> +++ b/tools/build/feature/test-zlib.c
> @@ -0,0 +1,9 @@
> +#include <zlib.h>
> +
> +int main(void)
> +{
> +	z_stream zs;
> +
> +	inflateInit(&zs);
> +	return 0;
> +}
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index e323eab10694..d5b9e0dae334 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -521,7 +521,7 @@ $(INSTALL_DOC_TARGETS):
>   #
>   config-clean:
>   	$(call QUIET_CLEAN, config)
> -	$(Q)$(MAKE) -C config/feature-checks clean >/dev/null
> +	$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
>
>   clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean
>   	$(call QUIET_CLEAN, core-objs)  $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
> index 01d8acc5453e..df666a596c2a 100644
> --- a/tools/perf/config/Makefile
> +++ b/tools/perf/config/Makefile
> @@ -176,7 +176,7 @@ LDFLAGS += -Wl,-z,noexecstack
>
>   EXTLIBS = -lpthread -lrt -lm -ldl
>
> -include $(src-perf)/config/Makefile.feature
> +include $(srctree)/tools/build/Makefile.feature
>
>   ifeq ($(feature-stackprotector-all), 1)
>     CFLAGS += -fstack-protector-all
> diff --git a/tools/perf/config/Makefile.feature b/tools/perf/config/Makefile.feature
> deleted file mode 100644
> index 55b671a93d67..000000000000
> --- a/tools/perf/config/Makefile.feature
> +++ /dev/null
> @@ -1,171 +0,0 @@
> -feature_dir := $(srctree)/tools/perf/config/feature-checks
> -
> -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) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/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:
> -#
> -
> -#
> -# 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. ]
> -#
> -FEATURE_TESTS =			\
> -	backtrace			\
> -	dwarf				\
> -	fortify-source			\
> -	sync-compare-and-swap		\
> -	glibc				\
> -	gtk2				\
> -	gtk2-infobar			\
> -	libaudit			\
> -	libbfd				\
> -	libelf				\
> -	libelf-getphdrnum		\
> -	libelf-mmap			\
> -	libnuma				\
> -	libperl				\
> -	libpython			\
> -	libpython-version		\
> -	libslang			\
> -	libunwind			\
> -	pthread-attr-setaffinity-np	\
> -	stackprotector-all		\
> -	timerfd				\
> -	libdw-dwarf-unwind		\
> -	libbabeltrace			\
> -	zlib
> -
> -FEATURE_DISPLAY =			\
> -	dwarf				\
> -	glibc				\
> -	gtk2				\
> -	libaudit			\
> -	libbfd				\
> -	libelf				\
> -	libnuma				\
> -	libperl				\
> -	libpython			\
> -	libslang			\
> -	libunwind			\
> -	libdw-dwarf-unwind		\
> -	libbabeltrace			\
> -	zlib
> -
> -# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
> -# If in the future we need per-feature checks/flags for features not
> -# mentioned in this list we need to refactor this ;-).
> -set_test_all_flags = $(eval $(set_test_all_flags_code))
> -define set_test_all_flags_code
> -  FEATURE_CHECK_CFLAGS-all  += $(FEATURE_CHECK_CFLAGS-$(1))
> -  FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
> -endef
> -
> -$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
> -
> -#
> -# Special fast-path for the 'all features are available' case:
> -#
> -$(call feature_check,all,$(MSG))
> -
> -#
> -# Just in case the build freshly failed, make sure we print the
> -# feature matrix:
> -#
> -ifeq ($(feature-all), 1)
> -  #
> -  # test-all.c passed - just set all the core feature flags to 1:
> -  #
> -  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
> -else
> -  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C $(feature_dir) $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
> -  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
> -endif
> -
> -#
> -# Print the result of the feature test:
> -#
> -feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
> -
> -define feature_print_status_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
> -endef
> -
> -feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
> -define feature_print_text_code
> -    MSG = $(shell printf '...%30s: %s' $(1) $(2))
> -endef
> -
> -FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
> -FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
> -
> -ifeq ($(dwarf-post-unwind),1)
> -  FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
> -endif
> -
> -# The $(feature_display) controls the default detection message
> -# output. It's set if:
> -# - detected features differes from stored features from
> -#   last build (in FEATURE-DUMP file)
> -# - one of the $(FEATURE_DISPLAY) is not detected
> -# - VF is enabled
> -
> -ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
> -  $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
> -  feature_display := 1
> -endif
> -
> -feature_check = $(eval $(feature_check_code))
> -define feature_check_code
> -  ifneq ($(feature-$(1)), 1)
> -    feature_display := 1
> -  endif
> -endef
> -
> -$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
> -
> -ifeq ($(VF),1)
> -  feature_display := 1
> -  feature_verbose := 1
> -endif
> -
> -ifeq ($(feature_display),1)
> -  $(info )
> -  $(info Auto-detecting system features:)
> -  $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
> -
> -  ifeq ($(dwarf-post-unwind),1)
> -    $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
> -  endif
> -
> -  ifneq ($(feature_verbose),1)
> -    $(info )
> -  endif
> -endif
> -
> -ifeq ($(feature_verbose),1)
> -  TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
> -  $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
> -  $(info )
> -endif
> diff --git a/tools/perf/config/feature-checks/.gitignore b/tools/perf/config/feature-checks/.gitignore
> deleted file mode 100644
> index 80f3da0c3515..000000000000
> --- a/tools/perf/config/feature-checks/.gitignore
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -*.d
> -*.bin
> diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
> deleted file mode 100644
> index 8fe067864957..000000000000
> --- a/tools/perf/config/feature-checks/Makefile
> +++ /dev/null
> @@ -1,159 +0,0 @@
> -
> -FILES=					\
> -	test-all.bin			\
> -	test-backtrace.bin		\
> -	test-bionic.bin			\
> -	test-dwarf.bin			\
> -	test-fortify-source.bin		\
> -	test-sync-compare-and-swap.bin	\
> -	test-glibc.bin			\
> -	test-gtk2.bin			\
> -	test-gtk2-infobar.bin		\
> -	test-hello.bin			\
> -	test-libaudit.bin		\
> -	test-libbfd.bin			\
> -	test-liberty.bin		\
> -	test-liberty-z.bin		\
> -	test-cplus-demangle.bin		\
> -	test-libelf.bin			\
> -	test-libelf-getphdrnum.bin	\
> -	test-libelf-mmap.bin		\
> -	test-libnuma.bin		\
> -	test-libperl.bin		\
> -	test-libpython.bin		\
> -	test-libpython-version.bin	\
> -	test-libslang.bin		\
> -	test-libunwind.bin		\
> -	test-libunwind-debug-frame.bin	\
> -	test-pthread-attr-setaffinity-np.bin	\
> -	test-stackprotector-all.bin	\
> -	test-timerfd.bin		\
> -	test-libdw-dwarf-unwind.bin	\
> -	test-libbabeltrace.bin		\
> -	test-compile-32.bin		\
> -	test-compile-x32.bin		\
> -	test-zlib.bin
> -
> -CC := $(CROSS_COMPILE)gcc -MD
> -PKG_CONFIG := $(CROSS_COMPILE)pkg-config
> -
> -all: $(FILES)
> -
> -BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
> -
> -###############################
> -
> -test-all.bin:
> -	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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 -lz -lbabeltrace
> -
> -test-hello.bin:
> -	$(BUILD)
> -
> -test-pthread-attr-setaffinity-np.bin:
> -	$(BUILD) -D_GNU_SOURCE -lpthread
> -
> -test-stackprotector-all.bin:
> -	$(BUILD) -fstack-protector-all
> -
> -test-fortify-source.bin:
> -	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
> -
> -test-bionic.bin:
> -	$(BUILD)
> -
> -test-libelf.bin:
> -	$(BUILD) -lelf
> -
> -test-glibc.bin:
> -	$(BUILD)
> -
> -test-dwarf.bin:
> -	$(BUILD) -ldw
> -
> -test-libelf-mmap.bin:
> -	$(BUILD) -lelf
> -
> -test-libelf-getphdrnum.bin:
> -	$(BUILD) -lelf
> -
> -test-libnuma.bin:
> -	$(BUILD) -lnuma
> -
> -test-libunwind.bin:
> -	$(BUILD) -lelf
> -
> -test-libunwind-debug-frame.bin:
> -	$(BUILD) -lelf
> -
> -test-libaudit.bin:
> -	$(BUILD) -laudit
> -
> -test-libslang.bin:
> -	$(BUILD) -I/usr/include/slang -lslang
> -
> -test-gtk2.bin:
> -	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
> -
> -test-gtk2-infobar.bin:
> -	$(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.bin:
> -	$(BUILD) $(FLAGS_PERL_EMBED)
> -
> -test-libpython.bin:
> -	$(BUILD)
> -
> -test-libpython-version.bin:
> -	$(BUILD)
> -
> -test-libbfd.bin:
> -	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
> -
> -test-liberty.bin:
> -	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
> -
> -test-liberty-z.bin:
> -	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
> -
> -test-cplus-demangle.bin:
> -	$(BUILD) -liberty
> -
> -test-backtrace.bin:
> -	$(BUILD)
> -
> -test-timerfd.bin:
> -	$(BUILD)
> -
> -test-libdw-dwarf-unwind.bin:
> -	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
> -
> -test-libbabeltrace.bin:
> -	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
> -
> -test-sync-compare-and-swap.bin:
> -	$(BUILD)
> -
> -test-compile-32.bin:
> -	$(CC) -m32 -o $(OUTPUT)$@ test-compile.c
> -
> -test-compile-x32.bin:
> -	$(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
> -
> -test-zlib.bin:
> -	$(BUILD) -lz
> -
> --include *.d
> -
> -###############################
> -
> -clean:
> -	rm -f $(FILES) *.d
> diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
> deleted file mode 100644
> index 1ffc3da5ca10..000000000000
> --- a/tools/perf/config/feature-checks/test-all.c
> +++ /dev/null
> @@ -1,136 +0,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_backtrace
> -# include "test-backtrace.c"
> -#undef main
> -
> -#define main main_test_libnuma
> -# include "test-libnuma.c"
> -#undef main
> -
> -#define main main_test_timerfd
> -# include "test-timerfd.c"
> -#undef main
> -
> -#define main main_test_stackprotector_all
> -# include "test-stackprotector-all.c"
> -#undef main
> -
> -#define main main_test_libdw_dwarf_unwind
> -# include "test-libdw-dwarf-unwind.c"
> -#undef main
> -
> -#define main main_test_sync_compare_and_swap
> -# include "test-sync-compare-and-swap.c"
> -#undef main
> -
> -#define main main_test_zlib
> -# include "test-zlib.c"
> -#undef main
> -
> -#define main main_test_pthread_attr_setaffinity_np
> -# include "test-pthread_attr_setaffinity_np.c"
> -#undef main
> -
> -#define main main_test_libbabeltrace
> -# include "test-libbabeltrace.c"
> -#undef main
> -
> -int main(int argc, char *argv[])
> -{
> -	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_backtrace();
> -	main_test_libnuma();
> -	main_test_timerfd();
> -	main_test_stackprotector_all();
> -	main_test_libdw_dwarf_unwind();
> -	main_test_sync_compare_and_swap(argc, argv);
> -	main_test_zlib();
> -	main_test_pthread_attr_setaffinity_np();
> -	main_test_libbabeltrace();
> -
> -	return 0;
> -}
> diff --git a/tools/perf/config/feature-checks/test-backtrace.c b/tools/perf/config/feature-checks/test-backtrace.c
> deleted file mode 100644
> index 7124aa1dc8fb..000000000000
> --- a/tools/perf/config/feature-checks/test-backtrace.c
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -#include <execinfo.h>
> -#include <stdio.h>
> -
> -int main(void)
> -{
> -	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-bionic.c b/tools/perf/config/feature-checks/test-bionic.c
> deleted file mode 100644
> index eac24e9513eb..000000000000
> --- a/tools/perf/config/feature-checks/test-bionic.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <android/api-level.h>
> -
> -int main(void)
> -{
> -	return __ANDROID_API__;
> -}
> diff --git a/tools/perf/config/feature-checks/test-compile.c b/tools/perf/config/feature-checks/test-compile.c
> deleted file mode 100644
> index 31dbf45bf99c..000000000000
> --- a/tools/perf/config/feature-checks/test-compile.c
> +++ /dev/null
> @@ -1,4 +0,0 @@
> -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
> deleted file mode 100644
> index 610c686e0009..000000000000
> --- a/tools/perf/config/feature-checks/test-cplus-demangle.c
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -extern int printf(const char *format, ...);
> -extern char *cplus_demangle(const char *, int);
> -
> -int main(void)
> -{
> -	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-dwarf.c b/tools/perf/config/feature-checks/test-dwarf.c
> deleted file mode 100644
> index 3fc1801ce4a9..000000000000
> --- a/tools/perf/config/feature-checks/test-dwarf.c
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -#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;
> -}
> diff --git a/tools/perf/config/feature-checks/test-fortify-source.c b/tools/perf/config/feature-checks/test-fortify-source.c
> deleted file mode 100644
> index c9f398d87868..000000000000
> --- a/tools/perf/config/feature-checks/test-fortify-source.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <stdio.h>
> -
> -int main(void)
> -{
> -	return puts("hi");
> -}
> diff --git a/tools/perf/config/feature-checks/test-glibc.c b/tools/perf/config/feature-checks/test-glibc.c
> deleted file mode 100644
> index b0820345cd98..000000000000
> --- a/tools/perf/config/feature-checks/test-glibc.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -#include <gnu/libc-version.h>
> -
> -int main(void)
> -{
> -	const char *version = gnu_get_libc_version();
> -
> -	return (long)version;
> -}
> diff --git a/tools/perf/config/feature-checks/test-gtk2-infobar.c b/tools/perf/config/feature-checks/test-gtk2-infobar.c
> deleted file mode 100644
> index 397b4646d066..000000000000
> --- a/tools/perf/config/feature-checks/test-gtk2-infobar.c
> +++ /dev/null
> @@ -1,11 +0,0 @@
> -#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);
> -	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
> deleted file mode 100644
> index 6bd80e509439..000000000000
> --- a/tools/perf/config/feature-checks/test-gtk2.c
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -#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;
> -}
> diff --git a/tools/perf/config/feature-checks/test-hello.c b/tools/perf/config/feature-checks/test-hello.c
> deleted file mode 100644
> index c9f398d87868..000000000000
> --- a/tools/perf/config/feature-checks/test-hello.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <stdio.h>
> -
> -int main(void)
> -{
> -	return puts("hi");
> -}
> diff --git a/tools/perf/config/feature-checks/test-libaudit.c b/tools/perf/config/feature-checks/test-libaudit.c
> deleted file mode 100644
> index afc019f08641..000000000000
> --- a/tools/perf/config/feature-checks/test-libaudit.c
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -#include <libaudit.h>
> -
> -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-libbabeltrace.c b/tools/perf/config/feature-checks/test-libbabeltrace.c
> deleted file mode 100644
> index 3b7dd68a4d52..000000000000
> --- a/tools/perf/config/feature-checks/test-libbabeltrace.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -
> -#include <babeltrace/ctf-writer/writer.h>
> -
> -int main(void)
> -{
> -	bt_ctf_stream_class_get_packet_context_type((void *) 0);
> -	return 0;
> -}
> diff --git a/tools/perf/config/feature-checks/test-libbfd.c b/tools/perf/config/feature-checks/test-libbfd.c
> deleted file mode 100644
> index 24059907e990..000000000000
> --- a/tools/perf/config/feature-checks/test-libbfd.c
> +++ /dev/null
> @@ -1,15 +0,0 @@
> -#include <bfd.h>
> -
> -extern int printf(const char *format, ...);
> -
> -int main(void)
> -{
> -	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-libdw-dwarf-unwind.c b/tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
> deleted file mode 100644
> index f676a3ff442a..000000000000
> --- a/tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -
> -#include <elfutils/libdwfl.h>
> -
> -int main(void)
> -{
> -	/*
> -	 * This function is guarded via: __nonnull_attribute__ (1, 2).
> -	 * Passing '1' as arguments value. This code is never executed,
> -	 * only compiled.
> -	 */
> -	dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
> -	return 0;
> -}
> diff --git a/tools/perf/config/feature-checks/test-libelf-getphdrnum.c b/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
> deleted file mode 100644
> index d710459306c3..000000000000
> --- a/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -#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
> deleted file mode 100644
> index 564427d7ef18..000000000000
> --- a/tools/perf/config/feature-checks/test-libelf-mmap.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -#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
> deleted file mode 100644
> index 08db322d8957..000000000000
> --- a/tools/perf/config/feature-checks/test-libelf.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -#include <libelf.h>
> -
> -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
> deleted file mode 100644
> index 4763d9cd587d..000000000000
> --- a/tools/perf/config/feature-checks/test-libnuma.c
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -#include <numa.h>
> -#include <numaif.h>
> -
> -int main(void)
> -{
> -	numa_available();
> -
> -	return 0;
> -}
> diff --git a/tools/perf/config/feature-checks/test-libperl.c b/tools/perf/config/feature-checks/test-libperl.c
> deleted file mode 100644
> index 8871f6a0fdb4..000000000000
> --- a/tools/perf/config/feature-checks/test-libperl.c
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -#include <EXTERN.h>
> -#include <perl.h>
> -
> -int main(void)
> -{
> -	perl_alloc();
> -
> -	return 0;
> -}
> diff --git a/tools/perf/config/feature-checks/test-libpython-version.c b/tools/perf/config/feature-checks/test-libpython-version.c
> deleted file mode 100644
> index facea122d812..000000000000
> --- a/tools/perf/config/feature-checks/test-libpython-version.c
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -#include <Python.h>
> -
> -#if PY_VERSION_HEX >= 0x03000000
> -	#error
> -#endif
> -
> -int main(void)
> -{
> -	return 0;
> -}
> diff --git a/tools/perf/config/feature-checks/test-libpython.c b/tools/perf/config/feature-checks/test-libpython.c
> deleted file mode 100644
> index b24b28ad6324..000000000000
> --- a/tools/perf/config/feature-checks/test-libpython.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -#include <Python.h>
> -
> -int main(void)
> -{
> -	Py_Initialize();
> -
> -	return 0;
> -}
> diff --git a/tools/perf/config/feature-checks/test-libslang.c b/tools/perf/config/feature-checks/test-libslang.c
> deleted file mode 100644
> index 22ff22ed94d1..000000000000
> --- a/tools/perf/config/feature-checks/test-libslang.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <slang.h>
> -
> -int main(void)
> -{
> -	return SLsmg_init_smg();
> -}
> diff --git a/tools/perf/config/feature-checks/test-libunwind-debug-frame.c b/tools/perf/config/feature-checks/test-libunwind-debug-frame.c
> deleted file mode 100644
> index 0ef8087a104a..000000000000
> --- a/tools/perf/config/feature-checks/test-libunwind-debug-frame.c
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -#include <libunwind.h>
> -#include <stdlib.h>
> -
> -extern int
> -UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
> -				 unw_word_t ip, unw_word_t segbase,
> -				 const char *obj_name, unw_word_t start,
> -				 unw_word_t end);
> -
> -#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
> -
> -int main(void)
> -{
> -	dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
> -	return 0;
> -}
> diff --git a/tools/perf/config/feature-checks/test-libunwind.c b/tools/perf/config/feature-checks/test-libunwind.c
> deleted file mode 100644
> index 43b9369bcab7..000000000000
> --- a/tools/perf/config/feature-checks/test-libunwind.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -#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)
> -
> -static unw_accessors_t accessors;
> -
> -int main(void)
> -{
> -	unw_addr_space_t addr_space;
> -
> -	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-pthread-attr-setaffinity-np.c b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
> deleted file mode 100644
> index fdada5e8d454..000000000000
> --- a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -#include <stdint.h>
> -#include <pthread.h>
> -#include <sched.h>
> -
> -int main(void)
> -{
> -	int ret = 0;
> -	pthread_attr_t thread_attr;
> -	cpu_set_t cs;
> -
> -	pthread_attr_init(&thread_attr);
> -	CPU_ZERO(&cs);
> -
> -	ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
> -
> -	return ret;
> -}
> diff --git a/tools/perf/config/feature-checks/test-stackprotector-all.c b/tools/perf/config/feature-checks/test-stackprotector-all.c
> deleted file mode 100644
> index c9f398d87868..000000000000
> --- a/tools/perf/config/feature-checks/test-stackprotector-all.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <stdio.h>
> -
> -int main(void)
> -{
> -	return puts("hi");
> -}
> diff --git a/tools/perf/config/feature-checks/test-sync-compare-and-swap.c b/tools/perf/config/feature-checks/test-sync-compare-and-swap.c
> deleted file mode 100644
> index c34d4ca4af56..000000000000
> --- a/tools/perf/config/feature-checks/test-sync-compare-and-swap.c
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -#include <stdint.h>
> -
> -volatile uint64_t x;
> -
> -int main(int argc, char *argv[])
> -{
> -	uint64_t old, new = argc;
> -
> -	argv = argv;
> -	do {
> -		old = __sync_val_compare_and_swap(&x, 0, 0);
> -	} while (!__sync_bool_compare_and_swap(&x, old, new));
> -	return old == new;
> -}
> diff --git a/tools/perf/config/feature-checks/test-timerfd.c b/tools/perf/config/feature-checks/test-timerfd.c
> deleted file mode 100644
> index 8c5c083b4d3c..000000000000
> --- a/tools/perf/config/feature-checks/test-timerfd.c
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -/*
> - * test for timerfd functions used by perf-kvm-stat-live
> - */
> -#include <sys/timerfd.h>
> -
> -int main(void)
> -{
> -	struct itimerspec new_value;
> -
> -	int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
> -	if (fd < 0)
> -		return 1;
> -
> -	if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
> -		return 1;
> -
> -	return 0;
> -}
> diff --git a/tools/perf/config/feature-checks/test-zlib.c b/tools/perf/config/feature-checks/test-zlib.c
> deleted file mode 100644
> index e111fff6240e..000000000000
> --- a/tools/perf/config/feature-checks/test-zlib.c
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -#include <zlib.h>
> -
> -int main(void)
> -{
> -	z_stream zs;
> -
> -	inflateInit(&zs);
> -	return 0;
> -}
>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 11/14] tools build: Move feature checks code under tools/build
  2015-03-03 17:18   ` David Ahern
@ 2015-03-03 17:34     ` Jiri Olsa
  0 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 17:34 UTC (permalink / raw)
  To: David Ahern
  Cc: Jiri Olsa, linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

On Tue, Mar 03, 2015 at 10:18:41AM -0700, David Ahern wrote:
> On 3/3/15 7:26 AM, Jiri Olsa wrote:
> >Moving feature checks code under tools/build directory.
> 
> How does a specific tool specify which features are of interest? I can't
> imagine all features for perf are wanted by other tools.

it's described in patch 12/14
  tools build: Allow to override feature checks setup

jirka

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 12/14] tools build: Allow to override feature checks setup
  2015-03-03 14:26 ` [PATCH 12/14] tools build: Allow to override feature checks setup Jiri Olsa
@ 2015-03-03 17:49   ` David Ahern
  2015-03-03 17:55     ` Jiri Olsa
  2015-03-04 12:23   ` Namhyung Kim
  1 sibling, 1 reply; 25+ messages in thread
From: David Ahern @ 2015-03-03 17:49 UTC (permalink / raw)
  To: Jiri Olsa, linux-kernel
  Cc: Arnaldo Carvalho de Melo, Corey Ashford, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra

On 3/3/15 7:26 AM, Jiri Olsa wrote:
> Allowing to override configuration variables for feature
> checks. Also adding automated test and documentation.

Rather than an 'override' why not require users to specify feature 
checks of interest? ie., the previous patch moved all of perf's feature 
checks to a common Makefile. Why not have perf specify features of 
interest to it instead?

David

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 12/14] tools build: Allow to override feature checks setup
  2015-03-03 17:49   ` David Ahern
@ 2015-03-03 17:55     ` Jiri Olsa
  0 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-03 17:55 UTC (permalink / raw)
  To: David Ahern
  Cc: Jiri Olsa, linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

On Tue, Mar 03, 2015 at 10:49:08AM -0700, David Ahern wrote:
> On 3/3/15 7:26 AM, Jiri Olsa wrote:
> >Allowing to override configuration variables for feature
> >checks. Also adding automated test and documentation.
> 
> Rather than an 'override' why not require users to specify feature checks of
> interest? ie., the previous patch moved all of perf's feature checks to a
> common Makefile. Why not have perf specify features of interest to it
> instead?

well, thats what they can do as you can see in the example:

+  FEATURE_TESTS   := glibc backtrace
+  FEATURE_DISPLAY := glibc
+
+  srctree := ../../../..
+  include $(srctree)/tools/build/Makefile.feature

you specify features you want to check in FEATURE_TESTS variable
and features status you want to display in FEATURE_DISPLAY variable

at the mean time the default settings for those 2 is what
perf uses now (perf is the only user)

in future when there's multiple users, perf will set those
variables as well..

jirka

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/14] tools build: Move features framework into tools/build
  2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
                   ` (13 preceding siblings ...)
  2015-03-03 14:26 ` [PATCH 14/14] tools build: Disable default check for libbabeltrace Jiri Olsa
@ 2015-03-04  4:41 ` Ingo Molnar
  2015-03-04 10:18   ` Jiri Olsa
  14 siblings, 1 reply; 25+ messages in thread
From: Ingo Molnar @ 2015-03-04  4:41 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	David Ahern, Namhyung Kim, Paul Mackerras, Peter Zijlstra


* Jiri Olsa <jolsa@kernel.org> wrote:

> hi,
> moving features detection framework from perf to 'tools/build'
> plus other minor fixes.
> 
> It's also available in:
> git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> perf/build

So the series looks really good to me, and I also tested it, pulled it 
on top of tip:master, and feature detection still worked just as 
expected.

I noticed one detail:

> Jiri Olsa (14):
>       tools build: Remove Copyright from credits message

Please just leave the current credits in place, as these gents 
certainly have a copyright in the code as well, and since we pushed 
the original attribution upstream already, so we cannot (and don't 
want to) remove it. But yes, in general authors add their own 
copyrights.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/14] tools build: Move features framework into tools/build
  2015-03-04  4:41 ` [PATCH 00/14] tools build: Move features framework into tools/build Ingo Molnar
@ 2015-03-04 10:18   ` Jiri Olsa
  0 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-04 10:18 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Jiri Olsa, linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	David Ahern, Namhyung Kim, Paul Mackerras, Peter Zijlstra

On Wed, Mar 04, 2015 at 05:41:58AM +0100, Ingo Molnar wrote:
> 
> * Jiri Olsa <jolsa@kernel.org> wrote:
> 
> > hi,
> > moving features detection framework from perf to 'tools/build'
> > plus other minor fixes.
> > 
> > It's also available in:
> > git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> > perf/build
> 
> So the series looks really good to me, and I also tested it, pulled it 
> on top of tip:master, and feature detection still worked just as 
> expected.
> 
> I noticed one detail:
> 
> > Jiri Olsa (14):
> >       tools build: Remove Copyright from credits message
> 
> Please just leave the current credits in place, as these gents 
> certainly have a copyright in the code as well, and since we pushed 
> the original attribution upstream already, so we cannot (and don't 
> want to) remove it. But yes, in general authors add their own 
> copyrights.

ok, no problem

Arnaldo, I just removed it out of my perf/build branch

thanks,
jirka

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCHv2 14/14] tools build: Disable default check for libbabeltrace
  2015-03-03 14:26 ` [PATCH 14/14] tools build: Disable default check for libbabeltrace Jiri Olsa
@ 2015-03-04 10:40   ` Jiri Olsa
  2015-03-04 20:24     ` Ingo Molnar
  0 siblings, 1 reply; 25+ messages in thread
From: Jiri Olsa @ 2015-03-04 10:40 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	David Ahern, Ingo Molnar, Namhyung Kim, Paul Mackerras,
	Peter Zijlstra

On Tue, Mar 03, 2015 at 03:26:37PM +0100, Jiri Olsa wrote:
> Remove libbabeltrace check from default features set, because the
> requested version is not released yet in most distributions. We'll
> enable later.
> 
> Calling libbabeltrace check manually via feature_check
> before $(feature-libbabeltrace) is used.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: David Ahern <david.ahern@oracle.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <peterz@infradead.org>

forgot to remove test-all.c::main's call for main_test_libbabeltrace,
v2 attached and perf/build branch updated..

thanks,
jirka


---
Remove libbabeltrace check from default features set, because the
requested version is not released yet in most distributions. We'll
enable later.

Calling libbabeltrace check manually via feature_check
before $(feature-libbabeltrace) is used.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/build/Makefile.feature   | 2 --
 tools/build/feature/Makefile   | 2 +-
 tools/build/feature/test-all.c | 9 ++++++++-
 tools/perf/config/Makefile     | 9 +++++----
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 7b587178efea..12e58703a364 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -50,7 +50,6 @@ FEATURE_TESTS ?=			\
 	stackprotector-all		\
 	timerfd				\
 	libdw-dwarf-unwind		\
-	libbabeltrace			\
 	zlib
 
 FEATURE_DISPLAY ?=			\
@@ -66,7 +65,6 @@ FEATURE_DISPLAY ?=			\
 	libslang			\
 	libunwind			\
 	libdw-dwarf-unwind		\
-	libbabeltrace			\
 	zlib
 
 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 8fe067864957..b6e2e312ba54 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -44,7 +44,7 @@ BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(
 ###############################
 
 test-all.bin:
-	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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 -lz -lbabeltrace
+	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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 -lz
 
 test-hello.bin:
 	$(BUILD)
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 1ffc3da5ca10..06f5c8a67cb2 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -101,9 +101,17 @@
 # include "test-pthread_attr_setaffinity_np.c"
 #undef main
 
+# if 0
+/*
+ * Disable libbabeltrace check for test-all, because the requested
+ * library version is not released yet in most distributions. Will
+ * reenable later.
+ */
+
 #define main main_test_libbabeltrace
 # include "test-libbabeltrace.c"
 #undef main
+#endif
 
 int main(int argc, char *argv[])
 {
@@ -130,7 +138,6 @@ int main(int argc, char *argv[])
 	main_test_sync_compare_and_swap(argc, argv);
 	main_test_zlib();
 	main_test_pthread_attr_setaffinity_np();
-	main_test_libbabeltrace();
 
 	return 0;
 }
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index df666a596c2a..480631eccf50 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -588,14 +588,15 @@ else
 endif
 
 ifndef NO_LIBBABELTRACE
-  ifeq ($(feature-libbabeltrace), 0)
-    msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
-    NO_LIBBABELTRACE := 1
-  else
+  $(call feature_check,libbabeltrace)
+  ifeq ($(feature-libbabeltrace), 1)
     CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
     LDFLAGS += $(LIBBABELTRACE_LDFLAGS)
     EXTLIBS += -lbabeltrace-ctf
     $(call detected,CONFIG_LIBBABELTRACE)
+  else
+    msg := $(warning No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev);
+    NO_LIBBABELTRACE := 1
   endif
 endif
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 12/14] tools build: Allow to override feature checks setup
  2015-03-03 14:26 ` [PATCH 12/14] tools build: Allow to override feature checks setup Jiri Olsa
  2015-03-03 17:49   ` David Ahern
@ 2015-03-04 12:23   ` Namhyung Kim
  2015-03-04 12:37     ` [PATCHv2 " Jiri Olsa
  1 sibling, 1 reply; 25+ messages in thread
From: Namhyung Kim @ 2015-03-04 12:23 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	David Ahern, Ingo Molnar, Paul Mackerras, Peter Zijlstra

On Tue, Mar 03, 2015 at 03:26:35PM +0100, Jiri Olsa wrote:
> diff --git a/tools/build/tests/features/Makefile b/tools/build/tests/features/Makefile
> new file mode 100644
> index 000000000000..31782a1d3758
> --- /dev/null
> +++ b/tools/build/tests/features/Makefile
> @@ -0,0 +1,23 @@
> +all: test1
> +
> +test1:
> +	rm -f FEATURE-DUMP
> +	make -f Makefile.test1 > out
> +	# we should get one line with 'glibc' feature status
> +	features=`cat out | grep '\.\.\.' | wc -l`; \

It seems this `cat | grep | wc -l` pipeline can be replaced with a
single `grep -cF ... out` command.

Thanks,
Namhyung


> +	if [ "$$features" != "1" ]; then echo FAILED; exit 1; fi
> +	# we should NOT get any feature status line on second run
> +	make -f Makefile.test1 > out
> +	features=`cat out | grep '\.\.\.' | wc -l`; \
> +	if [ "$$features" == "1" ]; then echo FAILED; exit 1; fi
> +	# we should get both 'glibc' and 'backtrace' status lines now
> +	make -f Makefile.test1 VF=1 > out
> +	features=`cat out | grep '\.\.\.' | wc -l`; \
> +	if [ "$$features" != "2" ]; then echo FAILED; exit 1; fi
> +	# and fresh start without FEATURE-DUMP, expecting 'glibc' status line
> +	rm -f FEATURE-DUMP
> +	make -f Makefile.test1 > out
> +	features=`cat out | grep '\.\.\.' | wc -l`; \
> +	if [ "$$features" != "1" ]; then echo FAILED; exit 1; fi
> +	# cleanup
> +	rm -f FEATURE-DUMP out

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCHv2 12/14] tools build: Allow to override feature checks setup
  2015-03-04 12:23   ` Namhyung Kim
@ 2015-03-04 12:37     ` Jiri Olsa
  0 siblings, 0 replies; 25+ messages in thread
From: Jiri Olsa @ 2015-03-04 12:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	David Ahern, Ingo Molnar, Paul Mackerras, Peter Zijlstra

On Wed, Mar 04, 2015 at 09:23:01PM +0900, Namhyung Kim wrote:
> On Tue, Mar 03, 2015 at 03:26:35PM +0100, Jiri Olsa wrote:
> > diff --git a/tools/build/tests/features/Makefile b/tools/build/tests/features/Makefile
> > new file mode 100644
> > index 000000000000..31782a1d3758
> > --- /dev/null
> > +++ b/tools/build/tests/features/Makefile
> > @@ -0,0 +1,23 @@
> > +all: test1
> > +
> > +test1:
> > +	rm -f FEATURE-DUMP
> > +	make -f Makefile.test1 > out
> > +	# we should get one line with 'glibc' feature status
> > +	features=`cat out | grep '\.\.\.' | wc -l`; \
> 
> It seems this `cat | grep | wc -l` pipeline can be replaced with a
> single `grep -cF ... out` command.

right.. v2 attached, perf/build branch updated ;-)

thanks,
jirka


---
Allowing to override configuration variables for feature
checks. Also adding automated test and documentation.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/build/Documentation/Feature.txt     | 93 +++++++++++++++++++++++++++++++
 tools/build/Makefile.feature              |  4 +-
 tools/build/tests/features/Makefile       | 23 ++++++++
 tools/build/tests/features/Makefile.test1 | 16 ++++++
 tools/build/tests/run.sh                  |  4 +-
 5 files changed, 137 insertions(+), 3 deletions(-)
 create mode 100644 tools/build/Documentation/Feature.txt
 create mode 100644 tools/build/tests/features/Makefile
 create mode 100644 tools/build/tests/features/Makefile.test1

diff --git a/tools/build/Documentation/Feature.txt b/tools/build/Documentation/Feature.txt
new file mode 100644
index 000000000000..0c75419ba803
--- /dev/null
+++ b/tools/build/Documentation/Feature.txt
@@ -0,0 +1,93 @@
+Feature Framework
+=================
+The 'feature' framework provides information for makefiles about
+installed libraries and interfaces in the system.
+
+The 'feature' is represented by its name and simple source located
+in 'tools/build/feature/test-$(name).c' file. The framework builds
+each such source for configured feature and sets $(feature-$(name))
+variable to 0 or 1 if it fails or succeeds to build respectively.
+
+The current usage example of the feature framework is:
+
+--- Makefile.test
+  FEATURE_TESTS   := glibc backtrace
+  FEATURE_DISPLAY := glibc
+
+  srctree := ../../../..
+  include $(srctree)/tools/build/Makefile.feature
+
+  ifndef feature-glibc
+    $(error FAILED feature-glibc variable not defined)
+  endif
+
+  ifndef feature-backtrace
+    $(error FAILED feature-backtrace variable not defined)
+  endif
+---
+
+User defines list of features to check in FEATURE_TESTS variable:
+
+  FEATURE_TESTS   := glibc backtrace
+
+and list of features she wishes to display in FEATURE_DISPLAY variable:
+
+  FEATURE_DISPLAY := glibc
+
+then user includes Makefile.feature makefile:
+
+  include $(srctree)/tools/build/Makefile.feature
+
+following output is displayed on processing of the makefile:
+
+  $ make -f Makefile.test
+
+  Auto-detecting system features:
+  ...                         glibc: [ on  ]
+
+Plus following variables are defined indicating the
+requested feature status:
+
+  $(feature-glibc)
+  $(feature-backtrace)
+
+Following features are currently available for FEATURE_TESTS:
+
+      backtrace
+      dwarf
+      fortify-source
+      sync-compare-and-swap
+      glibc
+      gtk2
+      gtk2-infobar
+      libaudit
+      libbfd
+      libelf
+      libelf-getphdrnum
+      libelf-mmap
+      libnuma
+      libperl
+      libpython
+      libpython-version
+      libslang
+      libunwind
+      pthread-attr-setaffinity-np
+      stackprotector-all
+      timerfd
+      libdw-dwarf-unwind
+      libbabeltrace
+      zlib
+
+It's also possible to pass options for checks compilation and linking
+by using following variables:
+
+  FEATURE_CHECK_CFLAGS-$(name)
+  FEATURE_CHECK_LDFLAGS-$(name)
+
+where $(anem) represents feature name from above list.
+
+For example following settings will provide options for 'libunwind'
+feature compilation and linking:
+
+    FEATURE_CHECK_CFLAGS-libunwind  = $(LIBUNWIND_CFLAGS)
+    FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 3249fad27993..5b712ed7e4c7 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -27,7 +27,7 @@ endef
 #   the rule that uses them - an example for that is the 'bionic'
 #   feature check. ]
 #
-FEATURE_TESTS =			\
+FEATURE_TESTS ?=			\
 	backtrace			\
 	dwarf				\
 	fortify-source			\
@@ -53,7 +53,7 @@ FEATURE_TESTS =			\
 	libbabeltrace			\
 	zlib
 
-FEATURE_DISPLAY =			\
+FEATURE_DISPLAY ?=			\
 	dwarf				\
 	glibc				\
 	gtk2				\
diff --git a/tools/build/tests/features/Makefile b/tools/build/tests/features/Makefile
new file mode 100644
index 000000000000..cb94dda32534
--- /dev/null
+++ b/tools/build/tests/features/Makefile
@@ -0,0 +1,23 @@
+all: test1
+
+test1:
+	rm -f FEATURE-DUMP
+	make -f Makefile.test1 > out
+	# we should get one line with 'glibc' feature status
+	features=`grep -cF ... out`; \
+	if [ "$$features" != "1" ]; then echo FAILED; exit 1; fi
+	# we should NOT get any feature status line on second run
+	make -f Makefile.test1 > out
+	features=`grep -cF ... out`; \
+	if [ "$$features" == "1" ]; then echo FAILED; exit 1; fi
+	# we should get both 'glibc' and 'backtrace' status lines now
+	make -f Makefile.test1 VF=1 > out
+	features=`grep -cF ... out`; \
+	if [ "$$features" != "2" ]; then echo FAILED; exit 1; fi
+	# and fresh start without FEATURE-DUMP, expecting 'glibc' status line
+	rm -f FEATURE-DUMP
+	make -f Makefile.test1 > out
+	features=`grep -cF ... out`; \
+	if [ "$$features" != "1" ]; then echo FAILED; exit 1; fi
+	# cleanup
+	rm -f FEATURE-DUMP out
diff --git a/tools/build/tests/features/Makefile.test1 b/tools/build/tests/features/Makefile.test1
new file mode 100644
index 000000000000..101b78f777c1
--- /dev/null
+++ b/tools/build/tests/features/Makefile.test1
@@ -0,0 +1,16 @@
+
+FEATURE_TESTS   := glibc backtrace
+FEATURE_DISPLAY := glibc
+
+srctree := ../../../..
+include $(srctree)/tools/build/Makefile.feature
+
+ifndef feature-glibc
+  $(error FAILED feature-glibc variable not defined)
+endif
+
+ifndef feature-backtrace
+  $(error FAILED feature-backtrace variable not defined)
+endif
+
+all:
diff --git a/tools/build/tests/run.sh b/tools/build/tests/run.sh
index 5494f8ea7567..bd6dc8ee1830 100755
--- a/tools/build/tests/run.sh
+++ b/tools/build/tests/run.sh
@@ -39,4 +39,6 @@ echo -n Testing..
 test_ex
 test_ex_suffix
 
-echo OK
+cd features && make -s -f Makefile
+
+if [ $? -eq 0 ]; then echo OK; fi
-- 
1.9.3


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCHv2 14/14] tools build: Disable default check for libbabeltrace
  2015-03-04 10:40   ` [PATCHv2 " Jiri Olsa
@ 2015-03-04 20:24     ` Ingo Molnar
  0 siblings, 0 replies; 25+ messages in thread
From: Ingo Molnar @ 2015-03-04 20:24 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	David Ahern, Namhyung Kim, Paul Mackerras, Peter Zijlstra


* Jiri Olsa <jolsa@redhat.com> wrote:

> On Tue, Mar 03, 2015 at 03:26:37PM +0100, Jiri Olsa wrote:
> > Remove libbabeltrace check from default features set, because the
> > requested version is not released yet in most distributions. We'll
> > enable later.
> > 
> > Calling libbabeltrace check manually via feature_check
> > before $(feature-libbabeltrace) is used.
> > 
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> > Cc: David Ahern <david.ahern@oracle.com>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Paul Mackerras <paulus@samba.org>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> 
> forgot to remove test-all.c::main's call for main_test_libbabeltrace,
> v2 attached and perf/build branch updated..
> 
> thanks,
> jirka
> 
> 
> ---
> Remove libbabeltrace check from default features set, because the
> requested version is not released yet in most distributions. We'll
> enable later.
> 
> Calling libbabeltrace check manually via feature_check
> before $(feature-libbabeltrace) is used.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: David Ahern <david.ahern@oracle.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> ---
>  tools/build/Makefile.feature   | 2 --
>  tools/build/feature/Makefile   | 2 +-
>  tools/build/feature/test-all.c | 9 ++++++++-
>  tools/perf/config/Makefile     | 9 +++++----
>  4 files changed, 14 insertions(+), 8 deletions(-)

Acked-by: Ingo Molnar <mingo@kernel.org>

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-03-04 20:25 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-03 14:26 [PATCH 00/14] tools build: Move features framework into tools/build Jiri Olsa
2015-03-03 14:26 ` [PATCH 01/14] tools build: Remove Copyright from credits message Jiri Olsa
2015-03-03 14:26 ` [PATCH 02/14] perf build: Get rid of LIB_INCLUDE variable Jiri Olsa
2015-03-03 14:26 ` [PATCH 03/14] perf build: Rename CORE_FEATURE_TESTS to FEATURE_TESTS Jiri Olsa
2015-03-03 14:26 ` [PATCH 04/14] perf build: Get rid of VF_FEATURE_TESTS Jiri Olsa
2015-03-03 14:26 ` [PATCH 05/14] perf build: Rename display_lib into feature_display Jiri Olsa
2015-03-03 14:26 ` [PATCH 06/14] perf build: Rename display_vf to feature_verbose Jiri Olsa
2015-03-03 14:26 ` [PATCH 07/14] perf build: Rename PERF-FEATURES into FEATURE-DUMP Jiri Olsa
2015-03-03 14:26 ` [PATCH 08/14] perf build: Rename feature_print_var_code to print_var_code Jiri Olsa
2015-03-03 14:26 ` [PATCH 09/14] perf build: Separate feature make support into config/Makefile.feature Jiri Olsa
2015-03-03 14:26 ` [PATCH 10/14] perf build: Make features checks directory configurable Jiri Olsa
2015-03-03 14:26 ` [PATCH 11/14] tools build: Move feature checks code under tools/build Jiri Olsa
2015-03-03 17:18   ` David Ahern
2015-03-03 17:34     ` Jiri Olsa
2015-03-03 14:26 ` [PATCH 12/14] tools build: Allow to override feature checks setup Jiri Olsa
2015-03-03 17:49   ` David Ahern
2015-03-03 17:55     ` Jiri Olsa
2015-03-04 12:23   ` Namhyung Kim
2015-03-04 12:37     ` [PATCHv2 " Jiri Olsa
2015-03-03 14:26 ` [PATCH 13/14] tools build: Fix feature_check name clash Jiri Olsa
2015-03-03 14:26 ` [PATCH 14/14] tools build: Disable default check for libbabeltrace Jiri Olsa
2015-03-04 10:40   ` [PATCHv2 " Jiri Olsa
2015-03-04 20:24     ` Ingo Molnar
2015-03-04  4:41 ` [PATCH 00/14] tools build: Move features framework into tools/build Ingo Molnar
2015-03-04 10:18   ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).