From 709533e51b166d5a520589a03f0044ed304b33bd Mon Sep 17 00:00:00 2001 From: Roberto Sassu Date: Thu, 18 Aug 2022 14:09:55 +0200 Subject: tools build: Fix feature detection output due to eval expansion As the first eval expansion is used only to generate Makefile statements, messages should not be displayed at this stage, as for example conditional expressions are not evaluated. It can be seen for example in the output of feature detection for bpftool, where the number of detected features does not change, despite turning on the verbose mode (VF = 1) and there are additional features to display. Fix this issue by escaping the $ before $(info) statements, to ensure that messages are printed only when the function containing them is actually executed, and not when it is expanded. In addition, move the $(info) statement out of feature_print_status, due to the fact that is called both inside and outside an eval context, and place it to the caller so that the $ can be escaped when necessary. For symmetry, move the $(info) statement also out of feature_print_text, and place it to the caller. Force the TMP variable evaluation in verbose mode, to display the features in FEATURE_TESTS that are not in FEATURE_DISPLAY. Reorder perf feature detection messages (first non-verbose, then verbose ones) by moving the call to feature_display_entries earlier, before the VF environment variable check. Also, remove the newline from that function, as perf might display additional messages. Move the newline to perf Makefile, and display another one if displaying the detection result is not deferred as in the case of bpftool. Committer testing: Collecting the output from: $ make VF=1 -C tools/bpf/bpftool/ |& grep "Auto-detecting system features" -A20 $ diff -u before after --- before 2022-08-18 09:59:55.460529231 -0300 +++ after 2022-08-18 10:01:11.182517282 -0300 @@ -4,3 +4,5 @@ ... libbfd-liberty-z: [ on ] ... libcap: [ on ] ... clang-bpf-co-re: [ on ] +... disassembler-four-args: [ on ] +... disassembler-init-styled: [ OFF ] $ Fixes: 0afc5cad387db560 ("perf build: Separate feature make support into config/Makefile.feature") Signed-off-by: Roberto Sassu Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: bpf@vger.kernel.org Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Quentin Monnet Link: https://lore.kernel.org/r/20220818120957.319995-1-roberto.sassu@huaweicloud.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/build/Makefile.feature | 19 ++++++++----------- tools/perf/Makefile.config | 15 ++++++++------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index fc6ce0b2535a..9d3afbc37e15 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -177,7 +177,7 @@ endif # # Print the result of the feature test: # -feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG)) +feature_print_status = $(eval $(feature_print_status_code)) define feature_print_status_code ifeq ($(feature-$(1)), 1) @@ -187,7 +187,7 @@ define feature_print_status_code endif endef -feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG)) +feature_print_text = $(eval $(feature_print_text_code)) define feature_print_text_code MSG = $(shell printf '...%30s: %s' $(1) $(2)) endef @@ -247,21 +247,18 @@ endif feature_display_entries = $(eval $(feature_display_entries_code)) define feature_display_entries_code ifeq ($(feature_display),1) - $(info ) - $(info Auto-detecting system features:) - $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),)) - ifneq ($(feature_verbose),1) - $(info ) - endif + $$(info ) + $$(info Auto-detecting system features:) + $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),) $$(info $(MSG))) endif ifeq ($(feature_verbose),1) - TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS)) - $(foreach feat,$(TMP),$(call feature_print_status,$(feat),)) - $(info ) + $(eval TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))) + $(foreach feat,$(TMP),$(call feature_print_status,$(feat),) $$(info $(MSG))) endif endef ifeq ($(FEATURE_DISPLAY_DEFERRED),) $(call feature_display_entries) + $(info ) endif diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 2171f02daf59..2b4f703a54e0 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -1304,11 +1304,15 @@ define print_var_code MSG = $(shell printf '...%30s: %s' $(1) $($(1))) endef +ifeq ($(feature_display),1) + $(call feature_display_entries) +endif + ifeq ($(VF),1) # Display EXTRA features which are detected manualy # from here with feature_check call and thus cannot # be partof global state output. - $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),)) + $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),) $(info $(MSG))) $(call print_var,prefix) $(call print_var,bindir) $(call print_var,libdir) @@ -1318,11 +1322,12 @@ ifeq ($(VF),1) $(call print_var,JDIR) ifeq ($(dwarf-post-unwind),1) - $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) + $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG)) endif - $(info ) endif +$(info ) + $(call detected_var,bindir_SQ) $(call detected_var,PYTHON_WORD) ifneq ($(OUTPUT),) @@ -1352,7 +1357,3 @@ endif # tests. $(shell rm -f $(FEATURE_DUMP_FILENAME)) $(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME))) - -ifeq ($(feature_display),1) - $(call feature_display_entries) -endif -- cgit v1.2.3-59-g8ed1b