From: Ingo Molnar <mingo@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH 31/50] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target
Date: Mon, 7 Oct 2013 13:56:24 +0200 [thread overview]
Message-ID: <1381147003-2574-32-git-send-email-mingo@kernel.org> (raw)
In-Reply-To: <1381147003-2574-1-git-send-email-mingo@kernel.org>
Concatenate all feature checks into test-all.c.
This can be built and checked faster than all the individual tests.
If test-all fails then we still check all the individual features, so
this is a pure speedup, it should have no effects on functionality.
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/n/tip-5hlcb2qorzwfwrWTjiygjjih@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/perf/config/Makefile | 48 ++++++++++--
tools/perf/config/feature-checks/Makefile | 3 +
tools/perf/config/feature-checks/test-all.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 240 insertions(+), 7 deletions(-)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 1b2a46b..9a27aa9 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -89,17 +89,21 @@ CFLAGS += -std=gnu99
EXTLIBS = -lelf -lpthread -lrt -lm -ldl
-feature_check = $(eval $(feature_check_code)); $(info CHK: config/feature-checks/test-$(1))
+feature_check = $(eval $(feature_check_code))
define feature_check_code
- feature-$(2) := $(shell make -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+ feature-$(1) := $(shell $(MAKE) -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+endef
+
+feature_set = $(eval $(feature_set_code))
+define feature_set_code
+ feature-$(1) := 1
endef
#
# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
#
-$(info Testing features:)
-$(shell make -i -j -C config/feature-checks >/dev/null 2>&1)
-$(info done)
+$(info )
+$(info Auto-detecting system features:)
FEATURE_TESTS = \
hello \
@@ -126,9 +130,38 @@ FEATURE_TESTS = \
backtrace \
libnuma
-$(foreach test,$(FEATURE_TESTS),$(call feature_check,$(test),$(test)))
+#
+# Special fast-path for the 'all features are available' case:
+#
+$(call feature_check,all)
+
+ifeq ($(feature-all), 1)
+ $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
+else
+ $(shell $(MAKE) -i -j -C config/feature-checks >/dev/null 2>&1)
+ $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
+endif
+
+feature_print = $(eval $(feature_print_code))
+
+#
+# Print the result of the feature test:
+#
+define feature_print_code
+ ifeq ($(feature-$(1)), 1)
+ MSG := $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
+ else
+ MSG := $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
+ endif
+ $(info $(MSG))
+endef
+
+$(foreach feat,$(FEATURE_TESTS) DUMMY,$(call feature_print,$(feat)))
+
+# newline at the end of the feature printouts:
+$(info )
-ifeq ($(stackprotector-all), 1)
+ifeq ($(feature-stackprotector-all), 1)
CFLAGS += -fstack-protector-all
endif
@@ -167,6 +200,7 @@ CFLAGS += -I$(LIB_INCLUDE)
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
ifndef NO_BIONIC
+ $(feature_check,bionic)
ifeq ($(feature-bionic), 1)
BIONIC := 1
EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index c65bdac..b031669 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -32,6 +32,9 @@ BUILD = $(CC) -o $(OUTPUT)$@ $@.c
###############################
+test-all:
+ $(BUILD) -Werror -fstack-protector -Wvolatile-register-var -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lunwind -lunwind-x86_64 -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='perf' -DPACKAGE=perf -lbfd -ldl
+
test-hello:
$(BUILD)
diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
new file mode 100644
index 0000000..9f7c4b1
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -0,0 +1,196 @@
+
+#pragma GCC diagnostic ignored "-Wstrict-prototypes"
+
+#include <Python.h>
+
+#include <EXTERN.h>
+#include <perl.h>
+
+#include <stdio.h>
+#include <libelf.h>
+#include <gnu/libc-version.h>
+#include <dwarf.h>
+#include <elfutils/libdw.h>
+#include <elfutils/version.h>
+#include <libelf.h>
+#include <libunwind.h>
+#include <stdlib.h>
+#include <libaudit.h>
+#include <slang.h>
+#include <gtk/gtk.h>
+#include <bfd.h>
+#include <stdio.h>
+#include <execinfo.h>
+#include <stdio.h>
+#include <numa.h>
+#include <numaif.h>
+
+#pragma GCC diagnostic error "-Wstrict-prototypes"
+
+int main1(void)
+{
+ return puts("hi");
+}
+
+int main2(void)
+{
+ return puts("hi");
+}
+
+int main3(void)
+{
+ return puts("hi");
+}
+
+int main4(void)
+{
+ Elf *elf = elf_begin(0, ELF_C_READ, 0);
+ return (long)elf;
+}
+#
+int main5(void)
+{
+ Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
+ return (long)elf;
+}
+
+int main6(void)
+{
+ const char *version = gnu_get_libc_version();
+ return (long)version;
+}
+
+int main7(void)
+{
+ Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
+ return (long)dbg;
+}
+
+int main8(void)
+{
+ size_t dst;
+ return elf_getphdrnum(0, &dst);
+}
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+int main9(void)
+{
+ unw_addr_space_t addr_space;
+ addr_space = unw_create_addr_space(NULL, 0);
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+ return 0;
+}
+
+int main10(void)
+{
+ printf("error message: %s\n", audit_errno_to_name(0));
+ return audit_open();
+}
+
+int main11(void)
+{
+ return SLsmg_init_smg();
+}
+
+int main12(int argc, char *argv[])
+{
+ gtk_init(&argc, &argv);
+
+ return 0;
+}
+
+int main13(void)
+{
+ gtk_info_bar_new();
+
+ return 0;
+}
+
+int main14(void)
+{
+ perl_alloc();
+
+ return 0;
+}
+
+int main15(void)
+{
+ Py_Initialize();
+ return 0;
+}
+
+#if PY_VERSION_HEX >= 0x03000000
+ #error
+#endif
+
+int main16(void)
+{
+ return 0;
+}
+
+int main17(void)
+{
+ bfd_demangle(0, 0, 0);
+ return 0;
+}
+
+void exit_function(int x, void *y)
+{
+}
+
+int main18(void)
+{
+ return on_exit(exit_function, NULL);
+}
+
+int main19(void)
+{
+ void *backtrace_fns[1];
+ size_t entries;
+
+ entries = backtrace(backtrace_fns, 1);
+ backtrace_symbols(backtrace_fns, entries);
+
+ return 0;
+}
+
+int main20(void)
+{
+ numa_available();
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ main1();
+ main2();
+ main3();
+ main4();
+ main5();
+ main6();
+ main7();
+ main8();
+ main9();
+ main10();
+ main11();
+ main12(argc, argv);
+ main13();
+ main14();
+ main15();
+ main16();
+ main17();
+ main18();
+ main19();
+ main20();
+
+ return 0;
+}
--
1.7.11.7
next prev parent reply other threads:[~2013-10-07 12:04 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-07 11:55 [RFC PATCH 00/50] tools/perf: Speed up the build system Ingo Molnar
2013-10-07 11:55 ` [PATCH 01/50] tools/perf: Standardize feature support define names to: HAVE_{FEATURE}_SUPPORT Ingo Molnar
2013-10-07 11:55 ` [PATCH 02/50] tools/perf/build: Add feature check core code Ingo Molnar
2013-10-07 11:55 ` [PATCH 03/50] tools/perf/build: Add 'autodep' functionality, generate feature test dependencies automatically Ingo Molnar
2013-10-07 11:55 ` [PATCH 04/50] tools/perf/build: Split out feature check: 'libnuma' Ingo Molnar
2013-10-07 11:55 ` [PATCH 05/50] tools/perf/build: Split out feature check: 'stackprotector-all' Ingo Molnar
2013-10-07 11:55 ` [PATCH 06/50] tools/perf/build: Split out feature check: 'stackprotector' Ingo Molnar
2013-10-07 11:56 ` [PATCH 07/50] tools/perf/build: Split out feature check: 'volatile-register-var' Ingo Molnar
2013-10-07 11:56 ` [PATCH 08/50] tools/perf/build: Split out feature check: 'fortify-source' Ingo Molnar
2013-10-07 11:56 ` [PATCH 09/50] tools/perf/build: Split out feature check: 'bionic' Ingo Molnar
2013-10-07 11:56 ` [PATCH 10/50] tools/perf/build: Clean up the libelf logic in config/Makefile Ingo Molnar
2013-10-07 11:56 ` [PATCH 11/50] tools/perf/build: Split out feature check: 'libelf' Ingo Molnar
2013-10-07 11:56 ` [PATCH 12/50] tools/perf/build: Split out feature check: 'glibc' Ingo Molnar
2013-10-07 11:56 ` [PATCH 13/50] tools/perf/build: Split out feature check: 'dwarf' Ingo Molnar
2013-10-07 11:56 ` [PATCH 14/50] tools/perf/build: Clean up the mmap logic in config/Makefile Ingo Molnar
2013-10-07 11:56 ` [PATCH 15/50] tools/perf/build: Split out feature check: 'libelf-mmap' Ingo Molnar
2013-10-07 11:56 ` [PATCH 16/50] tools/perf/build: Split out feature check: 'libelf-getphdrnum' Ingo Molnar
2013-10-07 11:56 ` [PATCH 17/50] tools/perf/build: Clean up the libunwind logic in config/Makefile Ingo Molnar
2013-10-07 11:56 ` [PATCH 18/50] tools/perf/build: Split out feature check: 'libunwind' Ingo Molnar
2013-10-07 11:56 ` [PATCH 19/50] tools/perf/build: Split out feature check: 'libaudit' Ingo Molnar
2013-10-07 21:00 ` Jiri Olsa
2013-10-08 8:19 ` Ingo Molnar
2013-10-07 11:56 ` [PATCH 20/50] tools/perf/build: Split out feature check: 'libslang' Ingo Molnar
2013-10-07 14:52 ` David Ahern
2013-10-08 8:06 ` Ingo Molnar
2013-10-07 11:56 ` [PATCH 21/50] tools/perf/build: Split out feature check: 'gtk2' Ingo Molnar
2013-10-07 11:56 ` [PATCH 22/50] tools/perf/build: Split out feature check: 'gtk2-infobar' Ingo Molnar
2013-10-07 11:56 ` [PATCH 23/50] tools/perf/build: Split out feature check: 'libperl' Ingo Molnar
2013-10-07 11:56 ` [PATCH 24/50] tools/perf/build: Split out feature check: 'libpython' Ingo Molnar
2013-10-07 11:56 ` [PATCH 25/50] tools/perf/build: Split out feature check: 'libpython-version' Ingo Molnar
2013-10-07 11:56 ` [PATCH 26/50] tools/perf/build: Split out feature check: 'libbfd' Ingo Molnar
2013-10-07 15:11 ` David Ahern
2013-10-07 21:18 ` Jiri Olsa
2013-10-08 8:15 ` Ingo Molnar
2013-10-07 11:56 ` [PATCH 27/50] tools/perf/build: Split out feature check: 'on-exit' Ingo Molnar
2013-10-07 11:56 ` [PATCH 28/50] tools/perf/build: Split out feature check: 'backtrace' Ingo Molnar
2013-10-07 11:56 ` [PATCH 29/50] tools/perf: Clean up util/include/linux/compiler.h Ingo Molnar
2013-10-07 11:56 ` [PATCH 30/50] tools/perf: Turn strlcpy() into a __weak function Ingo Molnar
2013-10-07 11:56 ` Ingo Molnar [this message]
2013-10-07 21:27 ` [PATCH 31/50] tools/perf/build: Speed up auto-detection of features by adding a 'test-all' target Jiri Olsa
2013-10-08 8:23 ` Ingo Molnar
2013-10-07 21:59 ` Jiri Olsa
2013-10-07 11:56 ` [PATCH 32/50] tools/perf/build: Speed up git-version test on re-make Ingo Molnar
2013-10-07 11:56 ` [PATCH 33/50] tools/perf/build: Speed up the final link Ingo Molnar
2013-10-07 11:56 ` [PATCH 34/50] tools/perf: Fix double/triple-build of the feature detection logic during 'make install' et al Ingo Molnar
2013-10-07 11:56 ` [PATCH 35/50] tools/perf/build: Invoke feature-checks 'clean' target from the main Makefile Ingo Molnar
2013-10-07 11:56 ` [PATCH 36/50] tools/perf/build: Speed up auto-detection Ingo Molnar
2013-10-07 21:57 ` Jiri Olsa
2013-10-08 8:36 ` Ingo Molnar
2013-10-07 11:56 ` [PATCH 37/50] tools/perf/build: Improve printout-of auto-detected features Ingo Molnar
2013-10-07 22:12 ` Jiri Olsa
2013-10-08 8:46 ` Ingo Molnar
2013-10-08 15:51 ` Jiri Olsa
2013-10-09 6:42 ` [PATCH 53/52] tools/perf/build: Clean up feature_print_code() Ingo Molnar
2013-10-09 8:38 ` Jiri Olsa
2013-10-15 5:20 ` [tip:perf/core] " tip-bot for Jiri Olsa
2013-10-07 11:56 ` [PATCH 38/50] tools/perf/build: Automatically build in parallel, based on number of CPUs in the system Ingo Molnar
2013-10-07 11:56 ` [PATCH 39/50] tools/perf/build: Flip Makefile.parallel and Makefile.perf Ingo Molnar
2013-10-07 11:56 ` [PATCH 40/50] tools/perf/build: Standardize the various messages output by parallel make Ingo Molnar
2013-10-07 11:56 ` [PATCH 41/50] tools/perf/build: Split out feature checks: 'liberty', 'liberty-z', 'cplus-demangle' Ingo Molnar
2013-10-07 11:56 ` [PATCH 42/50] tools/perf/build: Remove unused config/feature-tests.mak Ingo Molnar
2013-10-07 11:56 ` [PATCH 43/50] tools/perf/build: Clean up various testcases Ingo Molnar
2013-10-07 11:56 ` [PATCH 44/50] tools/perf/build: Collapse the test-all.c testcase Ingo Molnar
2013-10-07 22:25 ` Jiri Olsa
2013-10-08 8:47 ` Ingo Molnar
2013-10-07 11:56 ` [PATCH 45/50] tools/perf/build: Pass through all targets to Makefile.perf Ingo Molnar
2013-10-07 11:56 ` [PATCH 46/50] tools/perf/build: Make sure autodep feature binaries honor the O= setting Ingo Molnar
2013-10-07 11:56 ` [PATCH 47/50] tools/perf/build: Exclude MAKEFLAGS from nested invocation Ingo Molnar
2013-10-07 11:56 ` [PATCH 48/50] tools/perf/build: Fix non-canonical directory names in O= Ingo Molnar
2013-10-07 11:56 ` [PATCH 49/50] tools/perf/build: Fix O=/some/dir perf.o type of targets Ingo Molnar
2013-10-07 22:33 ` Jiri Olsa
2013-10-08 8:49 ` Ingo Molnar
2013-10-07 11:56 ` [PATCH 50/50] tools/perf/build: Harmonize the style of the feature testcases Ingo Molnar
2013-10-07 13:52 ` [RFC PATCH 00/50] tools/perf: Speed up the build system David Ahern
2013-10-07 14:11 ` Ingo Molnar
2013-10-07 15:35 ` David Ahern
2013-10-07 15:51 ` [PATCH] tools/perf/build: Pass through LDFLAGS to feature tests Ingo Molnar
2013-10-07 16:07 ` David Ahern
2013-10-15 5:20 ` [tip:perf/core] " tip-bot for Ingo Molnar
2013-10-07 16:41 ` [RFC PATCH 00/50] tools/perf: Speed up the build system Ingo Molnar
2013-10-08 1:41 ` David Ahern
2013-10-08 12:48 ` Ingo Molnar
2013-10-07 20:15 ` Andi Kleen
2013-10-08 9:02 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1381147003-2574-32-git-send-email-mingo@kernel.org \
--to=mingo@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).