Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <roberto.sassu@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: bpf@vger.kernel.org
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/r/20220818120957.319995-1-roberto.sassu@huaweicloud.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Roberto Sassu and committed by
Arnaldo Carvalho de Melo
709533e5 8012243e

+16 -18
+8 -11
tools/build/Makefile.feature
··· 177 177 # 178 178 # Print the result of the feature test: 179 179 # 180 - feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG)) 180 + feature_print_status = $(eval $(feature_print_status_code)) 181 181 182 182 define feature_print_status_code 183 183 ifeq ($(feature-$(1)), 1) ··· 187 187 endif 188 188 endef 189 189 190 - feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG)) 190 + feature_print_text = $(eval $(feature_print_text_code)) 191 191 define feature_print_text_code 192 192 MSG = $(shell printf '...%30s: %s' $(1) $(2)) 193 193 endef ··· 247 247 feature_display_entries = $(eval $(feature_display_entries_code)) 248 248 define feature_display_entries_code 249 249 ifeq ($(feature_display),1) 250 - $(info ) 251 - $(info Auto-detecting system features:) 252 - $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),)) 253 - ifneq ($(feature_verbose),1) 254 - $(info ) 255 - endif 250 + $$(info ) 251 + $$(info Auto-detecting system features:) 252 + $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),) $$(info $(MSG))) 256 253 endif 257 254 258 255 ifeq ($(feature_verbose),1) 259 - TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS)) 260 - $(foreach feat,$(TMP),$(call feature_print_status,$(feat),)) 261 - $(info ) 256 + $(eval TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))) 257 + $(foreach feat,$(TMP),$(call feature_print_status,$(feat),) $$(info $(MSG))) 262 258 endif 263 259 endef 264 260 265 261 ifeq ($(FEATURE_DISPLAY_DEFERRED),) 266 262 $(call feature_display_entries) 263 + $(info ) 267 264 endif
+8 -7
tools/perf/Makefile.config
··· 1304 1304 MSG = $(shell printf '...%30s: %s' $(1) $($(1))) 1305 1305 endef 1306 1306 1307 + ifeq ($(feature_display),1) 1308 + $(call feature_display_entries) 1309 + endif 1310 + 1307 1311 ifeq ($(VF),1) 1308 1312 # Display EXTRA features which are detected manualy 1309 1313 # from here with feature_check call and thus cannot 1310 1314 # be partof global state output. 1311 - $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),)) 1315 + $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),) $(info $(MSG))) 1312 1316 $(call print_var,prefix) 1313 1317 $(call print_var,bindir) 1314 1318 $(call print_var,libdir) ··· 1322 1318 $(call print_var,JDIR) 1323 1319 1324 1320 ifeq ($(dwarf-post-unwind),1) 1325 - $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) 1321 + $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG)) 1326 1322 endif 1327 - $(info ) 1328 1323 endif 1324 + 1325 + $(info ) 1329 1326 1330 1327 $(call detected_var,bindir_SQ) 1331 1328 $(call detected_var,PYTHON_WORD) ··· 1357 1352 # tests. 1358 1353 $(shell rm -f $(FEATURE_DUMP_FILENAME)) 1359 1354 $(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME))) 1360 - 1361 - ifeq ($(feature_display),1) 1362 - $(call feature_display_entries) 1363 - endif