From b713f1190aefd801eeb33167cf556bc1a8026537 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Tue, 5 Aug 2025 20:42:25 +0200 Subject: [PATCH] toolchains: fix building on MacOS with clang 17 The zlib version used by GCC 4.9.4 and binutils 2.26.1 is incompatible with clang 17 from the latest Xcode command line tools, resulting in fdopen being defined as NULL. Remove the define for MacOS, as in zlib 1.31: https://github.com/madler/zlib/commit/4bd9a71f3539b5ce47f0c67ab5e01f3196dc8ef9 Change-Id: Ic7f3108dc4fcaca4ae9a571f2bdb9039be095f36 --- tools/rockboxdev.sh | 6 ++++- .../apple_silicon-zlib.patch | 23 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tools/toolchain-patches/apple_silicon-zlib.patch diff --git a/tools/rockboxdev.sh b/tools/rockboxdev.sh index 54b5d8bff3..361a4f5f2d 100755 --- a/tools/rockboxdev.sh +++ b/tools/rockboxdev.sh @@ -442,11 +442,15 @@ build() { # For Apple targets only if [ "$system" == "Darwin" ] ; then - patch="$patch apple_silicon.patch" + patch="$patch apple_silicon.patch apple_silicon-zlib.patch" EXTRA_CXXFLAGS="-fbracket-depth=512" fi fi + if [ "$toolname" == "binutils" ] && [ "$system" == "Darwin" ]; then + patch="$patch apple_silicon-zlib.patch" + fi + # create build directory if test -d $builddir; then if test ! -w $builddir; then diff --git a/tools/toolchain-patches/apple_silicon-zlib.patch b/tools/toolchain-patches/apple_silicon-zlib.patch new file mode 100644 index 0000000000..b35e94f023 --- /dev/null +++ b/tools/toolchain-patches/apple_silicon-zlib.patch @@ -0,0 +1,23 @@ +diff --git a/zlib/zutil.h b/zlib/zutil.h +index ed6b127e..3186e991 100644 +--- a/zlib/zutil.h ++++ b/zlib/zutil.h +@@ -118,17 +118,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ + # endif + #endif + +-#if defined(MACOS) || defined(TARGET_OS_MAC) ++#if defined(MACOS) + # define OS_CODE 0x07 +-# ifndef Z_SOLO +-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +-# include /* for fdopen */ +-# else +-# ifndef fdopen +-# define fdopen(fd,mode) NULL /* No fdopen() */ +-# endif +-# endif +-# endif + #endif + + #ifdef TOPS20