diff mbox series

[3/3] tools/build: Display logical OR of a feature flavors

Message ID 20220818120957.319995-3-roberto.sassu@huaweicloud.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series [1/3] tools/build: Fix feature detection output due to eval expansion | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Roberto Sassu Aug. 18, 2022, 12:09 p.m. UTC
From: Roberto Sassu <roberto.sassu@huawei.com>

Sometimes, features are simply different flavors of another feature, to
properly detect the exact dependencies needed by different Linux
distributions.

For example, libbfd has three flavors: libbfd if the distro does not
require any additional dependency; libbfd-liberty if it requires libiberty;
libbfd-liberty-z if it requires libiberty and libz.

It might not be clear to the user whether a feature has been successfully
detected or not, given that some of its flavors will be set to OFF, others
to ON.

Instead, display only the feature main flavor if not in verbose mode
(VF != 1), and set it to ON if at least one of its flavors has been
successfully detected (logical OR), OFF otherwise. Omit the other flavors.

Accomplish that by declaring a FEATURE_GROUP_MEMBERS-<feature main flavor>
variable, with the list of the other flavors as variable value. For now, do
it just for libbfd.

In verbose mode, of if no group is defined for a feature, show the feature
detection result as before.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
---
 tools/build/Makefile.feature | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

Comments

Arnaldo Carvalho de Melo Aug. 18, 2022, 1:09 p.m. UTC | #1
Em Thu, Aug 18, 2022 at 02:09:57PM +0200, roberto.sassu@huaweicloud.com escreveu:
> From: Roberto Sassu <roberto.sassu@huawei.com>
> 
> Sometimes, features are simply different flavors of another feature, to
> properly detect the exact dependencies needed by different Linux
> distributions.
> 
> For example, libbfd has three flavors: libbfd if the distro does not
> require any additional dependency; libbfd-liberty if it requires libiberty;
> libbfd-liberty-z if it requires libiberty and libz.
> 
> It might not be clear to the user whether a feature has been successfully
> detected or not, given that some of its flavors will be set to OFF, others
> to ON.
> 
> Instead, display only the feature main flavor if not in verbose mode
> (VF != 1), and set it to ON if at least one of its flavors has been
> successfully detected (logical OR), OFF otherwise. Omit the other flavors.
> 
> Accomplish that by declaring a FEATURE_GROUP_MEMBERS-<feature main flavor>
> variable, with the list of the other flavors as variable value. For now, do
> it just for libbfd.
> 
> In verbose mode, of if no group is defined for a feature, show the feature
> detection result as before.

Looks cool, tested and added this to the commit log message here in my
local branch, that will go public after further tests for the other
csets in it:

Committer testing:

Collecting the output from:

  $ make -C tools/bpf/bpftool/ clean
  $ make -C tools/bpf/bpftool/ |& grep "Auto-detecting system features" -A10

  $ diff -u before after
  --- before    2022-08-18 10:06:40.422086966 -0300
  +++ after     2022-08-18 10:07:59.202138282 -0300
  @@ -1,6 +1,4 @@
   Auto-detecting system features:
   ...                                  libbfd: [ on  ]
  -...                          libbfd-liberty: [ on  ]
  -...                        libbfd-liberty-z: [ on  ]
   ...                                  libcap: [ on  ]
   ...                         clang-bpf-co-re: [ on  ]
  $

Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Thanks for working on this!

- Arnaldo
 
> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
> ---
>  tools/build/Makefile.feature | 27 +++++++++++++++++++++++++--
>  1 file changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index 6c809941ff01..57619f240b56 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -137,6 +137,12 @@ FEATURE_DISPLAY ?=              \
>           libaio			\
>           libzstd
>  
> +#
> +# Declare group members of a feature to display the logical OR of the detection
> +# result instead of each member result.
> +#
> +FEATURE_GROUP_MEMBERS-libbfd = libbfd-liberty libbfd-liberty-z
> +
>  # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
>  # If in the future we need per-feature checks/flags for features not
>  # mentioned in this list we need to refactor this ;-).
> @@ -179,8 +185,17 @@ endif
>  #
>  feature_print_status = $(eval $(feature_print_status_code))
>  
> +feature_group = $(eval $(feature_gen_group)) $(GROUP)
> +
> +define feature_gen_group
> +  GROUP := $(1)
> +  ifneq ($(feature_verbose),1)
> +    GROUP += $(FEATURE_GROUP_MEMBERS-$(1))
> +  endif
> +endef
> +
>  define feature_print_status_code
> -  ifeq ($(feature-$(1)), 1)
> +  ifneq (,$(filter 1,$(foreach feat,$(call feature_group,$(feat)),$(feature-$(feat)))))
>      MSG = $(shell printf '...%40s: [ \033[32mon\033[m  ]' $(1))
>    else
>      MSG = $(shell printf '...%40s: [ \033[31mOFF\033[m ]' $(1))
> @@ -244,12 +259,20 @@ ifeq ($(VF),1)
>    feature_verbose := 1
>  endif
>  
> +ifneq ($(feature_verbose),1)
> +  #
> +  # Determine the features to omit from the displayed message, as only the
> +  # logical OR of the detection result will be shown.
> +  #
> +  FEATURE_OMIT := $(foreach feat,$(FEATURE_DISPLAY),$(FEATURE_GROUP_MEMBERS-$(feat)))
> +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),) $$(info $(MSG)))
> +    $(foreach feat,$(filter-out $(FEATURE_OMIT),$(FEATURE_DISPLAY)),$(call feature_print_status,$(feat),) $$(info $(MSG)))
>    endif
>  
>    ifeq ($(feature_verbose),1)
> -- 
> 2.25.1
Roberto Sassu Aug. 18, 2022, 1:25 p.m. UTC | #2
On Thu, 2022-08-18 at 10:09 -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Aug 18, 2022 at 02:09:57PM +0200, 
> roberto.sassu@huaweicloud.com escreveu:
> > From: Roberto Sassu <roberto.sassu@huawei.com>
> > 
> > Sometimes, features are simply different flavors of another
> > feature, to
> > properly detect the exact dependencies needed by different Linux
> > distributions.
> > 
> > For example, libbfd has three flavors: libbfd if the distro does
> > not
> > require any additional dependency; libbfd-liberty if it requires
> > libiberty;
> > libbfd-liberty-z if it requires libiberty and libz.
> > 
> > It might not be clear to the user whether a feature has been
> > successfully
> > detected or not, given that some of its flavors will be set to OFF,
> > others
> > to ON.
> > 
> > Instead, display only the feature main flavor if not in verbose
> > mode
> > (VF != 1), and set it to ON if at least one of its flavors has been
> > successfully detected (logical OR), OFF otherwise. Omit the other
> > flavors.
> > 
> > Accomplish that by declaring a FEATURE_GROUP_MEMBERS-<feature main
> > flavor>
> > variable, with the list of the other flavors as variable value. For
> > now, do
> > it just for libbfd.
> > 
> > In verbose mode, of if no group is defined for a feature, show the
> > feature
> > detection result as before.
> 
> Looks cool, tested and added this to the commit log message here in
> my
> local branch, that will go public after further tests for the other
> csets in it:
> 
> Committer testing:
> 
> Collecting the output from:
> 
>   $ make -C tools/bpf/bpftool/ clean
>   $ make -C tools/bpf/bpftool/ |& grep "Auto-detecting system
> features" -A10
> 
>   $ diff -u before after
>   --- before    2022-08-18 10:06:40.422086966 -0300
>   +++ after     2022-08-18 10:07:59.202138282 -0300
>   @@ -1,6 +1,4 @@
>    Auto-detecting system features:
>    ...                                  libbfd: [ on  ]
>   -...                          libbfd-liberty: [ on  ]
>   -...                        libbfd-liberty-z: [ on  ]
>    ...                                  libcap: [ on  ]
>    ...                         clang-bpf-co-re: [ on  ]
>   $
> 
> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> Thanks for working on this!

Thanks for testing and for adapting/pushing the other patches!

