From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: ejo@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 2/2] scripts: common.h: define loff_t on musl
Date: Thu, 20 Feb 2025 07:46:12 +0100 [thread overview]
Message-ID: <20250220064612.865757-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250220064612.865757-1-a.fatoum@pengutronix.de>
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@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@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
next prev parent reply other threads:[~2025-02-20 6:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 6:46 [PATCH master 1/2] scripts: define _GNU_SOURCE for every user tool build Ahmad Fatoum
2025-02-20 6:46 ` Ahmad Fatoum [this message]
2025-02-21 10:22 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250220064612.865757-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=ejo@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox