From d6e191f24c8d7d18cc043171f4fe68d59add0564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20P=C3=B6chtrager?= Date: Fri, 26 Dec 2014 11:26:43 +0100 Subject: [PATCH] make cctools / ld64 work properly with glibc < 2.10 https://github.com/tpoechtrager/cctools-port/pull/8 --- build.sh | 1 + patches/cctools-ld64-strnlen.patch | 67 ++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 patches/cctools-ld64-strnlen.patch diff --git a/build.sh b/build.sh index 402dfef..2fdfd0c 100755 --- a/build.sh +++ b/build.sh @@ -178,6 +178,7 @@ pushd .. &>/dev/null popd &>/dev/null patch -p0 < $PATCH_DIR/cctools-ld64-1.patch patch -p0 < $PATCH_DIR/cctools-ld64-2.patch +patch -p1 < $PATCH_DIR/cctools-ld64-strnlen.patch echo "" CONFFLAGS="--prefix=$TARGET_DIR --target=x86_64-apple-$TARGET" [ -n "$DISABLE_LTO_SUPPORT" ] && CONFFLAGS+=" --enable-lto=no" diff --git a/patches/cctools-ld64-strnlen.patch b/patches/cctools-ld64-strnlen.patch new file mode 100644 index 0000000..c40bbf9 --- /dev/null +++ b/patches/cctools-ld64-strnlen.patch @@ -0,0 +1,67 @@ +diff --git cctools/include/foreign/i386/_types.h cctools/include/foreign/i386/_types.h +index 601b196..8bffd6f 100644 +--- cctools/include/foreign/i386/_types.h ++++ cctools/include/foreign/i386/_types.h +@@ -33,6 +33,15 @@ + * flotaing point and other arithmetic types, as needed, later. + */ + ++/* ++ * Silence old glibc -Wtypedef-redefinition warnings. ++ * https://github.com/tpoechtrager/cctools-port/pull/8 ++ */ ++#ifdef __clang__ ++#pragma clang diagnostic push ++#pragma clang diagnostic ignored "-Wtypedef-redefinition" ++#endif ++ + #ifdef __GNUC__ + typedef __signed char __int8_t; + #else /* !__GNUC__ */ +@@ -121,4 +130,8 @@ typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */ + typedef long __darwin_ssize_t; /* byte count or error */ + typedef long __darwin_time_t; /* time() */ + ++#ifdef __clang__ ++#pragma clang diagnostic pop ++#endif ++ + #endif /* _BSD_I386__TYPES_H_ */ +diff --git cctools/ld64/src/3rd/strlcat.c cctools/ld64/src/3rd/strlcat.c +index ef1a10a..faf09e3 100644 +--- cctools/ld64/src/3rd/strlcat.c ++++ cctools/ld64/src/3rd/strlcat.c +@@ -23,6 +23,14 @@ + + #ifndef __APPLE__ + ++/* ++ * Otherwise string.h may hide strnlen(). ++ * https://github.com/tpoechtrager/cctools-port/pull/8 ++ */ ++#ifndef _GNU_SOURCE ++#define _GNU_SOURCE ++#endif ++ + #include + + size_t +diff --git cctools/otool/ofile_print.c cctools/otool/ofile_print.c +index 3eb6506..4e9493a 100644 +--- cctools/otool/ofile_print.c ++++ cctools/otool/ofile_print.c +@@ -201,6 +201,14 @@ + #define __dr6 dr6 + #define __dr7 dr7 + ++/* ++ * Otherwise string.h may hide strnlen(). ++ * https://github.com/tpoechtrager/cctools-port/pull/8 ++ */ ++#ifndef _GNU_SOURCE ++#define _GNU_SOURCE ++#endif ++ + #include + #include + #include