Roberto
Quentin Monnet Aug. 18, 2022, 4:40 p.m. UTC | #3
On 18/08/2022 14:25, Roberto Sassu wrote:
> On Thu, 2022-08-18 at 10:09 -0300, Arnaldo Carvalho de Melo wrote:
>> Em Thu, Aug 18, 2022 at 02:09:57PM +0200, 
>> roberto.sassu@huaweicloud.com escreveu:
>>> From: Roberto Sassu <roberto.sassu@huawei.com>
>>>
>>> Sometimes, features are simply different flavors of another
>>> feature, to
>>> properly detect the exact dependencies needed by different Linux
>>> distributions.
>>>
>>> For example, libbfd has three flavors: libbfd if the distro does
>>> not
>>> require any additional dependency; libbfd-liberty if it requires
>>> libiberty;
>>> libbfd-liberty-z if it requires libiberty and libz.
>>>
>>> It might not be clear to the user whether a feature has been
>>> successfully
>>> detected or not, given that some of its flavors will be set to OFF,
>>> others
>>> to ON.
>>>
>>> Instead, display only the feature main flavor if not in verbose
>>> mode
>>> (VF != 1), and set it to ON if at least one of its flavors has been
>>> successfully detected (logical OR), OFF otherwise. Omit the other
>>> flavors.
>>>
>>> Accomplish that by declaring a FEATURE_GROUP_MEMBERS-<feature main
>>> flavor>
>>> variable, with the list of the other flavors as variable value. For
>>> now, do
>>> it just for libbfd.
>>>
>>> In verbose mode, of if no group is defined for a feature, show the
>>> feature
>>> detection result as before.
>>
>> Looks cool, tested and added this to the commit log message here in
>> my
>> local branch, that will go public after further tests for the other
>> csets in it:
>>
>> Committer testing:
>>
>> Collecting the output from:
>>
>>   $ make -C tools/bpf/bpftool/ clean
>>   $ make -C tools/bpf/bpftool/ |& grep "Auto-detecting system
>> features" -A10
>>
>>   $ diff -u before after
>>   --- before    2022-08-18 10:06:40.422086966 -0300
>>   +++ after     2022-08-18 10:07:59.202138282 -0300
>>   @@ -1,6 +1,4 @@
>>    Auto-detecting system features:
>>    ...                                  libbfd: [ on  ]
>>   -...                          libbfd-liberty: [ on  ]
>>   -...                        libbfd-liberty-z: [ on  ]
>>    ...                                  libcap: [ on  ]
>>    ...                         clang-bpf-co-re: [ on  ]
>>   $
>>
>> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>>
>> Thanks for working on this!
> 
> Thanks for testing and for adapting/pushing the other patches!
> 
> Roberto
> 

Tested locally for bpftool and I also observe "libbfd: [ on  ]" only.
This looks much better, thank you Roberto for following up on this!

