[PATCH master 2/2] scripts: common.h: define loff_t on musl
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Feb 19 22:46:12 PST 2025
Target tool build against musl fails, because loff_t is undefined,
despite _GNU_SOURCE being defined.
This is because glibc defines loff_t via <sys/types.h>, but musl defines
loff_t only in fcntl.h and the latter file isn't included beforehand in
imx-usb-loader-target.c.
Add the missing include to <linux/types.h> and include that header in
scripts/common.h to resolve the musl breakage.
This issue was noticedd during a Yocto build against musl, but can be
easily reproduced in Debian as well using the musl-tools package:
export ARCH=sandbox
make HOSTCC=musl-gcc CC=musl-gcc targettools_defconfig
make HOSTCC=musl-gcc CC=musl-gcc
Changes to CI to build sandbox against musl will follow later.
Fixes: 5171f4d0696f ("scripts: implement read_fd and pread_full for tools")
Reported-by: Enrico Jörns <ejo at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
scripts/common.h | 2 ++
scripts/include/linux/types.h | 1 +
2 files changed, 3 insertions(+)
diff --git a/scripts/common.h b/scripts/common.h
index a0d16606b5d9..21ec576a5be9 100644
--- a/scripts/common.h
+++ b/scripts/common.h
@@ -1,6 +1,8 @@
#ifndef __COMMON_H
#define __COMMON_H
+#include <linux/types.h>
+
int read_file_2(const char *filename, size_t *size, void **outbuf, size_t max_size);
void *read_file(const char *filename, size_t *size);
void *read_fd(int fd, size_t *out_size);
diff --git a/scripts/include/linux/types.h b/scripts/include/linux/types.h
index e81d7e810126..5b0133345bb9 100644
--- a/scripts/include/linux/types.h
+++ b/scripts/include/linux/types.h
@@ -4,6 +4,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
+#include <fcntl.h>
typedef uint64_t __u64;
typedef int64_t __s64;
--
2.39.5
More information about the barebox
mailing list