mbox series

[RFC,0/4] CONFIG_IS_ENABLED magic

Message ID 20200612110216.10355-1-rasmus.villemoes@prevas.dk
Headers show
Series CONFIG_IS_ENABLED magic | expand

Message

Rasmus Villemoes June 12, 2020, 11:02 a.m. UTC
The first patch is just something I suggested to allow zstd support to
move forward. The remaining ones aim to make it more ergonomic to use
CONFIG_IS_ENABLED to exclude things from the build.

While it currently works just fine in C code that one can do

  if (CONFIG_IS_ENABLED(FOO)) {

  }

and have the compiler throw the whole block away, and then later the
linker throw away any functions and/or data that turns out not be used
anyway, it's currently somewhat uglier to exclude items from an array
initializer - it requires three lines to do

  #if CONFIG_IS_ENABLED(FOO)
  { some array item },
  #endif

and grepping for the FOO symbol doesn't really show what it is used
for including/excluding.

With the last patch, one can instead do

  CONFIG_IS_ENABLED(FOO, ({ some array item },))

It's just an RFC; I think this can be useful to reduce the size of
SPL/TPL without too much cluttering of the source, others can
disagree.


Rasmus Villemoes (4):
  common/image.c: image_decomp: put IH_COMP_XXX cases inside ifndef
    USE_HOSTCC
  linux/kconfig.h: simplify logic for choosing CONFIG_{SPL_,TPL_,}*
  linux/kconfig.h: remove unused helper macros
  linux/kconfig.h: create two- and three-argument versions of
    CONFIG_IS_ENABLED

 common/image.c               |   2 +
 include/linux/kconfig.h      | 103 ++++++++++++++++++-----------------
 scripts/config_whitelist.txt |   2 -
 3 files changed, 54 insertions(+), 53 deletions(-)

Comments

Tom Rini June 19, 2020, 5:57 p.m. UTC | #1
On Fri, Jun 12, 2020 at 01:02:12PM +0200, Rasmus Villemoes wrote:

> The first patch is just something I suggested to allow zstd support to
> move forward. The remaining ones aim to make it more ergonomic to use
> CONFIG_IS_ENABLED to exclude things from the build.
> 
> While it currently works just fine in C code that one can do
> 
>   if (CONFIG_IS_ENABLED(FOO)) {
> 
>   }
> 
> and have the compiler throw the whole block away, and then later the
> linker throw away any functions and/or data that turns out not be used
> anyway, it's currently somewhat uglier to exclude items from an array
> initializer - it requires three lines to do
> 
>   #if CONFIG_IS_ENABLED(FOO)
>   { some array item },
>   #endif
> 
> and grepping for the FOO symbol doesn't really show what it is used
> for including/excluding.
> 
> With the last patch, one can instead do
> 
>   CONFIG_IS_ENABLED(FOO, ({ some array item },))
> 
> It's just an RFC; I think this can be useful to reduce the size of
> SPL/TPL without too much cluttering of the source, others can
> disagree.
> 
> 
> Rasmus Villemoes (4):
>   common/image.c: image_decomp: put IH_COMP_XXX cases inside ifndef
>     USE_HOSTCC
>   linux/kconfig.h: simplify logic for choosing CONFIG_{SPL_,TPL_,}*
>   linux/kconfig.h: remove unused helper macros
>   linux/kconfig.h: create two- and three-argument versions of
>     CONFIG_IS_ENABLED
> 
>  common/image.c               |   2 +
>  include/linux/kconfig.h      | 103 ++++++++++++++++++-----------------
>  scripts/config_whitelist.txt |   2 -
>  3 files changed, 54 insertions(+), 53 deletions(-)

This is I believe a good step forward and should let us clean up our
code in a few areas.  Thanks!