Quentin
Arnaldo Carvalho de Melo Aug. 18, 2022, 6:14 p.m. UTC | #4
Em Thu, Aug 18, 2022 at 05:40:04PM +0100, Quentin Monnet escreveu:
> On 18/08/2022 14:25, Roberto Sassu wrote:
> > On Thu, 2022-08-18 at 10:09 -0300, Arnaldo Carvalho de Melo wrote:
> >> Em Thu, Aug 18, 2022 at 02:09:57PM +0200, 
> >> roberto.sassu@huaweicloud.com escreveu:
> >>> From: Roberto Sassu <roberto.sassu@huawei.com>
> >>>
> >>> Sometimes, features are simply different flavors of another
> >>> feature, to
> >>> properly detect the exact dependencies needed by different Linux
> >>> distributions.
> >>>
> >>> For example, libbfd has three flavors: libbfd if the distro does
> >>> not
> >>> require any additional dependency; libbfd-liberty if it requires
> >>> libiberty;
> >>> libbfd-liberty-z if it requires libiberty and libz.
> >>>
> >>> It might not be clear to the user whether a feature has been
> >>> successfully
> >>> detected or not, given that some of its flavors will be set to OFF,
> >>> others
> >>> to ON.
> >>>
> >>> Instead, display only the feature main flavor if not in verbose
> >>> mode
> >>> (VF != 1), and set it to ON if at least one of its flavors has been
> >>> successfully detected (logical OR), OFF otherwise. Omit the other
> >>> flavors.
> >>>
> >>> Accomplish that by declaring a FEATURE_GROUP_MEMBERS-<feature main
> >>> flavor>
> >>> variable, with the list of the other flavors as variable value. For
> >>> now, do
> >>> it just for libbfd.
> >>>
> >>> In verbose mode, of if no group is defined for a feature, show the
> >>> feature
> >>> detection result as before.
> >>
> >> Looks cool, tested and added this to the commit log message here in
> >> my
> >> local branch, that will go public after further tests for the other
> >> csets in it:
> >>
> >> Committer testing:
> >>
> >> Collecting the output from:
> >>
> >>   $ make -C tools/bpf/bpftool/ clean
> >>   $ make -C tools/bpf/bpftool/ |& grep "Auto-detecting system
> >> features" -A10
> >>
> >>   $ diff -u before after
> >>   --- before    2022-08-18 10:06:40.422086966 -0300
> >>   +++ after     2022-08-18 10:07:59.202138282 -0300
> >>   @@ -1,6 +1,4 @@
> >>    Auto-detecting system features:
> >>    ...                                  libbfd: [ on  ]
> >>   -...                          libbfd-liberty: [ on  ]
> >>   -...                        libbfd-liberty-z: [ on  ]
> >>    ...                                  libcap: [ on  ]
> >>    ...                         clang-bpf-co-re: [ on  ]
> >>   $
> >>
> >> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> >>
> >> Thanks for working on this!
> > 
> > Thanks for testing and for adapting/pushing the other patches!
> > 
> > Roberto
> > 
> 
> Tested locally for bpftool and I also observe "libbfd: [ on  ]" only.
> This looks much better, thank you Roberto for following up on this!

So I'll add your Tested-by: to this one as well, maybe to all the
patches in this series?

- Arnaldo
Quentin Monnet Aug. 18, 2022, 10:15 p.m. UTC | #5
On Thu, 18 Aug 2022 at 19:14, Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> Em Thu, Aug 18, 2022 at 05:40:04PM +0100, Quentin Monnet escreveu:
> > On 18/08/2022 14:25, Roberto Sassu wrote:
> > > On Thu, 2022-08-18 at 10:09 -0300, Arnaldo Carvalho de Melo wrote:
> > >> Em Thu, Aug 18, 2022 at 02:09:57PM +0200,
> > >> roberto.sassu@huaweicloud.com escreveu:
> > >>> From: Roberto Sassu <roberto.sassu@huawei.com>
> > >>>
> > >>> Sometimes, features are simply different flavors of another
> > >>> feature, to
> > >>> properly detect the exact dependencies needed by different Linux
> > >>> distributions.
> > >>>
> > >>> For example, libbfd has three flavors: libbfd if the distro does
> > >>> not
> > >>> require any additional dependency; libbfd-liberty if it requires
> > >>> libiberty;
> > >>> libbfd-liberty-z if it requires libiberty and libz.
> > >>>
> > >>> It might not be clear to the user whether a feature has been
> > >>> successfully
> > >>> detected or not, given that some of its flavors will be set to OFF,
> > >>> others
> > >>> to ON.
> > >>>
> > >>> Instead, display only the feature main flavor if not in verbose
> > >>> mode
> > >>> (VF != 1), and set it to ON if at least one of its flavors has been
> > >>> successfully detected (logical OR), OFF otherwise. Omit the other
> > >>> flavors.
> > >>>
> > >>> Accomplish that by declaring a FEATURE_GROUP_MEMBERS-<feature main
> > >>> flavor>
> > >>> variable, with the list of the other flavors as variable value. For
> > >>> now, do
> > >>> it just for libbfd.
> > >>>
> > >>> In verbose mode, of if no group is defined for a feature, show the
> > >>> feature
> > >>> detection result as before.
> > >>
> > >> Looks cool, tested and added this to the commit log message here in
> > >> my
> > >> local branch, that will go public after further tests for the other
> > >> csets in it:
> > >>
> > >> Committer testing:
> > >>
> > >> Collecting the output from:
> > >>
> > >>   $ make -C tools/bpf/bpftool/ clean
> > >>   $ make -C tools/bpf/bpftool/ |& grep "Auto-detecting system
> > >> features" -A10
> > >>
> > >>   $ diff -u before after
> > >>   --- before    2022-08-18 10:06:40.422086966 -0300
> > >>   +++ after     2022-08-18 10:07:59.202138282 -0300
> > >>   @@ -1,6 +1,4 @@
> > >>    Auto-detecting system features:
> > >>    ...                                  libbfd: [ on  ]
> > >>   -...                          libbfd-liberty: [ on  ]
> > >>   -...                        libbfd-liberty-z: [ on  ]
> > >>    ...                                  libcap: [ on  ]
> > >>    ...                         clang-bpf-co-re: [ on  ]
> > >>   $
> > >>
> > >> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > >>
> > >> Thanks for working on this!
> > >
> > > Thanks for testing and for adapting/pushing the other patches!
> > >
> > > Roberto
> > >
> >
> > Tested locally for bpftool and I also observe "libbfd: [ on  ]" only.
> > This looks much better, thank you Roberto for following up on this!
>
> So I'll add your Tested-by: to this one as well, maybe to all the
> patches in this series?

