diff --git a/README.md b/README.md index bf649dd..dab6643 100644 --- a/README.md +++ b/README.md @@ -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:** diff --git a/cctools/ar/archive.c b/cctools/ar/archive.c index 74a679d..045dd8c 100644 --- a/cctools/ar/archive.c +++ b/cctools/ar/archive.c @@ -78,6 +78,7 @@ static char rcsid[] = "$NetBSD: archive.c,v 1.7 1995/03/26 03:27:46 glass Exp $" #include #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include diff --git a/cctools/as/arm.c b/cctools/as/arm.c index 680225d..68fe77d 100644 --- a/cctools/as/arm.c +++ b/cctools/as/arm.c @@ -3,6 +3,7 @@ #include #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include "as.h" #include "flonum.h" diff --git a/cctools/as/driver.c b/cctools/as/driver.c index 24b468b..cbc1263 100644 --- a/cctools/as/driver.c +++ b/cctools/as/driver.c @@ -9,6 +9,7 @@ #include "stdio.h" #include "stdlib.h" #include "string.h" +#include /* cctools-port: For bcmp, bzero ... */ #include "libc.h" #include #include diff --git a/cctools/as/dwarf2dbg.c b/cctools/as/dwarf2dbg.c index 9c4c31e..5f15fca 100644 --- a/cctools/as/dwarf2dbg.c +++ b/cctools/as/dwarf2dbg.c @@ -30,6 +30,7 @@ #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/as/input-file.c b/cctools/as/input-file.c index f7ec600..636bac1 100644 --- a/cctools/as/input-file.c +++ b/cctools/as/input-file.c @@ -29,6 +29,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include "input-file.h" diff --git a/cctools/as/symbols.c b/cctools/as/symbols.c index e5d76b5..699efec 100644 --- a/cctools/as/symbols.c +++ b/cctools/as/symbols.c @@ -19,6 +19,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include "as.h" #include "hash.h" diff --git a/cctools/autogen.sh b/cctools/autogen.sh index 9258d0d..ca899f5 100755 --- a/cctools/autogen.sh +++ b/cctools/autogen.sh @@ -19,7 +19,7 @@ fi export LIBTOOLIZE mkdir -p m4 -$LIBTOOLIZE -c -i +$LIBTOOLIZE -c -i --force aclocal -I m4 autoconf diff --git a/cctools/configure b/cctools/configure index 8e42007..21ac3d6 100755 --- a/cctools/configure +++ b/cctools/configure @@ -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 diff --git a/cctools/configure.ac b/cctools/configure.ac index 22cee73..05068a6 100644 --- a/cctools/configure.ac +++ b/cctools/configure.ac @@ -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) diff --git a/cctools/include/foreign/mach/i386/vm_param.h b/cctools/include/foreign/mach/i386/vm_param.h index 1f9da2f..abd089c 100644 --- a/cctools/include/foreign/mach/i386/vm_param.h +++ b/cctools/include/foreign/mach/i386/vm_param.h @@ -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) diff --git a/cctools/include/sys/cdefs.h b/cctools/include/sys/cdefs.h index 9fac96f..61e4e8b 100644 --- a/cctools/include/sys/cdefs.h +++ b/cctools/include/sys/cdefs.h @@ -1,5 +1,5 @@ #if defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || \ - defined(__OpenBSD__) || defined(__NetBSD__) + defined(__OpenBSD__) || defined(__NetBSD__) || defined(__ANDROID__) #include_next diff --git a/cctools/ld64/src/3rd/helper.h b/cctools/ld64/src/3rd/helper.h index 5d34afb..4fac2e1 100644 --- a/cctools/ld64/src/3rd/helper.h +++ b/cctools/ld64/src/3rd/helper.h @@ -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 diff --git a/cctools/ld64/src/ld/Options.cpp b/cctools/ld64/src/ld/Options.cpp index 523eb10..e4b37ec 100644 --- a/cctools/ld64/src/ld/Options.cpp +++ b/cctools/ld64/src/ld/Options.cpp @@ -34,7 +34,9 @@ #include #include #include +#ifndef __ANDROID__ // ld64-port #include +#endif #include #include #ifdef TAPI_SUPPORT diff --git a/cctools/ld64/src/ld/debugline.c b/cctools/ld64/src/ld/debugline.c index c4e151d..dd43c63 100644 --- a/cctools/ld64/src/ld/debugline.c +++ b/cctools/ld64/src/ld/debugline.c @@ -22,6 +22,7 @@ */ #ifndef KLD #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/libstuff/execute.c b/cctools/libstuff/execute.c index 4eee640..244a2ba 100644 --- a/cctools/libstuff/execute.c +++ b/cctools/libstuff/execute.c @@ -24,6 +24,7 @@ #include /* first to get rid of pre-comp warning */ #include /* first to get rid of pre-comp warning */ #include "stdio.h" +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/libstuff/llvm.c b/cctools/libstuff/llvm.c index 30952bb..76674d4 100644 --- a/cctools/libstuff/llvm.c +++ b/cctools/libstuff/llvm.c @@ -1,4 +1,5 @@ #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/libstuff/lto.c b/cctools/libstuff/lto.c index 286ac5b..598f919 100644 --- a/cctools/libstuff/lto.c +++ b/cctools/libstuff/lto.c @@ -1,6 +1,7 @@ #ifdef LTO_SUPPORT #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/libstuff/port.c b/cctools/libstuff/port.c index 1137dc8..4191454 100644 --- a/cctools/libstuff/port.c +++ b/cctools/libstuff/port.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/cctools/misc/nm.c b/cctools/misc/nm.c index 88d359d..9ca98fd 100644 --- a/cctools/misc/nm.c +++ b/cctools/misc/nm.c @@ -85,6 +85,7 @@ #include #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/misc/redo_prebinding.c b/cctools/misc/redo_prebinding.c index bfca128..b3e15bf 100644 --- a/cctools/misc/redo_prebinding.c +++ b/cctools/misc/redo_prebinding.c @@ -86,6 +86,7 @@ #import #import #import +#import /* cctools-port: For bcmp, bzero ... */ #import #import #import diff --git a/cctools/misc/segedit.c b/cctools/misc/segedit.c index 9ec7eaf..b043864 100644 --- a/cctools/misc/segedit.c +++ b/cctools/misc/segedit.c @@ -32,6 +32,7 @@ #include #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/misc/strip.c b/cctools/misc/strip.c index 8e16f62..6a638e3 100644 --- a/cctools/misc/strip.c +++ b/cctools/misc/strip.c @@ -28,6 +28,7 @@ #include #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/otool/arm64_disasm.c b/cctools/otool/arm64_disasm.c index e29d1cb..8e3e5d2 100644 --- a/cctools/otool/arm64_disasm.c +++ b/cctools/otool/arm64_disasm.c @@ -1,5 +1,6 @@ #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/otool/i386_disasm.c b/cctools/otool/i386_disasm.c index 1fe7894..55f9409 100644 --- a/cctools/otool/i386_disasm.c +++ b/cctools/otool/i386_disasm.c @@ -57,6 +57,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include /* cctools-port: For bcmp, bzero ... */ #include #include #include diff --git a/cctools/otool/print_objc2_64bit.c b/cctools/otool/print_objc2_64bit.c index 00993a8..67304e2 100644 --- a/cctools/otool/print_objc2_64bit.c +++ b/cctools/otool/print_objc2_64bit.c @@ -32,6 +32,7 @@ #include "stdlib.h" #include "stddef.h" #include "string.h" +#include /* cctools-port: For bcmp, bzero ... */ #include "mach-o/loader.h" #include "mach-o/arm64/reloc.h" #include "stuff/allocate.h" diff --git a/usage_examples/ios_toolchain/build.sh b/usage_examples/ios_toolchain/build.sh index 8a92c0a..bb78112 100755 --- a/usage_examples/ios_toolchain/build.sh +++ b/usage_examples/ios_toolchain/build.sh @@ -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 diff --git a/usage_examples/ios_toolchain/wrapper.c b/usage_examples/ios_toolchain/wrapper.c index b44b6fe..4d1bbf5 100644 --- a/usage_examples/ios_toolchain/wrapper.c +++ b/usage_examples/ios_toolchain/wrapper.c @@ -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);