Skip to contentSkip to conversation

boot/image-fit.c: Restore building tools on macOS

PATCH In review Tom Rini 2 participants 3 messages Dec 1, 2025 – Dec 2, 2025

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 boot/image-fit.c: Restore building tools on macOS

The ordering of headers in this file doesn't follow our rules exactly because this file ends up being included when building host tools and so has to be correct for host include paths and ordering as well. We need to have <malloc.h> higher in the file or macOS will fail to build due to declaration problems.

Fixes 8fbcc0e0e839 ("boot: Assure FDT is always at 8-byte aligned address")

---
Cc: Marek Vasut <[email protected]>

---
 boot/image-fit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
boot/image-fit.c +1 -1
index cccaa48f6839..3f66bec49041 100644
@@ -23,6 +23,7 @@
 #include <log.h>
 #include <mapmem.h>
 #include <asm/io.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <asm/global_data.h>
 #ifdef CONFIG_DM_HASH
@@ -35,7 +36,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #include <bootm.h>
 #include <image.h>
 #include <bootstage.h>
-#include <malloc.h>
 #include <upl.h>
 #include <u-boot/crc.h>
 
Signature · 1 line
2.43.0
author
#1 lore raw
Quoted 27 lines · Tom Rini

The ordering of headers in this file doesn't follow our rules exactly because this file ends up being included when building host tools and so has to be correct for host include paths and ordering as well. We need to have <malloc.h> higher in the file or macOS will fail to build due to declaration problems.

Fixes 8fbcc0e0e839 ("boot: Assure FDT is always at 8-byte aligned address")

---
Cc: Marek Vasut <[email protected]>

---
 boot/image-fit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
boot/image-fit.c +1 -0
index cccaa48f6839..3f66bec49041 100644
@@ -23,6 +23,7 @@
 #include <log.h>
 #include <mapmem.h>
 #include <asm/io.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <asm/global_data.h>
 #ifdef CONFIG_DM_HASH

boot/image-fit.c DECLARE_GLOBAL_DATA_PTR; · line 40

Quoted 6 lines
boot/image-fit.c +0 -1
@@ -35,7 +36,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #include <bootm.h>
 #include <image.h>
 #include <bootstage.h>
-#include <malloc.h>
 #include <upl.h>
 #include <u-boot/crc.h>

Well, this blows up *everywhere* and so is wrong. I'll figure out something or another for a v2.

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

The ordering of headers in this file doesn't follow our rules exactly because this file ends up being included when building host tools and so has to be correct for host include paths and ordering as well. We need to have <malloc.h> higher in the file or macOS will fail to build due to declaration problems.

Fixes 8fbcc0e0e839 ("boot: Assure FDT is always at 8-byte aligned address")

---
Cc: Marek Vasut <[email protected]>

I ran across this missing malloc() once before, but never triggered it in CI after changing the fixed patch slightly. It seems it does trigger sometimes, so:

Thanks !