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 <jelonek.jonas@gmail.com>
This commit is contained in:
parent
34ac128d6d
commit
e42e9c8133
2 changed files with 21 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
Loading…
Reference in a new issue