[RFC PATCH 0/4] CONFIG_IS_ENABLED magic

Rasmus Villemoes rasmus.villemoes at prevas.dk
Fri Jun 12 13:02:12 CEST 2020


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(-)

-- 
2.23.0



More information about the U-Boot mailing list