Sorry, I haven't tested the first two patches other than by applying
them, so just for the third one preferably. Thanks!
Jiri Olsa Aug. 22, 2022, 10:58 a.m. UTC | #6
On Thu, Aug 18, 2022 at 02:09:57PM +0200, roberto.sassu@huaweicloud.com wrote:
> From: Roberto Sassu <roberto.sassu@huawei.com>
> 
> Sometimes, features are simply different flavors of another feature, to
> properly detect the exact dependencies needed by different Linux
> distributions.
> 
> For example, libbfd has three flavors: libbfd if the distro does not
> require any additional dependency; libbfd-liberty if it requires libiberty;
> libbfd-liberty-z if it requires libiberty and libz.
> 
> It might not be clear to the user whether a feature has been successfully
> detected or not, given that some of its flavors will be set to OFF, others
> to ON.
> 
> Instead, display only the feature main flavor if not in verbose mode
> (VF != 1), and set it to ON if at least one of its flavors has been
> successfully detected (logical OR), OFF otherwise. Omit the other flavors.
> 
> Accomplish that by declaring a FEATURE_GROUP_MEMBERS-<feature main flavor>
> variable, with the list of the other flavors as variable value. For now, do
> it just for libbfd.
> 
> In verbose mode, of if no group is defined for a feature, show the feature
> detection result as before.
> 
> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
> ---
>  tools/build/Makefile.feature | 27 +++++++++++++++++++++++++--
>  1 file changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index 6c809941ff01..57619f240b56 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -137,6 +137,12 @@ FEATURE_DISPLAY ?=              \
>           libaio			\
>           libzstd
>  
> +#
> +# Declare group members of a feature to display the logical OR of the detection
> +# result instead of each member result.
> +#
> +FEATURE_GROUP_MEMBERS-libbfd = libbfd-liberty libbfd-liberty-z

nice, I checked and could not find any other 'flavours' instance
like libbfd, but it might happen in future

for the whole patchset:

Tested-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka


> +
>  # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
>  # If in the future we need per-feature checks/flags for features not
>  # mentioned in this list we need to refactor this ;-).
> @@ -179,8 +185,17 @@ endif
>  #
>  feature_print_status = $(eval $(feature_print_status_code))
>  
> +feature_group = $(eval $(feature_gen_group)) $(GROUP)
> +
> +define feature_gen_group
> +  GROUP := $(1)
> +  ifneq ($(feature_verbose),1)
> +    GROUP += $(FEATURE_GROUP_MEMBERS-$(1))
> +  endif
> +endef
> +
>  define feature_print_status_code
> -  ifeq ($(feature-$(1)), 1)
> +  ifneq (,$(filter 1,$(foreach feat,$(call feature_group,$(feat)),$(feature-$(feat)))))
>      MSG = $(shell printf '...%40s: [ \033[32mon\033[m  ]' $(1))
>    else
>      MSG = $(shell printf '...%40s: [ \033[31mOFF\033[m ]' $(1))
> @@ -244,12 +259,20 @@ ifeq ($(VF),1)
>    feature_verbose := 1
>  endif
>  
> +ifneq ($(feature_verbose),1)
> +  #
> +  # Determine the features to omit from the displayed message, as only the
> +  # logical OR of the detection result will be shown.
> +  #
> +  FEATURE_OMIT := $(foreach feat,$(FEATURE_DISPLAY),$(FEATURE_GROUP_MEMBERS-$(feat)))
> +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),) $$(info $(MSG)))
> +    $(foreach feat,$(filter-out $(FEATURE_OMIT),$(FEATURE_DISPLAY)),$(call feature_print_status,$(feat),) $$(info $(MSG)))
>    endif
>  
>    ifeq ($(feature_verbose),1)
> -- 
> 2.25.1
>
Roberto Sassu Aug. 22, 2022, 11:24 a.m. UTC | #7
On Mon, 2022-08-22 at 12:58 +0200, Jiri Olsa wrote:
> On Thu, Aug 18, 2022 at 02:09:57PM +0200, 

