From: Shine <4c.fce2@proton.me> Date: Mon, 2 Feb 2026 22:06:44 +0000 (+0100) Subject: packages: arm-trusted-firmware-tools: fix build on musl host X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e42e9c8133fbd0dce7abfe1ec696383745448078;p=thirdparty%2Fopenwrt.git packages: arm-trusted-firmware-tools: fix build on musl host 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 --- diff --git a/package/boot/arm-trusted-firmware-tools/Makefile b/package/boot/arm-trusted-firmware-tools/Makefile index dd0ed66a21f..b709112ce39 100644 --- a/package/boot/arm-trusted-firmware-tools/Makefile +++ b/package/boot/arm-trusted-firmware-tools/Makefile @@ -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 index 00000000000..f421e91ef0c --- /dev/null +++ b/package/boot/arm-trusted-firmware-tools/patches/003-fiptool_musl_fix.patch @@ -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 +