• Roberto Sassu's avatar
    tools build: Fix feature detection output due to eval expansion · 709533e5
    Roberto Sassu authored
    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: 0afc5cad ("perf build: Separate feature make support into config/Makefile.feature")
    Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
    Tested-by: default avatarArnaldo 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    709533e5
Makefile.config 41.1 KB