[...]

> 
> > In verbose mode, of if no group is defined for a feature, show the
> > feature
> > detection result as before.

Thanks Jiri.

'or' instead of 'of', if the patch can be edited.

Roberto

> > Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
> > ---
> >  tools/build/Makefile.feature | 27 +++++++++++++++++++++++++--
> >  1 file changed, 25 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/build/Makefile.feature
> > b/tools/build/Makefile.feature
> > index 6c809941ff01..57619f240b56 100644
> > --- a/tools/build/Makefile.feature
> > +++ b/tools/build/Makefile.feature
> > @@ -137,6 +137,12 @@ FEATURE_DISPLAY ?=              \
> >           libaio			\
> >           libzstd
> >  
> > +#
> > +# Declare group members of a feature to display the logical OR of
> > the detection
> > +# result instead of each member result.
> > +#
> > +FEATURE_GROUP_MEMBERS-libbfd = libbfd-liberty libbfd-liberty-z
> 
> nice, I checked and could not find any other 'flavours' instance
> like libbfd, but it might happen in future
> 
> for the whole patchset:
> 
> Tested-by: Jiri Olsa <jolsa@kernel.org>
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> 
> thanks,
> jirka
> 
> 
> > +
> >  # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS
> > features.
> >  # If in the future we need per-feature checks/flags for features
> > not
> >  # mentioned in this list we need to refactor this ;-).
> > @@ -179,8 +185,17 @@ endif
> >  #
> >  feature_print_status = $(eval $(feature_print_status_code))
> >  
> > +feature_group = $(eval $(feature_gen_group)) $(GROUP)
> > +
> > +define feature_gen_group
> > +  GROUP := $(1)
> > +  ifneq ($(feature_verbose),1)
> > +    GROUP += $(FEATURE_GROUP_MEMBERS-$(1))
> > +  endif
> > +endef
> > +
> >  define feature_print_status_code
> > -  ifeq ($(feature-$(1)), 1)
> > +  ifneq (,$(filter 1,$(foreach feat,$(call
> > feature_group,$(feat)),$(feature-$(feat)))))
> >      MSG = $(shell printf '...%40s: [ \033[32mon\033[m  ]' $(1))
> >    else
> >      MSG = $(shell printf '...%40s: [ \033[31mOFF\033[m ]' $(1))
> > @@ -244,12 +259,20 @@ ifeq ($(VF),1)
> >    feature_verbose := 1
> >  endif
> >  
> > +ifneq ($(feature_verbose),1)
> > +  #
> > +  # Determine the features to omit from the displayed message, as
> > only the
> > +  # logical OR of the detection result will be shown.
> > +  #
> > +  FEATURE_OMIT := $(foreach
> > feat,$(FEATURE_DISPLAY),$(FEATURE_GROUP_MEMBERS-$(feat)))
> > +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),) $$(info $(MSG)))
> > +    $(foreach feat,$(filter-out
> > $(FEATURE_OMIT),$(FEATURE_DISPLAY)),$(call
> > feature_print_status,$(feat),) $$(info $(MSG)))
> >    endif
> >  
> >    ifeq ($(feature_verbose),1)
> > -- 
> > 2.25.1
> >
Roberto Sassu Sept. 27, 2022, 7:14 a.m. UTC | #8
On Mon, 2022-08-22 at 13:24 +0200, Roberto Sassu wrote:
> On Mon, 2022-08-22 at 12:58 +0200, Jiri Olsa wrote:
> > On Thu, Aug 18, 2022 at 02:09:57PM +0200, 
> 
> [...]
> 
> > > In verbose mode, of if no group is defined for a feature, show
> > > the
> > > feature
> > > detection result as before.
> 
> Thanks Jiri.
> 
> 'or' instead of 'of', if the patch can be edited.

