]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
packages: arm-trusted-firmware-tools: fix build on musl host
authorShine <4c.fce2@proton.me>
Mon, 2 Feb 2026 22:06:44 +0000 (23:06 +0100)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Sun, 21 Jun 2026 09:18:45 +0000 (11:18 +0200)
Due to POSIX style ioctl() declaration in MUSL, arm-trusted-firmware-tools
fails to build on MUSL based hosts with -Werror and -pedantic GCC switches
enabled. Alpine Linux, for example, fixes this with an unconditional cast
to "int". This commit tries to apply this cast only for MUSL based build
hosts, while keeping the type as-is where the cast isn't needed. Maybe
overkill, but cleaner than an unconditional cast.

Fixes: #13339
Signed-off-by: Shine <4c.fce2@proton.me>
Link: https://github.com/openwrt/openwrt/pull/21957
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
package/boot/arm-trusted-firmware-tools/Makefile
package/boot/arm-trusted-firmware-tools/patches/003-fiptool_musl_fix.patch [new file with mode: 0644]

index dd0ed66a21f77aee6f8e392b564f569caae21b1f..b709112ce39f917346837a146cb663f7282de359 100644 (file)
@@ -29,10 +29,16 @@ define Package/arm-trusted-firmware-tools
   BUILDONLY:=1
 endef
 
+ifeq ($(shell uname -s),Linux)
+       HOST_MUSL_FLAG:=$(shell [ "$$(2>&1 ldd --version | head -n 1 | cut -d ' ' -f1)" = "musl" ] && echo " -D__MUSL__")
+else
+       HOST_MUSL_FLAG:=
+endif
+
 define Host/Compile
        $(MAKE) -C \
                $(HOST_BUILD_DIR)/tools/fiptool \
-               CPPFLAGS="$(HOST_CFLAGS)" \
+               CPPFLAGS="$(HOST_CFLAGS)$(HOST_MUSL_FLAG)" \
                LDFLAGS="$(HOST_LDFLAGS)" \
                OPENSSL_DIR="$(STAGING_DIR_HOST)"
 endef
diff --git a/package/boot/arm-trusted-firmware-tools/patches/003-fiptool_musl_fix.patch b/package/boot/arm-trusted-firmware-tools/patches/003-fiptool_musl_fix.patch
new file mode 100644 (file)
index 0000000..f421e91
--- /dev/null
@@ -0,0 +1,14 @@
+--- a/tools/fiptool/fiptool.c
++++ b/tools/fiptool/fiptool.c
+@@ -318,7 +318,11 @@
+ #ifdef BLKGETSIZE64
+       if ((st.st_mode & S_IFBLK) != 0)
++#ifdef __MUSL__
++              if (ioctl(fileno(fp), (int)BLKGETSIZE64, &st_size) == -1)
++#else
+               if (ioctl(fileno(fp), BLKGETSIZE64, &st_size) == -1)
++#endif
+                       log_err("ioctl %s", filename);
+ #endif