From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752070AbbCUSzf (ORCPT ); Sat, 21 Mar 2015 14:55:35 -0400 Received: from mail.kernel.org ([198.145.29.136]:49939 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752033AbbCUSz2 (ORCPT ); Sat, 21 Mar 2015 14:55:28 -0400 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Corey Ashford , David Ahern , Namhyung Kim , Paul Mackerras , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 10/19] perf build: Move feature checks code under tools/build Date: Sat, 21 Mar 2015 15:54:29 -0300 Message-Id: <1426964078-16384-11-git-send-email-acme@kernel.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1426964078-16384-1-git-send-email-acme@kernel.org> References: <1426964078-16384-1-git-send-email-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa 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 Cc: Corey Ashford Cc: David Ahern Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-3lamtb30dhf4wo99y1n8kxg0@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/build/Makefile.feature | 169 +++++++++++++++++++++ tools/build/feature/.gitignore | 3 + tools/build/feature/Makefile | 160 +++++++++++++++++++ tools/build/feature/test-all.c | 143 +++++++++++++++++ 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 | 9 ++ 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 | 169 --------------------- tools/perf/config/feature-checks/.gitignore | 3 - tools/perf/config/feature-checks/Makefile | 160 ------------------- tools/perf/config/feature-checks/test-all.c | 143 ----------------- 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 | 9 -- 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, 785 insertions(+), 785 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..c6f44894d4a1 --- /dev/null +++ b/tools/build/Makefile.feature @@ -0,0 +1,169 @@ +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 \ + zlib + +FEATURE_DISPLAY = \ + dwarf \ + glibc \ + gtk2 \ + libaudit \ + libbfd \ + libelf \ + libnuma \ + libperl \ + libpython \ + libslang \ + libunwind \ + libdw-dwarf-unwind \ + 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_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_display_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..09b335b98842 --- /dev/null +++ b/tools/build/feature/.gitignore @@ -0,0 +1,3 @@ +*.d +*.bin +*.output diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile new file mode 100644 index 000000000000..0d694a94cda2 --- /dev/null +++ b/tools/build/feature/Makefile @@ -0,0 +1,160 @@ + +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) + BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1 + +############################### + +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 + +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 $(FILES:.bin=.make.output) diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c new file mode 100644 index 000000000000..a61c20456705 --- /dev/null +++ b/tools/build/feature/test-all.c @@ -0,0 +1,143 @@ +/* + * 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 + +# 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[]) +{ + 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(); + + 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 +#include + +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 + +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 +#include +#include + +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 + +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 + +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 +#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 +#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 + +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 + +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..9cf802a04885 --- /dev/null +++ b/tools/build/feature/test-libbabeltrace.c @@ -0,0 +1,9 @@ + +#include +#include + +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 + +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 + +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 + +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 + +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 + +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 +#include + +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 +#include + +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 + +#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 + +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 + +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 +#include + +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 +#include + +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 +#include +#include + +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 + +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 + +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 + +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 + +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 01278429965a..6d1918a6b83b 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 ea83a92630c0..000000000000 --- a/tools/perf/config/Makefile.feature +++ /dev/null @@ -1,169 +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 \ - zlib - -FEATURE_DISPLAY = \ - dwarf \ - glibc \ - gtk2 \ - libaudit \ - libbfd \ - libelf \ - libnuma \ - libperl \ - libpython \ - libslang \ - libunwind \ - libdw-dwarf-unwind \ - 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_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_display_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 09b335b98842..000000000000 --- a/tools/perf/config/feature-checks/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.d -*.bin -*.output diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile deleted file mode 100644 index 0d694a94cda2..000000000000 --- a/tools/perf/config/feature-checks/Makefile +++ /dev/null @@ -1,160 +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) - BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1 - -############################### - -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 - -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 $(FILES:.bin=.make.output) 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 a61c20456705..000000000000 --- a/tools/perf/config/feature-checks/test-all.c +++ /dev/null @@ -1,143 +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 - -# 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[]) -{ - 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(); - - 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 -#include - -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 - -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 -#include -#include - -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 - -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 - -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 -#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 -#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 - -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 - -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 9cf802a04885..000000000000 --- a/tools/perf/config/feature-checks/test-libbabeltrace.c +++ /dev/null @@ -1,9 +0,0 @@ - -#include -#include - -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 - -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 - -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 - -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 - -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 - -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 -#include - -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 -#include - -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 - -#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 - -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 - -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 -#include - -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 -#include - -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 -#include -#include - -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 - -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 - -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 - -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 - -int main(void) -{ - z_stream zs; - - inflateInit(&zs); - return 0; -} -- 1.9.3