Skip to contentSkip to conversation

envtools: make them build again

PATCH In review Rasmus Villemoes 3 participants 4 messages Oct 16, 2024 – Oct 22, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 envtools: make them build again

In v2024.10, "make envtools" is broken for at least these defconfigs:

am335x_evm_defconfig
rpi_3_defconfig
rpi_4_defconfig
mx7dsabresd_defconfig
wandboard_defconfig
imx8mp_evk_defconfig

The only defconfig we use for which it is not broken is stm32mp13_defconfig. They all work just fine in v2024.07.

The symptoms are slightly different, but all related to the fact that some transitively included header uses IS_ENABLED or CONFIG_IS_ENABLED without linux/kconfig.h having already been included.

A simple git bisect doesn't produce anything sensible, it ends up at 3a9f642ca94 (crypto: nuvoton: npcm_sha: Support SHA 384/512) which clearly has nothing to do with this. But digging deeper, one eventually finds 0f92fa45603 ("env: Remove <common.h> and add needed includes").

So at first I tried adding "#include <linux/kconfig.h>" in include/env_default.h and include/env_flags.h. That fixes it for some, but not all, of the above. For example rpi_3_defconfig still fails, then in log.h complaining about BIT() and u8 not being defined. At least BIT() is should have gotten from bitops.h, except that that's behind ifdef __KERNEL__, so not set for the envtools build.

It turns out that the envtools source code in fw_env_private.h already has some hackery to deal with all this, in the form of the __ASSEMBLY__ games it plays before including config.h. It seems that if we just make sure to do that include early enough, so that config.h is indeed parsed with that __ASSEMBLY__ hackery in place, everything builds fine.

Fixes 0f92fa45603 ("env: Remove <common.h> and add needed includes")

---
Resending because I failed to send to the list the first time around. Sorry for the noise.

 tools/env/fw_env.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/env/fw_env.c +2 -1
index 74451ecb945..425faf380fb 100644
@@ -9,6 +9,8 @@
 
 #define _GNU_SOURCE
 
+#include "fw_env_private.h"
+
 #include <compiler.h>
 #include <env.h>
 #include <errno.h>
@@ -39,7 +41,6 @@
 
 #include <mtd/ubi-user.h>
 
-#include "fw_env_private.h"
 #include "fw_env.h"
 
 struct env_opts default_opts = {
Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Rasmus Villemoes

In v2024.10, "make envtools" is broken for at least these defconfigs:

am335x_evm_defconfig
rpi_3_defconfig
rpi_4_defconfig
mx7dsabresd_defconfig
wandboard_defconfig
imx8mp_evk_defconfig

The only defconfig we use for which it is not broken is stm32mp13_defconfig. They all work just fine in v2024.07.

The symptoms are slightly different, but all related to the fact that some transitively included header uses IS_ENABLED or CONFIG_IS_ENABLED without linux/kconfig.h having already been included.

A simple git bisect doesn't produce anything sensible, it ends up at 3a9f642ca94 (crypto: nuvoton: npcm_sha: Support SHA 384/512) which clearly has nothing to do with this. But digging deeper, one eventually finds 0f92fa45603 ("env: Remove <common.h> and add needed includes").

So at first I tried adding "#include <linux/kconfig.h>" in include/env_default.h and include/env_flags.h. That fixes it for some, but not all, of the above. For example rpi_3_defconfig still fails, then in log.h complaining about BIT() and u8 not being defined. At least BIT() is should have gotten from bitops.h, except that that's behind ifdef __KERNEL__, so not set for the envtools build.

It turns out that the envtools source code in fw_env_private.h already has some hackery to deal with all this, in the form of the __ASSEMBLY__ games it plays before including config.h. It seems that if we just make sure to do that include early enough, so that config.h is indeed parsed with that __ASSEMBLY__ hackery in place, everything builds fine.

Quoted 2 lines
Fixes 0f92fa45603 ("env: Remove <common.h> and add needed includes")

Oh wow, good work.

Signature · 1 line
Tom
Reviewed-by on v1 1/1
#2 lore raw
In reply to Rasmus Villemoes
Quoted 37 lines · Rasmus Villemoes

In v2024.10, "make envtools" is broken for at least these defconfigs:

am335x_evm_defconfig
rpi_3_defconfig
rpi_4_defconfig
mx7dsabresd_defconfig
wandboard_defconfig
imx8mp_evk_defconfig

The only defconfig we use for which it is not broken is stm32mp13_defconfig. They all work just fine in v2024.07.

The symptoms are slightly different, but all related to the fact that some transitively included header uses IS_ENABLED or CONFIG_IS_ENABLED without linux/kconfig.h having already been included.

A simple git bisect doesn't produce anything sensible, it ends up at 3a9f642ca94 (crypto: nuvoton: npcm_sha: Support SHA 384/512) which clearly has nothing to do with this. But digging deeper, one eventually finds 0f92fa45603 ("env: Remove <common.h> and add needed includes").

So at first I tried adding "#include <linux/kconfig.h>" in include/env_default.h and include/env_flags.h. That fixes it for some, but not all, of the above. For example rpi_3_defconfig still fails, then in log.h complaining about BIT() and u8 not being defined. At least BIT() is should have gotten from bitops.h, except that that's behind ifdef __KERNEL__, so not set for the envtools build.

It turns out that the envtools source code in fw_env_private.h already has some hackery to deal with all this, in the form of the __ASSEMBLY__ games it plays before including config.h. It seems that if we just make sure to do that include early enough, so that config.h is indeed parsed with that __ASSEMBLY__ hackery in place, everything builds fine.

Quoted 2 lines
Fixes 0f92fa45603 ("env: Remove <common.h> and add needed includes")

Thanks for the fix.

#3 lore raw
In reply to Rasmus Villemoes
Quoted 10 lines · Rasmus Villemoes

In v2024.10, "make envtools" is broken for at least these defconfigs:

am335x_evm_defconfig
rpi_3_defconfig
rpi_4_defconfig
mx7dsabresd_defconfig
wandboard_defconfig
imx8mp_evk_defconfig

[...]

Applied to u-boot/master, thanks!

Signature · 1 line
Tom