Hi Arnaldo

will you take these patches?

Thanks

Roberto
Arnaldo Carvalho de Melo Sept. 27, 2022, 12:21 p.m. UTC | #9
Em Tue, Sep 27, 2022 at 09:14:34AM +0200, Roberto Sassu escreveu:
> On Mon, 2022-08-22 at 13:24 +0200, Roberto Sassu wrote:
> > On Mon, 2022-08-22 at 12:58 +0200, Jiri Olsa wrote:
> > > On Thu, Aug 18, 2022 at 02:09:57PM +0200, 
> > 
> > [...]
> > 
> > > > In verbose mode, of if no group is defined for a feature, show
> > > > the
> > > > feature
> > > > detection result as before.
> > 
> > Thanks Jiri.
> > 
> > 'or' instead of 'of', if the patch can be edited.
> 
> Hi Arnaldo
> 
> will you take these patches?

The tools/build one I have in my perf/core branch, for v6.1.

⬢[acme@toolbox perf]$ git log --oneline --author roberto.sassu@huawei.com tools/{build,perf,lib}
924b0da1154fa814 tools build: Display logical OR of a feature flavors
1903f4ac2f3a6d33 tools build: Increment room for feature name in feature detection output
48ab65e0fec644b4 tools build: Fix feature detection output due to eval expansion
5b245985a6de5ac1 tools build: Switch to new openssl API for test-libcrypto
dd6775f986144a9e perf build: Remove FEATURE_CHECK_LDFLAGS-disassembler-{four-args,init-styled} setting
629b98e2b1c6efcf tools, build: Retry detection of bfd-related features
⬢[acme@toolbox perf]$

Quentin, may I pick the ones that touch bpftool?

- Arnaldo
Roberto Sassu Sept. 27, 2022, 12:25 p.m. UTC | #10
On Tue, 2022-09-27 at 13:21 +0100, Arnaldo Carvalho de Melo wrote:
> Em Tue, Sep 27, 2022 at 09:14:34AM +0200, Roberto Sassu escreveu:
> > On Mon, 2022-08-22 at 13:24 +0200, Roberto Sassu wrote:
> > > On Mon, 2022-08-22 at 12:58 +0200, Jiri Olsa wrote:
> > > > On Thu, Aug 18, 2022 at 02:09:57PM +0200, 
> > > 
> > > [...]
> > > 
> > > > > In verbose mode, of if no group is defined for a feature,
> > > > > show
> > > > > the
> > > > > feature
> > > > > detection result as before.
> > > 
> > > Thanks Jiri.
> > > 
> > > 'or' instead of 'of', if the patch can be edited.
> > 
> > Hi Arnaldo
> > 
> > will you take these patches?
> 
> The tools/build one I have in my perf/core branch, for v6.1.
> 
> ⬢[acme@toolbox perf]$ git log --oneline --author 
> roberto.sassu@huawei.com tools/{build,perf,lib}
> 924b0da1154fa814 tools build: Display logical OR of a feature flavors
> 1903f4ac2f3a6d33 tools build: Increment room for feature name in
> feature detection output
> 48ab65e0fec644b4 tools build: Fix feature detection output due to
> eval expansion
> 5b245985a6de5ac1 tools build: Switch to new openssl API for test-
> libcrypto
> dd6775f986144a9e perf build: Remove FEATURE_CHECK_LDFLAGS-
> disassembler-{four-args,init-styled} setting
> 629b98e2b1c6efcf tools, build: Retry detection of bfd-related
> features
> ⬢[acme@toolbox perf]$

Oh, thanks. I had a quick look today at the web interface. I didn't see
them.

