mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 0/3] sandbox: enable building under musl
@ 2025-03-25 12:47 Ahmad Fatoum
  2025-03-25 12:47 ` [PATCH master 1/3] sandbox: use POSIX header instead of Linux one Ahmad Fatoum
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-03-25 12:47 UTC (permalink / raw)
  To: barebox; +Cc: Jules Maselbas

Building sandbox itself as opposed to the target/host tools still fails
with musl, due to some headers not being available.

This is fixed by this series.

Ahmad Fatoum (3):
  sandbox: use POSIX header instead of Linux one
  sandbox: don't build tap support code without CONFIG_DRIVER_NET_TAP
  sandbox: os: tap: make it compile with musl

 arch/sandbox/os/Makefile |  3 ++-
 arch/sandbox/os/common.c |  2 +-
 arch/sandbox/os/tap.c    | 14 ++++++++++++--
 3 files changed, 15 insertions(+), 4 deletions(-)

-- 
2.39.5




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH master 1/3] sandbox: use POSIX header instead of Linux one
  2025-03-25 12:47 [PATCH master 0/3] sandbox: enable building under musl Ahmad Fatoum
@ 2025-03-25 12:47 ` Ahmad Fatoum
  2025-03-25 12:47 ` [PATCH master 2/3] sandbox: don't build tap support code without CONFIG_DRIVER_NET_TAP Ahmad Fatoum
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-03-25 12:47 UTC (permalink / raw)
  To: barebox; +Cc: Jules Maselbas, Ahmad Fatoum

We include <linux/fs.h> to get a definition of BLKGETSIZE64, but this
fails on musl. Both glibc and musl make the definition available via
<sys/mount.h>, so let's use that instead.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/os/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 7067c94d9b45..d44213319422 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -39,7 +39,7 @@
 #include <sys/select.h>
 #include <sys/wait.h>
 #include <sys/ioctl.h>
-#include <linux/fs.h>
+#include <sys/mount.h>
 #include <sys/time.h>
 /*
  * ...except the ones needed to connect with barebox
-- 
2.39.5




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH master 2/3] sandbox: don't build tap support code without CONFIG_DRIVER_NET_TAP
  2025-03-25 12:47 [PATCH master 0/3] sandbox: enable building under musl Ahmad Fatoum
  2025-03-25 12:47 ` [PATCH master 1/3] sandbox: use POSIX header instead of Linux one Ahmad Fatoum
@ 2025-03-25 12:47 ` Ahmad Fatoum
  2025-03-25 12:47 ` [PATCH master 3/3] sandbox: os: tap: make it compile with musl Ahmad Fatoum
  2025-03-27  8:13 ` [PATCH master 0/3] sandbox: enable building under musl Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-03-25 12:47 UTC (permalink / raw)
  To: barebox; +Cc: Jules Maselbas, Ahmad Fatoum

There's no point in compiling tap_alloc() if it's not going to be used.
As the file unconditionally uses <linux/*.h> headers, it breaks the
build, when those are not available.

Therefore only build the file if actually needed.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/os/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index 7a76fb0290e8..c40bc78d31dd 100644
--- a/arch/sandbox/os/Makefile
+++ b/arch/sandbox/os/Makefile
@@ -20,7 +20,8 @@ ifeq ($(CONFIG_SANDBOX_LINUX_I386),y)
 KBUILD_CFLAGS += -m32
 endif
 
-obj-y = common.o tap.o setjmp.o
+obj-y = common.o setjmp.o
+obj-$(CONFIG_DRIVER_NET_TAP) += tap.o
 obj-$(CONFIG_MALLOC_LIBC) += libc_malloc.o
 
 CFLAGS_sdl.o = $(shell $(PKG_CONFIG) sdl2 --cflags)
-- 
2.39.5




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH master 3/3] sandbox: os: tap: make it compile with musl
  2025-03-25 12:47 [PATCH master 0/3] sandbox: enable building under musl Ahmad Fatoum
  2025-03-25 12:47 ` [PATCH master 1/3] sandbox: use POSIX header instead of Linux one Ahmad Fatoum
  2025-03-25 12:47 ` [PATCH master 2/3] sandbox: don't build tap support code without CONFIG_DRIVER_NET_TAP Ahmad Fatoum
@ 2025-03-25 12:47 ` Ahmad Fatoum
  2025-03-27  8:13 ` [PATCH master 0/3] sandbox: enable building under musl Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-03-25 12:47 UTC (permalink / raw)
  To: barebox; +Cc: Jules Maselbas, Ahmad Fatoum

musl not ship a definition of IFF_TAP. As this is ABI set in stone,
let's just duplicate the constant we need and use them as fallback, when
<linux/if_tun.h> is missing.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/os/tap.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/os/tap.c b/arch/sandbox/os/tap.c
index 83b97ffd49c7..fbb20f2fa80f 100644
--- a/arch/sandbox/os/tap.c
+++ b/arch/sandbox/os/tap.c
@@ -21,10 +21,20 @@
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
-#include <linux/if.h>
-#include <linux/if_tun.h>
+#include <net/if.h>
 #include <string.h>
 
+#ifdef __has_include
+#  if !__has_include(<linux/if_tun.h>)
+#    define IFF_TAP		0x0002
+#    define IFF_NO_PI	0x1000
+#    define TUNSETIFF	_IOW('T', 202, int)
+#  endif
+#endif
+#ifndef IFF_TAP
+#  include <linux/if_tun.h>
+#endif
+
 int tap_alloc(const char *dev)
 {
 	struct ifreq ifr;
-- 
2.39.5




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH master 0/3] sandbox: enable building under musl
  2025-03-25 12:47 [PATCH master 0/3] sandbox: enable building under musl Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2025-03-25 12:47 ` [PATCH master 3/3] sandbox: os: tap: make it compile with musl Ahmad Fatoum
@ 2025-03-27  8:13 ` Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2025-03-27  8:13 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: Jules Maselbas


On Tue, 25 Mar 2025 13:47:37 +0100, Ahmad Fatoum wrote:
> Building sandbox itself as opposed to the target/host tools still fails
> with musl, due to some headers not being available.
> 
> This is fixed by this series.
> 
> Ahmad Fatoum (3):
>   sandbox: use POSIX header instead of Linux one
>   sandbox: don't build tap support code without CONFIG_DRIVER_NET_TAP
>   sandbox: os: tap: make it compile with musl
> 
> [...]

Applied, thanks!

[1/3] sandbox: use POSIX header instead of Linux one
      https://git.pengutronix.de/cgit/barebox/commit/?id=1426b121630e (link may not be stable)
[2/3] sandbox: don't build tap support code without CONFIG_DRIVER_NET_TAP
      https://git.pengutronix.de/cgit/barebox/commit/?id=97fcb63d9d67 (link may not be stable)
[3/3] sandbox: os: tap: make it compile with musl
      https://git.pengutronix.de/cgit/barebox/commit/?id=d9e696e5a5dd (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-27  8:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-25 12:47 [PATCH master 0/3] sandbox: enable building under musl Ahmad Fatoum
2025-03-25 12:47 ` [PATCH master 1/3] sandbox: use POSIX header instead of Linux one Ahmad Fatoum
2025-03-25 12:47 ` [PATCH master 2/3] sandbox: don't build tap support code without CONFIG_DRIVER_NET_TAP Ahmad Fatoum
2025-03-25 12:47 ` [PATCH master 3/3] sandbox: os: tap: make it compile with musl Ahmad Fatoum
2025-03-27  8:13 ` [PATCH master 0/3] sandbox: enable building under musl Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox