Fixes to make cctools and ld64 work on Android

This commit is contained in:
Thomas Pöchtrager 2019-11-06 17:54:58 +01:00
parent 406ce466ac
commit 5e9c52005f
28 changed files with 47 additions and 19 deletions

View File

@ -7,8 +7,8 @@ Originally ported by [cjacker](http://ios-toolchain-based-on-clang-for-linux.goo
**SUPPORTED OPERATING SYSTEMS:**
Linux, FreeBSD, Mac OS X, iOS,
OpenBSD and NetBSD
Linux, Android (Termux), FreeBSD,
Mac OS X, iOS, OpenBSD and NetBSD
**SUPPORTED HOST ARCHITECTURES:**

View File

@ -78,6 +78,7 @@ static char rcsid[] = "$NetBSD: archive.c,v 1.7 1995/03/26 03:27:46 glass Exp $"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <unistd.h>
#include <mach-o/fat.h>

View File

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <mach-o/arm/reloc.h>
#include "as.h"
#include "flonum.h"

View File

@ -9,6 +9,7 @@
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include "libc.h"
#include <sys/file.h>
#include <mach/mach.h>

View File

@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <unistd.h>
#include <sys/param.h>
#include <libgen.h>

View File

@ -29,6 +29,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <assert.h>
#include <libc.h>
#include "input-file.h"

View File

@ -19,6 +19,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdlib.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <ctype.h>
#include "as.h"
#include "hash.h"

View File

@ -19,7 +19,7 @@ fi
export LIBTOOLIZE
mkdir -p m4
$LIBTOOLIZE -c -i
$LIBTOOLIZE -c -i --force
aclocal -I m4
autoconf

12
cctools/configure vendored
View File

@ -16995,6 +16995,18 @@ _ACEOF
fi
done
for ac_func in bcopy bcmp bzero index rindex
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
### Check how to access struct stat's tv_nsec field.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for st_mtimespec.tv_nsec in struct stat" >&5

View File

@ -202,6 +202,7 @@ AC_CHECK_LIB([uuid],[uuid_generate_random],[
AC_SUBST(UUID_LIB)
AC_CHECK_FUNCS([strmode utimens utimensat])
AC_CHECK_FUNCS([bcopy bcmp bzero index rindex])
### Check how to access struct stat's tv_nsec field.
AC_MSG_CHECKING(for st_mtimespec.tv_nsec in struct stat)

View File

@ -95,7 +95,8 @@
#define I386_PGBYTES 4096 /* bytes per 80386 page */
#define I386_PGSHIFT 12 /* bitshift for pages */
#undef PAGE_SIZE /* Cygwin */
#undef PAGE_SIZE /* cctools-port */
#undef PAGE_MASK
#define PAGE_SIZE I386_PGBYTES
#define PAGE_SHIFT I386_PGSHIFT
#define PAGE_MASK (PAGE_SIZE - 1)

View File

@ -1,5 +1,5 @@
#if defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || \
defined(__OpenBSD__) || defined(__NetBSD__)
defined(__OpenBSD__) || defined(__NetBSD__) || defined(__ANDROID__)
#include_next <sys/cdefs.h>

View File

@ -5,18 +5,6 @@
#define __USE_GNU
#endif
#ifndef __has_extension
#define __has_extension(x) 0
#endif
#ifndef __has_include
#define __has_include(x) 0
#endif
#ifndef __has_include_next
#define __has_include_next(x) 0
#endif
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -34,7 +34,9 @@
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#ifndef __ANDROID__ // ld64-port
#include <spawn.h>
#endif
#include <cxxabi.h>
#include <Availability.h>
#ifdef TAPI_SUPPORT

View File

@ -22,6 +22,7 @@
*/
#ifndef KLD
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>

View File

@ -24,6 +24,7 @@
#include <libc.h> /* first to get rid of pre-comp warning */
#include <mach/mach.h> /* first to get rid of pre-comp warning */
#include "stdio.h"
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <signal.h>
#include <sys/wait.h>
#include <sys/file.h>

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <stdlib.h>
#include <libc.h>
#include <sys/file.h>

View File

@ -1,6 +1,7 @@
#ifdef LTO_SUPPORT
#include <stdio.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <stdlib.h>
#include <libc.h>
#include <sys/file.h>

View File

@ -1,5 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>

View File

@ -85,6 +85,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <ctype.h>
#include <libc.h>
#include <dlfcn.h>

View File

@ -86,6 +86,7 @@
#import <stdio.h>
#import <stdlib.h>
#import <string.h>
#import <strings.h> /* cctools-port: For bcmp, bzero ... */
#import <limits.h>
#import <libc.h>
#import <malloc/malloc.h>

View File

@ -32,6 +32,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <errno.h>
#include <stdio.h>
#include <sys/file.h>

View File

@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <limits.h>
#include <ctype.h>
#include <libc.h>

View File

@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <stdlib.h>
#include <mach-o/loader.h>
#include <mach-o/nlist.h>

View File

@ -57,6 +57,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
#include <mach-o/reloc.h>

View File

@ -32,6 +32,7 @@
#include "stdlib.h"
#include "stddef.h"
#include "string.h"
#include <strings.h> /* cctools-port: For bcmp, bzero ... */
#include "mach-o/loader.h"
#include "mach-o/arm64/reloc.h"
#include "stuff/allocate.h"

View File

@ -4,6 +4,12 @@ export LC_ALL=C
pushd "${0%/*}" &>/dev/null
PLATFORM=$(uname -s)
OPERATING_SYSTEM=$(uname -o || echo "-")
if [ $OPERATING_SYSTEM == "Android" ]; then
export CC="clang -D__ANDROID_API__=26"
export CXX="clang++ -D__ANDROID_API__=26"
fi
if [ -z "$LLVM_DSYMUTIL" ]; then
LLVM_DSYMUTIL=llvm-dsymutil
@ -141,7 +147,7 @@ if [ $OK -eq 1 ]; then
pushd $TARGETDIR/bin &>/dev/null
ln -sf $TRIPLE-lipo lipo
popd &>/dev/null
else
elif ! which dsymutil &>/dev/null; then
echo "int main(){return 0;}" | cc -xc -O2 -o $TARGETDIR/bin/dsymutil -
fi

View File

@ -147,7 +147,7 @@ int main(int argc, char *argv[])
target_info(argv, &target, &compiler);
if (!get_executable_path(execpath, sizeof(execpath))) abort();
snprintf(sdkpath, sizeof(sdkpath), "%s/../SDK/" SDK_DIR, execpath);
snprintf(sdkpath, sizeof(sdkpath) - 1, "%s/../SDK/" SDK_DIR, execpath);
snprintf(codesign_allocate, sizeof(codesign_allocate),
"%s-codesign_allocate", target);