Roberto
Quentin Monnet Sept. 27, 2022, 1:24 p.m. UTC | #11
Tue Sep 27 2022 13:21:58 GMT+0100 ~ Arnaldo Carvalho de Melo
<acme@kernel.org>
> Em Tue, Sep 27, 2022 at 09:14:34AM +0200, Roberto Sassu escreveu:
>> On Mon, 2022-08-22 at 13:24 +0200, Roberto Sassu wrote:
>>> On Mon, 2022-08-22 at 12:58 +0200, Jiri Olsa wrote:
>>>> On Thu, Aug 18, 2022 at 02:09:57PM +0200, 
>>>
>>> [...]
>>>
>>>>> In verbose mode, of if no group is defined for a feature, show
>>>>> the
>>>>> feature
>>>>> detection result as before.
>>>
>>> Thanks Jiri.
>>>
>>> 'or' instead of 'of', if the patch can be edited.
>>
>> Hi Arnaldo
>>
>> will you take these patches?
> 
> The tools/build one I have in my perf/core branch, for v6.1.
> 
> ⬢[acme@toolbox perf]$ git log --oneline --author roberto.sassu@huawei.com tools/{build,perf,lib}
> 924b0da1154fa814 tools build: Display logical OR of a feature flavors
> 1903f4ac2f3a6d33 tools build: Increment room for feature name in feature detection output
> 48ab65e0fec644b4 tools build: Fix feature detection output due to eval expansion
> 5b245985a6de5ac1 tools build: Switch to new openssl API for test-libcrypto
> dd6775f986144a9e perf build: Remove FEATURE_CHECK_LDFLAGS-disassembler-{four-args,init-styled} setting
> 629b98e2b1c6efcf tools, build: Retry detection of bfd-related features
> ⬢[acme@toolbox perf]$
> 
> Quentin, may I pick the ones that touch bpftool?

Would be fine by me, although I'm not the one merging bpftool patches to
bpf-next (Alexei, Andrii or Daniel do it).

But for the current patchset I think there's nothing touching bpftool
directly, you already have all three patches in your tree as far as I
can tell

Quentin
diff mbox series

Patch

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 6c809941ff01..57619f240b56 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -137,6 +137,12 @@  FEATURE_DISPLAY ?=              \
          libaio			\
          libzstd
 
+#
+# Declare group members of a feature to display the logical OR of the detection
+# result instead of each member result.
+#
+FEATURE_GROUP_MEMBERS-libbfd = libbfd-liberty libbfd-liberty-z
+
 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
 # If in the future we need per-feature checks/flags for features not
 # mentioned in this list we need to refactor this ;-).
@@ -179,8 +185,17 @@  endif
 #
 feature_print_status = $(eval $(feature_print_status_code))
 
+feature_group = $(eval $(feature_gen_group)) $(GROUP)
+
+define feature_gen_group
+  GROUP := $(1)
+  ifneq ($(feature_verbose),1)
+    GROUP += $(FEATURE_GROUP_MEMBERS-$(1))
+  endif
+endef
+
 define feature_print_status_code
-  ifeq ($(feature-$(1)), 1)
+  ifneq (,$(filter 1,$(foreach feat,$(call feature_group,$(feat)),$(feature-$(feat)))))
     MSG = $(shell printf '...%40s: [ \033[32mon\033[m  ]' $(1))
   else
     MSG = $(shell printf '...%40s: [ \033[31mOFF\033[m ]' $(1))
@@ -244,12 +259,20 @@  ifeq ($(VF),1)
   feature_verbose := 1
 endif
 
+ifneq ($(feature_verbose),1)
+  #
+  # Determine the features to omit from the displayed message, as only the
+  # logical OR of the detection result will be shown.
+  #
+  FEATURE_OMIT := $(foreach feat,$(FEATURE_DISPLAY),$(FEATURE_GROUP_MEMBERS-$(feat)))
+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),) $$(info $(MSG)))
+    $(foreach feat,$(filter-out $(FEATURE_OMIT),$(FEATURE_DISPLAY)),$(call feature_print_status,$(feat),) $$(info $(MSG)))
   endif
 
   ifeq ($(feature_verbose),1)