Add CFLAGS and LDFLAGS for each feature to be checked during the build. This allows to pass particular flags and parameters to the feature checks compilation.
Use the per-feature check flags for the unwinding feature in order to correctly compile the libunwind and libunwind-debug-frame feature checks.
This change set simplifies the flags passing mechanism between the Makefiles in config/Makefile and config/feature-checks; this could be farther optimized by moving the compilation flags to the per-feature check flags for all features to be checked.
Tested on x86_64, ARMv7 and ARMv8 with and without LIBUNWIND_DIR set in 'make -C tools/perf'
Jean Pihet (2): perf: add per-feature check flags perf: unwinding: use the per-feature check flags
tools/perf/config/Makefile | 48 +++++++++++++++++-------------- tools/perf/config/feature-checks/Makefile | 8 +++--- 2 files changed, 30 insertions(+), 26 deletions(-)
Add CFLAGS and LDFLAGS for each feature to be checked. This allows to pass flags and parameters to the feature checks compilation. Also simplifies the feature check makefile, to come in a subsequent patch.
Signed-off-by: Jean Pihet jean.pihet@linaro.org --- tools/perf/config/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index f7d11a8..c551495 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -102,7 +102,7 @@ endif
feature_check = $(eval $(feature_check_code)) define feature_check_code - feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/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))" LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) endef
feature_set = $(eval $(feature_set_code))
Use the per-feature check flags for the unwinding feature in order to correctly compile the libunwind and libunwind-debug-frame feature checks.
Tested on x86_64, ARMv7 and ARMv8 with and without LIBUNWIND_DIR set in 'make -C tools/perf'
Signed-off-by: Jean Pihet jean.pihet@linaro.org Cc: Jiri Olsa jolsa@redhat.com --- tools/perf/config/Makefile | 48 +++++++++++++++++-------------- tools/perf/config/feature-checks/Makefile | 8 +++--- 2 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index c551495..cd62286 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -36,6 +36,26 @@ ifeq ($(ARCH),arm) LIBUNWIND_LIBS = -lunwind -lunwind-arm endif
+ifeq ($(LIBUNWIND_LIBS),) + NO_LIBUNWIND := 1 +else + # + # For linking with debug library, run like: + # + # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ + # + ifdef LIBUNWIND_DIR + LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include + LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib + endif + LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS) + + FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) + FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) + FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS) + FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) +endif + ifeq ($(NO_PERF_REGS),0) CFLAGS += -DHAVE_PERF_REGS_SUPPORT endif @@ -102,7 +122,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))" LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/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 config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0) endef
feature_set = $(eval $(feature_set_code)) @@ -310,21 +330,7 @@ ifndef NO_LIBELF endif # NO_DWARF endif # NO_LIBELF
-ifeq ($(LIBUNWIND_LIBS),) - NO_LIBUNWIND := 1 -endif - ifndef NO_LIBUNWIND - # - # For linking with debug library, run like: - # - # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ - # - ifdef LIBUNWIND_DIR - LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include - LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib - endif - ifneq ($(feature-libunwind), 1) msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1); NO_LIBUNWIND := 1 @@ -339,14 +345,12 @@ ifndef NO_LIBUNWIND # non-ARM has no dwarf_find_debug_frame() function: CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME endif - endif -endif
-ifndef NO_LIBUNWIND - CFLAGS += -DHAVE_LIBUNWIND_SUPPORT - EXTLIBS += $(LIBUNWIND_LIBS) - CFLAGS += $(LIBUNWIND_CFLAGS) - LDFLAGS += $(LIBUNWIND_LDFLAGS) + CFLAGS += -DHAVE_LIBUNWIND_SUPPORT + EXTLIBS += $(LIBUNWIND_LIBS) + CFLAGS += $(LIBUNWIND_CFLAGS) + LDFLAGS += $(LIBUNWIND_LDFLAGS) + endif # ifneq ($(feature-libunwind), 1) endif
ifndef NO_LIBAUDIT diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile index 87e7900..0bf3af7 100644 --- a/tools/perf/config/feature-checks/Makefile +++ b/tools/perf/config/feature-checks/Makefile @@ -33,12 +33,12 @@ CC := $(CC) -MD
all: $(FILES)
-BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c +BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $@.c $(LDFLAGS)
###############################
test-all: - $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl + $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
test-hello: $(BUILD) @@ -74,10 +74,10 @@ test-libnuma: $(BUILD) -lnuma
test-libunwind: - $(BUILD) $(LIBUNWIND_LIBS) -lelf + $(BUILD) -lelf
test-libunwind-debug-frame: - $(BUILD) $(LIBUNWIND_LIBS) -lelf + $(BUILD) -lelf
test-libaudit: $(BUILD) -laudit
On Sat, Dec 07, 2013 at 11:17:41AM +0100, Jean Pihet wrote:
Use the per-feature check flags for the unwinding feature in order to correctly compile the libunwind and libunwind-debug-frame feature checks.
Tested on x86_64, ARMv7 and ARMv8 with and without LIBUNWIND_DIR set in 'make -C tools/perf'
Signed-off-by: Jean Pihet jean.pihet@linaro.org Cc: Jiri Olsa jolsa@redhat.com
SNIP
+BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $@.c $(LDFLAGS) ############################### test-all:
- $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
- $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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
hum, the test-all build command should have every possible flags we use, right? including LIBUNWIND_CFLAGS, LIBUNWIND_LDFLAGS
also, this patch no longer applies on acme's perf/core
jirka
Hi Jiri,
On 9 December 2013 18:17, Jiri Olsa jolsa@redhat.com wrote:
On Sat, Dec 07, 2013 at 11:17:41AM +0100, Jean Pihet wrote:
Use the per-feature check flags for the unwinding feature in order to correctly compile the libunwind and libunwind-debug-frame feature checks.
Tested on x86_64, ARMv7 and ARMv8 with and without LIBUNWIND_DIR set in 'make -C tools/perf'
Signed-off-by: Jean Pihet jean.pihet@linaro.org Cc: Jiri Olsa jolsa@redhat.com
SNIP
+BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $@.c $(LDFLAGS)
###############################
test-all:
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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
hum, the test-all build command should have every possible flags we use, right? including LIBUNWIND_CFLAGS, LIBUNWIND_LDFLAGS
Oh yes you are right. I am overlooked the test-all feature (which never builds on my modest embedded systems). $(LIBUNWIND_LIBS) should be replaced by $(LIBUNWIND_CFLAGS) $(LIBUNWIND_LDFLAGS), is that a reasonable approach?
also, this patch no longer applies on acme's perf/core
I am using a recent mainline (3.12-rc2).
Let me correct the patch on acme's perf/core. Is that OK?
Thx for reviewing! Jean
jirka
On Mon, Dec 09, 2013 at 07:02:02PM +0100, Jean Pihet wrote:
Hi Jiri,
On 9 December 2013 18:17, Jiri Olsa jolsa@redhat.com wrote:
On Sat, Dec 07, 2013 at 11:17:41AM +0100, Jean Pihet wrote:
Use the per-feature check flags for the unwinding feature in order to correctly compile the libunwind and libunwind-debug-frame feature checks.
Tested on x86_64, ARMv7 and ARMv8 with and without LIBUNWIND_DIR set in 'make -C tools/perf'
Signed-off-by: Jean Pihet jean.pihet@linaro.org Cc: Jiri Olsa jolsa@redhat.com
SNIP
+BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $@.c $(LDFLAGS)
###############################
test-all:
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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
hum, the test-all build command should have every possible flags we use, right? including LIBUNWIND_CFLAGS, LIBUNWIND_LDFLAGS
Oh yes you are right. I am overlooked the test-all feature (which never builds on my modest embedded systems). $(LIBUNWIND_LIBS) should be replaced by $(LIBUNWIND_CFLAGS) $(LIBUNWIND_LDFLAGS), is that a reasonable approach?
also, this patch no longer applies on acme's perf/core
I am using a recent mainline (3.12-rc2).
Let me correct the patch on acme's perf/core. Is that OK?
yep, thats the best practise
jirka
On Mon, Dec 09, 2013 at 07:02:02PM +0100, Jean Pihet wrote:
Hi Jiri,
On 9 December 2013 18:17, Jiri Olsa jolsa@redhat.com wrote:
On Sat, Dec 07, 2013 at 11:17:41AM +0100, Jean Pihet wrote:
Use the per-feature check flags for the unwinding feature in order to correctly compile the libunwind and libunwind-debug-frame feature checks.
Tested on x86_64, ARMv7 and ARMv8 with and without LIBUNWIND_DIR set in 'make -C tools/perf'
Signed-off-by: Jean Pihet jean.pihet@linaro.org Cc: Jiri Olsa jolsa@redhat.com
SNIP
+BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $@.c $(LDFLAGS)
###############################
test-all:
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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
hum, the test-all build command should have every possible flags we use, right? including LIBUNWIND_CFLAGS, LIBUNWIND_LDFLAGS
Oh yes you are right. I am overlooked the test-all feature (which never builds on my modest embedded systems). $(LIBUNWIND_LIBS) should be replaced by $(LIBUNWIND_CFLAGS) $(LIBUNWIND_LDFLAGS), is that a reasonable approach?
hum, I'm just dealing with same issue for new libdw feature.. ;-)
I was wondering we could just setup: FEATURE_CHECK_CFLAGS-all FEATURE_CHECK_LDFLAGS-all
automatically from all defined FEATURE_CHECK_(C|LD)FLAGS-* just a thought.. haven't tried it yet
jirka
Hi Jiri,
On 10 December 2013 10:57, Jiri Olsa jolsa@redhat.com wrote:
On Mon, Dec 09, 2013 at 07:02:02PM +0100, Jean Pihet wrote:
Hi Jiri,
On 9 December 2013 18:17, Jiri Olsa jolsa@redhat.com wrote:
On Sat, Dec 07, 2013 at 11:17:41AM +0100, Jean Pihet wrote:
Use the per-feature check flags for the unwinding feature in order to correctly compile the libunwind and libunwind-debug-frame feature checks.
Tested on x86_64, ARMv7 and ARMv8 with and without LIBUNWIND_DIR set in 'make -C tools/perf'
Signed-off-by: Jean Pihet jean.pihet@linaro.org Cc: Jiri Olsa jolsa@redhat.com
SNIP
+BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $@.c $(LDFLAGS)
###############################
test-all:
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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
hum, the test-all build command should have every possible flags we use, right? including LIBUNWIND_CFLAGS, LIBUNWIND_LDFLAGS
Oh yes you are right. I am overlooked the test-all feature (which never builds on my modest embedded systems). $(LIBUNWIND_LIBS) should be replaced by $(LIBUNWIND_CFLAGS) $(LIBUNWIND_LDFLAGS), is that a reasonable approach?
hum, I'm just dealing with same issue for new libdw feature.. ;-)
I was wondering we could just setup: FEATURE_CHECK_CFLAGS-all FEATURE_CHECK_LDFLAGS-all
automatically from all defined FEATURE_CHECK_(C|LD)FLAGS-* just a thought.. haven't tried it yet
Yes that is the idea. The per-feature flags are designed for that purpose. For now I have the fix for libunwind only, cf. here below. All features should use the flags. There are complex cases though (e.g perl flags in config/Makefile andconfig/feature-checks)...
My plan is to submit the ix for libunwind first and if ok care about the other features. Is that OK?
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index d24b4bd..65bc78e 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -56,10 +56,14 @@ else endif LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
+ # Set per-feature check compilation flags FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS) FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) + # and the flags for the test-all case + FEATURE_CHECK_CFLAGS-all += $(LIBUNWIND_CFLAGS) + FEATURE_CHECK_LDFLAGS-all += $(LIBUNWIND_LDFLAGS) endif
ifeq ($(NO_PERF_REGS),0)
jirka
Thx, Jean
On Tue, Dec 10, 2013 at 11:05:04AM +0100, Jean Pihet wrote:
Hi Jiri,
On 10 December 2013 10:57, Jiri Olsa jolsa@redhat.com wrote:
On Mon, Dec 09, 2013 at 07:02:02PM +0100, Jean Pihet wrote:
Hi Jiri,
On 9 December 2013 18:17, Jiri Olsa jolsa@redhat.com wrote:
On Sat, Dec 07, 2013 at 11:17:41AM +0100, Jean Pihet wrote:
Use the per-feature check flags for the unwinding feature in order to correctly compile the libunwind and libunwind-debug-frame feature checks.
Tested on x86_64, ARMv7 and ARMv8 with and without LIBUNWIND_DIR set in 'make -C tools/perf'
Signed-off-by: Jean Pihet jean.pihet@linaro.org Cc: Jiri Olsa jolsa@redhat.com
SNIP
+BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $@.c $(LDFLAGS)
###############################
test-all:
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
$(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -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
hum, the test-all build command should have every possible flags we use, right? including LIBUNWIND_CFLAGS, LIBUNWIND_LDFLAGS
Oh yes you are right. I am overlooked the test-all feature (which never builds on my modest embedded systems). $(LIBUNWIND_LIBS) should be replaced by $(LIBUNWIND_CFLAGS) $(LIBUNWIND_LDFLAGS), is that a reasonable approach?
hum, I'm just dealing with same issue for new libdw feature.. ;-)
I was wondering we could just setup: FEATURE_CHECK_CFLAGS-all FEATURE_CHECK_LDFLAGS-all
automatically from all defined FEATURE_CHECK_(C|LD)FLAGS-* just a thought.. haven't tried it yet
Yes that is the idea. The per-feature flags are designed for that purpose. For now I have the fix for libunwind only, cf. here below. All features should use the flags. There are complex cases though (e.g perl flags in config/Makefile andconfig/feature-checks)...
My plan is to submit the ix for libunwind first and if ok care about the other features. Is that OK?
sounds good, thanks
jirka
linaro-kernel@lists.linaro.org