diff --git a/README.md b/README.md index 5bc65f5d..1ddad199 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,34 @@ # Apple cctools port for Linux, FreeBSD and NetBSD # -Current Version: 855 + ld64-236.3 -Originally ported by cjacker from the [ios-toolchain-for-linux](https://code.google.com/p/ios-toolchain-based-on-clang-for-linux/) project. +Current Version: 855 + ld64-236.3. +Originally ported by [cjacker](http://ios-toolchain-based-on-clang-for-linux.googlecode.com). -## INSTALLATION ## +## SUPPORTED HOSTS ## + +Linux +FreeBSD +NetBSD +Mac OS X +iOS (partially) + +## SUPPORTED TARGETS ## + +armv4t, armv5, armv6, armv7, armv7f, armv7k, armv7s, armv6m +armv7m, armv7em, armv8, arm64, arm64v8, i386, x86_64 and x86_64h. + +## DEPENDENCIES ## -Make sure you have the following installed on your Linux box: +`Clang 3.2+`, `automake`, `autogen` and `libtool`. -`Clang 3.2+`, `llvm-devel`, `automake`, `autogen`, -`libtool`, `uuid-devel` and `openssl-devel`. +On Linux / FreeBSD / NetBSD you also need to install: -Then type: +`uuid-devel` and `openssl-devel`. + +Optional, but recommended deps: + +`llvm-devel` (Enables Link Time Optimization) + +## INSTALLATION ## * `cd cctools` * `./autogen.sh` @@ -21,4 +39,4 @@ Then type: target = `i386-apple-darwin11`, `x86_64-apple-darwin11`, `arm-apple-darwin11`, ... If you get compile errors because of `unistd.h`, then please run -`../tools/fix-unistd-issue.sh` in the cctools directory and restart compiling. +`../tools/fix_unistd_issue.sh` and restart compiling. diff --git a/cctools/Makefile.am b/cctools/Makefile.am index 44084adb..87e0494a 100644 --- a/cctools/Makefile.am +++ b/cctools/Makefile.am @@ -1,2 +1,7 @@ +if ISDARWIN +SUBDIRS=libstuff ar as misc otool ld64 $(LD_CLASSIC) +else SUBDIRS=libstuff ar as misc libobjc2 otool ld64 $(LD_CLASSIC) +endif + ACLOCAL_AMFLAGS = -I m4 diff --git a/cctools/ar/Makefile.am b/cctools/ar/Makefile.am index 007eb7dd..e4a9d0e3 100644 --- a/cctools/ar/Makefile.am +++ b/cctools/ar/Makefile.am @@ -2,7 +2,7 @@ bin_PROGRAMS = ar ar_LDADD = \ $(top_srcdir)/libstuff/libstuff.la -ar_CFLAGS = -D__DARWIN_UNIX03 -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff $(WARNINGS) $(LTO_DEFS) $(ENDIAN_FLAG) +ar_CFLAGS = -D__DARWIN_UNIX03 -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff $(WARNINGS) $(LTO_DEF) $(ENDIAN_FLAG) ar_SOURCES = \ append.c \ diff --git a/cctools/as/Makefile.am b/cctools/as/Makefile.am index ce0ddc05..deaf3147 100644 --- a/cctools/as/Makefile.am +++ b/cctools/as/Makefile.am @@ -4,6 +4,6 @@ bin_PROGRAMS = as as_LDADD = \ $(top_srcdir)/libstuff/libstuff.la -as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff $(WARNINGS) $(LTO_DEFS) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 $(ENDIAN_FLAG) +as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff $(WARNINGS) $(LTO_DEF) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 $(ENDIAN_FLAG) as_SOURCES = driver.c diff --git a/cctools/as/arm/Makefile.am b/cctools/as/arm/Makefile.am index a1c5a6fe..61bba71a 100644 --- a/cctools/as/arm/Makefile.am +++ b/cctools/as/arm/Makefile.am @@ -3,7 +3,7 @@ libexec_PROGRAMS = arm-as arm_as_LDADD = \ $(top_srcdir)/libstuff/libstuff.la -arm_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEFS) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DARM +arm_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEF) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DARM arm_as_SOURCES = ../app.c ../as.c ../atof-generic.c ../atof-ieee.c ../expr.c ../fixes.c ../flonum-const.c \ ../flonum-copy.c ../flonum-mult.c ../frags.c ../hash.c ../hex-value.c ../input-file.c \ diff --git a/cctools/as/i386/Makefile.am b/cctools/as/i386/Makefile.am index 0599c58d..08fbb6c4 100644 --- a/cctools/as/i386/Makefile.am +++ b/cctools/as/i386/Makefile.am @@ -3,7 +3,7 @@ libexec_PROGRAMS = i386-as i386_as_LDADD = \ $(top_srcdir)/libstuff/libstuff.la -i386_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEFS) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DI386 -Di486 -Di586 -Di686 +i386_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEF) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DI386 -Di486 -Di586 -Di686 i386_as_SOURCES = ../app.c ../as.c ../atof-generic.c ../atof-ieee.c ../expr.c ../fixes.c ../flonum-const.c \ ../flonum-copy.c ../flonum-mult.c ../frags.c ../hash.c ../hex-value.c ../input-file.c \ diff --git a/cctools/as/ppc/Makefile.am b/cctools/as/ppc/Makefile.am index a9d87e46..17f76292 100644 --- a/cctools/as/ppc/Makefile.am +++ b/cctools/as/ppc/Makefile.am @@ -3,7 +3,7 @@ libexec_PROGRAMS = ppc-as ppc_as_LDADD = \ $(top_srcdir)/libstuff/libstuff.la -ppc_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEFS) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DPPC +ppc_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEF) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DPPC ppc_as_SOURCES = ../app.c ../as.c ../atof-generic.c ../atof-ieee.c ../expr.c ../fixes.c ../flonum-const.c \ ../flonum-copy.c ../flonum-mult.c ../frags.c ../hash.c ../hex-value.c ../input-file.c \ diff --git a/cctools/as/ppc64/Makefile.am b/cctools/as/ppc64/Makefile.am index fbcd0067..2c081e21 100644 --- a/cctools/as/ppc64/Makefile.am +++ b/cctools/as/ppc64/Makefile.am @@ -3,7 +3,7 @@ libexec_PROGRAMS = ppc64-as ppc64_as_LDADD = \ $(top_srcdir)/libstuff/libstuff.la -ppc64_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEFS) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DPPC -DARCH64 +ppc64_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEF) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DPPC -DARCH64 ppc64_as_SOURCES = ../app.c ../as.c ../atof-generic.c ../atof-ieee.c ../expr.c ../fixes.c ../flonum-const.c \ ../flonum-copy.c ../flonum-mult.c ../frags.c ../hash.c ../hex-value.c ../input-file.c \ diff --git a/cctools/as/x86_64/Makefile.am b/cctools/as/x86_64/Makefile.am index 03bcbb8c..e9953d1b 100644 --- a/cctools/as/x86_64/Makefile.am +++ b/cctools/as/x86_64/Makefile.am @@ -3,7 +3,7 @@ libexec_PROGRAMS = x86_64-as x86_64_as_LDADD = \ $(top_srcdir)/libstuff/libstuff.la -x86_64_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEFS) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DI386 -Di486 -Di586 -Di686 -DARCH64 +x86_64_as_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/as $(WARNINGS) $(LTO_DEF) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DI386 -Di486 -Di586 -Di686 -DARCH64 x86_64_as_SOURCES = ../app.c ../as.c ../atof-generic.c ../atof-ieee.c ../expr.c ../fixes.c ../flonum-const.c \ ../flonum-copy.c ../flonum-mult.c ../frags.c ../hash.c ../hex-value.c ../input-file.c \ diff --git a/cctools/autogen.sh b/cctools/autogen.sh index 3130e909..adc65d21 100755 --- a/cctools/autogen.sh +++ b/cctools/autogen.sh @@ -2,10 +2,6 @@ # set -x -test -n "$DISABLE_LTO_SUPPORT" && rm -rf tmp - -../tools/find_lto_header.sh || echo "llvm-devel seems not to be installed - disabling LTO support" - grep -n "__block," /usr/include/unistd.h &>/dev/null if [ $? -eq 0 ]; then echo "applying workaround for buggy unistd.h" diff --git a/cctools/configure.ac b/cctools/configure.ac index c4f6c47b..a2593015 100644 --- a/cctools/configure.ac +++ b/cctools/configure.ac @@ -6,20 +6,43 @@ AC_CANONICAL_TARGET AC_ARG_PROGRAM -# force compiler to clang -CC=clang -CXX=clang++ -CPP="clang -E" +case $host_os in + darwin* ) + isdarwin=yes + AM_CONDITIONAL([ISDARWIN], [true]) + ;; + * ) + AM_CONDITIONAL([ISDARWIN], [false]) + ;; +esac + +if test "x$CFLAGS" = "x"; then + CFLAGS="-O3" +fi + +if test "x$CXXFLAGS" = "x"; then + CXXFLAGS="-O3" +fi -CFLAGS="$CFLAGS `cat tmp/cflags 2>/dev/null`" -CFLAGS="$CFLAGS -isystem /usr/local/include -isystem /usr/pkg/include -O3" -CXXFLAGS="$CXXFLAGS -std=c++0x `cat tmp/cxxflags 2>/dev/null`" -CXXFLAGS="$CXXFLAGS -isystem /usr/local/include -isystem /usr/pkg/include -O3" +if test "x$isdarwin" = "xyes"; then + CXXFLAGS="$CXXFLAGS -stdlib=libc++" +fi -LDFLAGS="$LDFLAGS -L/usr/local/lib `cat tmp/ldflags 2>/dev/null`" +CXXFLAGS="$CXXFLAGS -std=c++0x" + +if test "x$build" = "x$host"; then + CC="clang" + CXX="clang++" + CFLAGS="$CFLAGS -isystem /usr/local/include -isystem /usr/pkg/include" + CXXFLAGS="$CXXFLAGS -isystem /usr/local/include -isystem /usr/pkg/include" + LDFLAGS="$LDFLAGS -L/usr/local/lib" +else + CC="`which ${host_alias}-clang 2>/dev/null || echo clang`" + CXX="`which ${host_alias}-clang++ 2>/dev/null || echo clang++`" +fi -LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`cat tmp/ldpath 2>/dev/null`" -export LD_LIBRARY_PATH +CPP="$CC -E" +OBJC="$CC" # FIXME 'subdir-objects' breaks dependency tracking AM_INIT_AUTOMAKE([1.10 no-define no-dist-gzip dist-bzip2 tar-ustar subdir-objects no-dependencies]) @@ -34,7 +57,6 @@ AC_CONFIG_SRCDIR([APPLE_LICENSE]) LT_PREREQ([2.2.6]) LT_INIT(disable-static) - AC_PROG_INSTALL AC_PROG_CC([clang]) @@ -46,8 +68,15 @@ AM_PROG_AS([clang]) AC_CHECK_TOOL([HOST_RANLIB], [ranlib], :) AC_CHECK_TOOL([HOST_AR], [ar], :) -AC_CHECK_HEADERS([openssl/md5.h], [], [AC_MSG_ERROR([*** md5.h not found, Please install ssl dev packages according to your system])]) -AC_CHECK_HEADERS([uuid/uuid.h], [], [AC_MSG_ERROR([*** uuid.h not found, Please install uuid dev packages according to your system])]) +if test "x$isdarwin" != "xyes"; then + AC_CHECK_HEADERS([openssl/md5.h], [], [AC_MSG_ERROR([*** md5.h not found, please install ssl dev packages according to your system])]) + CRYPTO_LIB=-lcrypto + SSL_LIB=-lssl + AC_SUBST([CRYPTO_LIB]) + AC_SUBST([SSL_LIB]) +fi + +AC_CHECK_HEADERS([uuid/uuid.h], [], [AC_MSG_ERROR([*** uuid.h not found, please install uuid dev packages according to your system])]) #for libstuff emulated.c case $target_cpu in @@ -67,7 +96,11 @@ case $target_cpu in AC_DEFINE(EMULATED_HOST_CPU_TYPE, 16777223, [Emulated CPU type]) AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 3, [Emulated CPU subtype]) ;; - arm) + arm64*) + AC_DEFINE(EMULATED_HOST_CPU_TYPE, 16777228, [Emulated CPU type]) + AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 0, [Emulated CPU subtype]) + ;; + arm*) AC_DEFINE(EMULATED_HOST_CPU_TYPE, 12, [Emulated CPU type]) AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 0, [Emulated CPU subtype]) ;; @@ -76,23 +109,20 @@ case $target_cpu in ;; esac -#as reported, some users may use llvm-c/Disassembler.h instead of local copy in include dir. -#add these macros for avoid compilation failed. +# as reported, some users may use llvm-c/Disassembler.h instead of a local copy in include dir. +# add these macros to avoid compilation failures. AC_DEFINE(__STDC_LIMIT_MACROS) AC_DEFINE(__STDC_CONSTANT_MACROS) - - -#for as wrapper. AC_SUBST([ASLIBEXECDIR], ['${libexecdir}/as']) -#for ld_class involk in ld64 and other command call. +# set PROGRAM PREFIX if test "$target_alias"; then AC_SUBST([PROGRAM_PREFIX], ['${target_alias}-']) fi -#disable warnings. +# disable certain warnings. WARNINGS="" @@ -243,17 +273,18 @@ CFLAGS=$ORIGCFLAGS AC_SUBST([WARNINGS], [$WARNINGS]) -AC_CHECK_LIB([dl],[dlopen],[DL_LIBS=-ldl]) -AC_SUBST(DL_LIBS) +AC_CHECK_LIB([dl],[dlopen],[DL_LIB=-ldl]) +AC_SUBST(DL_LIB) AC_CHECK_LIB([pthread],[pthread_create],[PTHREAD_FLAGS=-pthread]) AC_SUBST(PTHREAD_FLAGS) -AC_CHECK_LIB([uuid],[uuid_generate_random],[UUID_LIBS=-luuid]) -AC_SUBST(UUID_LIBS) +AC_CHECK_LIB([uuid],[uuid_generate_random],[UUID_LIB=-luuid]) +AC_SUBST(UUID_LIB) + +AC_CHECK_FUNCS([strmode]) -AC_CHECK_LIB([crypto],[MD5_Init],[CRYPT_LIBS=-lcrypto]) -AC_SUBST(CRYPT_LIBS) +### Check for __cxa_demangle in various C++ ABI libs ### AC_CHECK_LIB([c++abi],[__cxa_demangle],[CXXABI_LIB=-lc++abi],[ AC_CHECK_LIB([supc++],[__cxa_demangle],[CXXABI_LIB=-lsupc++],[ @@ -263,10 +294,26 @@ AC_CHECK_LIB([c++abi],[__cxa_demangle],[CXXABI_LIB=-lc++abi],[ AC_SUBST(CXXABI_LIB) +### Check for libLTO ### + +ORIGLDFLAGS=$LDFLAGS +LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/lib,--enable-new-dtags" +AC_MSG_CHECKING([if -Wl,-rpath,,--enable-new-dtags is supported]) +AC_LINK_IFELSE( + [AC_LANG_SOURCE([[int main(){}]])], + [rpathlink=yes + AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])] +) +LDFLAGS=$ORIGLDFLAGS + +CHECK_LLVM + +### Check endianness ### + AC_C_BIGENDIAN([AC_SUBST([ENDIAN_FLAG],[-D__BIG_ENDIAN__=1])], [AC_SUBST([ENDIAN_FLAG],[-D__LITTLE_ENDIAN__=1])]) -AC_CHECK_FUNCS([strmode]) AC_CONFIG_FILES([Makefile libstuff/Makefile]) AC_CONFIG_FILES([ar/Makefile]) @@ -279,9 +326,12 @@ AC_CONFIG_FILES([as/ppc64/Makefile]) #AC_CONFIG_FILES([man/Makefile]) AC_CONFIG_FILES([misc/Makefile]) AC_CONFIG_FILES([otool/Makefile]) -AC_CONFIG_FILES([libobjc2/Makefile]) -AC_CONFIG_FILES([ld/Makefile]) +if test "x$isdarwin" != "xyes"; then + AC_CONFIG_FILES([libobjc2/Makefile]) +fi + +AC_CONFIG_FILES([ld/Makefile]) AC_CONFIG_FILES([ld64/Makefile]) AC_CONFIG_FILES([ld64/src/Makefile]) diff --git a/cctools/include/foreign/CommonCrypto/CommonDigest.h b/cctools/include/foreign/CommonCrypto/CommonDigest.h index 9452b9f0..4845ce02 100644 --- a/cctools/include/foreign/CommonCrypto/CommonDigest.h +++ b/cctools/include/foreign/CommonCrypto/CommonDigest.h @@ -1,3 +1,9 @@ +#ifdef __APPLE__ + +#include_next + +#else + #include #define CC_MD5_DIGEST_LENGTH MD5_DIGEST_LENGTH @@ -7,3 +13,5 @@ #define CC_MD5 MD5 #define CC_MD5_Transform MD5_Transform #define CC_MD5_CTX MD5_CTX + +#endif /* __APPLE__ */ diff --git a/cctools/include/foreign/libkern/OSAtomic.h b/cctools/include/foreign/libkern/OSAtomic.h index 9f2dba43..56242907 100644 --- a/cctools/include/foreign/libkern/OSAtomic.h +++ b/cctools/include/foreign/libkern/OSAtomic.h @@ -82,7 +82,7 @@ __inline static int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue ) { return OSAtomicAdd32Barrier( -1, __theValue); } -#if defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) +#if defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__) int64_t OSAtomicAdd64( int64_t __theAmount, volatile int64_t *__theValue ); int64_t OSAtomicAdd64Barrier( int64_t __theAmount, volatile int64_t *__theValue ); @@ -101,7 +101,7 @@ __inline static int64_t OSAtomicDecrement64Barrier( volatile int64_t *__theValue ) { return OSAtomicAdd64Barrier( -1, __theValue); } -#endif /* defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) */ +#endif /* defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__) */ /* Boolean functions (and, or, xor.) These come in four versions for each operation: @@ -138,12 +138,12 @@ bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile bool OSAtomicCompareAndSwapLong( long __oldValue, long __newValue, volatile long *__theValue ); bool OSAtomicCompareAndSwapLongBarrier( long __oldValue, long __newValue, volatile long *__theValue ); -#if defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) +#if defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__) bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue ); bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue ); -#endif /* defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) */ +#endif /* defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__) */ /* Test and set. They return the original value of the bit, and operate on bit (0x80>>(n&7)) diff --git a/cctools/include/foreign/libkern/OSByteOrder.h b/cctools/include/foreign/libkern/OSByteOrder.h index 915a2494..97f5155d 100644 --- a/cctools/include/foreign/libkern/OSByteOrder.h +++ b/cctools/include/foreign/libkern/OSByteOrder.h @@ -43,7 +43,7 @@ #include #elif (defined(__i386__) || defined(__x86_64__)) #include -#elif defined(__arm__) +#elif defined(__arm__) || defined(__arm64__) #include #else #include diff --git a/cctools/include/foreign/libkern/_OSByteOrder.h b/cctools/include/foreign/libkern/_OSByteOrder.h index e6a30a1d..2c8b9a48 100644 --- a/cctools/include/foreign/libkern/_OSByteOrder.h +++ b/cctools/include/foreign/libkern/_OSByteOrder.h @@ -66,7 +66,7 @@ #include #endif -#if defined(__arm__) +#if defined(__arm__) || defined(__arm64__) #include #endif diff --git a/cctools/include/foreign/mach/machine/asm.h b/cctools/include/foreign/mach/machine/asm.h index 59e1da29..1cdbb810 100644 --- a/cctools/include/foreign/mach/machine/asm.h +++ b/cctools/include/foreign/mach/machine/asm.h @@ -29,12 +29,8 @@ #ifndef _MACH_MACHINE_ASM_H #define _MACH_MACHINE_ASM_H -#if defined (__ppc__) || defined (__ppc64__) -#include "mach/ppc/asm.h" -#elif defined (__i386__) || defined(__x86_64__) +#if defined (__i386__) || defined(__x86_64__) #include "mach/i386/asm.h" -#elif defined (__arm__) -#include "mach/arm/asm.h" #else #error architecture not supported #endif diff --git a/cctools/include/foreign/mach/machine/boolean.h b/cctools/include/foreign/mach/machine/boolean.h index 1bec00d4..3f421226 100644 --- a/cctools/include/foreign/mach/machine/boolean.h +++ b/cctools/include/foreign/mach/machine/boolean.h @@ -33,7 +33,7 @@ #include "mach/ppc/boolean.h" #elif defined (__i386__) || defined(__x86_64__) #include "mach/i386/boolean.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/boolean.h" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/machine/exception.h b/cctools/include/foreign/mach/machine/exception.h index 5ce83f25..548d38ca 100644 --- a/cctools/include/foreign/mach/machine/exception.h +++ b/cctools/include/foreign/mach/machine/exception.h @@ -33,7 +33,7 @@ #include "mach/ppc/exception.h" #elif defined (__i386__) || defined(__x86_64__) #include "mach/i386/exception.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/exception.h" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/machine/kern_return.h b/cctools/include/foreign/mach/machine/kern_return.h index df373969..f4759d94 100644 --- a/cctools/include/foreign/mach/machine/kern_return.h +++ b/cctools/include/foreign/mach/machine/kern_return.h @@ -33,7 +33,7 @@ #include "mach/ppc/kern_return.h" #elif defined (__i386__) || defined(__x86_64__) #include "mach/i386/kern_return.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/kern_return.h" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/machine/machine_types.defs b/cctools/include/foreign/mach/machine/machine_types.defs index 418d16bc..a60fe29f 100644 --- a/cctools/include/foreign/mach/machine/machine_types.defs +++ b/cctools/include/foreign/mach/machine/machine_types.defs @@ -29,11 +29,9 @@ #ifndef _MACH_MACHINE_MACHINE_TYPES_DEFS #define _MACH_MACHINE_MACHINE_TYPES_DEFS -#if defined (__ppc__) || defined (__ppc64__) -#include "mach/ppc/machine_types.defs" -#elif defined (__i386__) || defined(__x86_64__) +#if defined (__i386__) || defined(__x86_64__) #include "mach/i386/machine_types.defs" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/machine_types.defs" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/machine/ndr_def.h b/cctools/include/foreign/mach/machine/ndr_def.h index a7b5a9bd..2d345147 100644 --- a/cctools/include/foreign/mach/machine/ndr_def.h +++ b/cctools/include/foreign/mach/machine/ndr_def.h @@ -29,12 +29,8 @@ #ifndef _MACH_MACHINE_NDR_DEF_H #define _MACH_MACHINE_NDR_DEF_H -#if defined (__ppc__) || defined (__ppc64__) -#include "mach/ppc/ndr_def.h" -#elif defined (__i386__) || defined(__x86_64__) +#if defined (__i386__) || defined(__x86_64__) #include "mach/i386/ndr_def.h" -#elif defined (__arm__) -#include "mach/arm/ndr_def.h" #else #error architecture not supported #endif diff --git a/cctools/include/foreign/mach/machine/processor_info.h b/cctools/include/foreign/mach/machine/processor_info.h index ca963679..849fb918 100644 --- a/cctools/include/foreign/mach/machine/processor_info.h +++ b/cctools/include/foreign/mach/machine/processor_info.h @@ -33,7 +33,7 @@ #include "mach/ppc/processor_info.h" #elif defined (__i386__) || defined(__x86_64__) #include "mach/i386/processor_info.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/processor_info.h" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/machine/rpc.h b/cctools/include/foreign/mach/machine/rpc.h index b969bd4d..60ad2ace 100644 --- a/cctools/include/foreign/mach/machine/rpc.h +++ b/cctools/include/foreign/mach/machine/rpc.h @@ -33,7 +33,7 @@ #include "mach/ppc/rpc.h" #elif defined (__i386__) || defined(__x86_64__) #include "mach/i386/rpc.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/rpc.h" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/machine/sdt_isa.h b/cctools/include/foreign/mach/machine/sdt_isa.h index a8e1379c..edd26dcc 100644 --- a/cctools/include/foreign/mach/machine/sdt_isa.h +++ b/cctools/include/foreign/mach/machine/sdt_isa.h @@ -28,12 +28,8 @@ #ifndef _MACH_MACHINE_SDT_ISA_H_ #define _MACH_MACHINE_SDT_ISA_H_ -#if defined (__ppc__) || defined (__ppc64__) -#include -#elif defined (__i386__) || defined(__x86_64__) +#if defined (__i386__) || defined(__x86_64__) #include -#elif defined (__arm__) -#include #else #error architecture not supported #endif diff --git a/cctools/include/foreign/mach/machine/thread_state.h b/cctools/include/foreign/mach/machine/thread_state.h index 18ffca4e..bf368835 100644 --- a/cctools/include/foreign/mach/machine/thread_state.h +++ b/cctools/include/foreign/mach/machine/thread_state.h @@ -33,7 +33,7 @@ #include "mach/ppc/thread_state.h" #elif defined (__i386__) || defined(__x86_64__) #include "mach/i386/thread_state.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/thread_state.h" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/machine/thread_status.h b/cctools/include/foreign/mach/machine/thread_status.h index ad5eff08..40b1c82e 100644 --- a/cctools/include/foreign/mach/machine/thread_status.h +++ b/cctools/include/foreign/mach/machine/thread_status.h @@ -33,7 +33,7 @@ #include "mach/ppc/thread_status.h" #elif defined (__i386__) || defined(__x86_64__) #include "mach/i386/thread_status.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/thread_status.h" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/machine/vm_param.h b/cctools/include/foreign/mach/machine/vm_param.h index c71121b9..7f05c29b 100644 --- a/cctools/include/foreign/mach/machine/vm_param.h +++ b/cctools/include/foreign/mach/machine/vm_param.h @@ -33,7 +33,7 @@ #include "mach/ppc/vm_param.h" #elif defined (__i386__) || defined(__x86_64__) #include "mach/i386/vm_param.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/vm_param.h" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/machine/vm_types.h b/cctools/include/foreign/mach/machine/vm_types.h index b3660921..97744994 100644 --- a/cctools/include/foreign/mach/machine/vm_types.h +++ b/cctools/include/foreign/mach/machine/vm_types.h @@ -33,7 +33,7 @@ #include "mach/ppc/vm_types.h" #elif defined (__i386__) || defined(__x86_64__) #include "mach/i386/vm_types.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "mach/arm/vm_types.h" #else #error architecture not supported diff --git a/cctools/include/foreign/mach/shared_memory_server.h b/cctools/include/foreign/mach/shared_memory_server.h index 1ca25f39..ea7b9127 100644 --- a/cctools/include/foreign/mach/shared_memory_server.h +++ b/cctools/include/foreign/mach/shared_memory_server.h @@ -55,21 +55,12 @@ #define VM_PROT_COW 0x8 /* must not interfere with normal prot assignments */ #define VM_PROT_ZF 0x10 /* must not interfere with normal prot assignments */ -#ifdef __arm__ -#define GLOBAL_SHARED_TEXT_SEGMENT 0x30000000U -#define GLOBAL_SHARED_DATA_SEGMENT 0x38000000U -#define GLOBAL_SHARED_SEGMENT_MASK 0xF8000000U - -#define SHARED_TEXT_REGION_SIZE 0x08000000 -#define SHARED_DATA_REGION_SIZE 0x08000000 -#else #define GLOBAL_SHARED_TEXT_SEGMENT 0x90000000U #define GLOBAL_SHARED_DATA_SEGMENT 0xA0000000U #define GLOBAL_SHARED_SEGMENT_MASK 0xF0000000U #define SHARED_TEXT_REGION_SIZE 0x10000000 #define SHARED_DATA_REGION_SIZE 0x10000000 -#endif #if !defined(__LP64__) @@ -83,13 +74,8 @@ * i.e. if the size is 0x10000000 the object can be mapped at * 0x20000000, or 0x30000000, but not 0x1000000 */ -#ifdef __arm__ -#define SHARED_TEXT_REGION_MASK 0x07FFFFFF -#define SHARED_DATA_REGION_MASK 0x07FFFFFF -#else #define SHARED_TEXT_REGION_MASK 0x0FFFFFFF #define SHARED_DATA_REGION_MASK 0x0FFFFFFF -#endif /* flags field aliases for copyin_shared_file and load_shared_file */ @@ -133,6 +119,7 @@ struct shared_region_range_np { mach_vm_size_t srr_size; }; +#ifndef KERNEL __BEGIN_DECLS int shared_region_map_file_np(int fd, @@ -143,5 +130,6 @@ int shared_region_make_private_np(uint32_t rangeCount, const struct shared_region_range_np *ranges); __END_DECLS +#endif /* !KERNEL */ #endif /* _MACH_SHARED_MEMORY_SERVER_H_ */ diff --git a/cctools/include/foreign/mach/shared_region.h b/cctools/include/foreign/mach/shared_region.h index 4bea17ee..845cccc1 100644 --- a/cctools/include/foreign/mach/shared_region.h +++ b/cctools/include/foreign/mach/shared_region.h @@ -63,10 +63,10 @@ #define SHARED_REGION_NESTING_MIN_PPC64 0x0000000010000000ULL #define SHARED_REGION_NESTING_MAX_PPC64 0x0000000010000000ULL -#define SHARED_REGION_BASE_ARM 0x30000000ULL -#define SHARED_REGION_SIZE_ARM 0x10000000ULL -#define SHARED_REGION_NESTING_BASE_ARM 0x30000000ULL -#define SHARED_REGION_NESTING_SIZE_ARM 0x08000000ULL +#define SHARED_REGION_BASE_ARM 0x2C000000ULL +#define SHARED_REGION_SIZE_ARM 0x14000000ULL +#define SHARED_REGION_NESTING_BASE_ARM 0x2C000000ULL +#define SHARED_REGION_NESTING_SIZE_ARM 0x14000000ULL #define SHARED_REGION_NESTING_MIN_ARM ? #define SHARED_REGION_NESTING_MAX_ARM ? @@ -84,29 +84,20 @@ #define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_X86_64 #define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_X86_64 #define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_X86_64 -#elif defined(__ppc__) -#define SHARED_REGION_BASE SHARED_REGION_BASE_PPC -#define SHARED_REGION_SIZE SHARED_REGION_SIZE_PPC -#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_PPC -#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_PPC -#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_PPC -#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_PPC -#elif defined(__ppc64__) -#define SHARED_REGION_BASE SHARED_REGION_BASE_PPC64 -#define SHARED_REGION_SIZE SHARED_REGION_SIZE_PPC64 -#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_PPC64 -#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_PPC64 -#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_PPC64 -#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_PPC64 -#elif defined(__arm__) -#define SHARED_REGION_BASE SHARED_REGION_BASE_ARM -#define SHARED_REGION_SIZE SHARED_REGION_SIZE_ARM -#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_ARM -#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_ARM -#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_ARM -#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_ARM #endif +#ifdef KERNEL_PRIVATE + +/* + * This is routine sets the current source of power. + * Arguments: + * 0 if it is external source (connected to power ) + * 1 if it is internal power source ie battery + */ + +void post_sys_powersource(int); + +#endif /* KERNEL_PRIVATE */ /* * All shared_region_* declarations are a private interface * between dyld and the kernel. @@ -121,14 +112,18 @@ struct shared_file_mapping_np { }; #define VM_PROT_COW 0x8 /* must not interfere with normal prot assignments */ #define VM_PROT_ZF 0x10 /* must not interfere with normal prot assignments */ +#define VM_PROT_SLIDE 0x20 /* must not interfere with normal prot assignments */ +#ifndef KERNEL __BEGIN_DECLS int shared_region_check_np(uint64_t *startaddress); int shared_region_map_np(int fd, uint32_t mappingCount, const struct shared_file_mapping_np *mappings); +int shared_region_slide_np(void); __END_DECLS +#endif /* !KERNEL */ #endif /* _MACH_SHARED_REGION_H_ */ diff --git a/cctools/include/foreign/mach/task.h b/cctools/include/foreign/mach/task.h index 459a3300..644948b0 100644 --- a/cctools/include/foreign/mach/task.h +++ b/cctools/include/foreign/mach/task.h @@ -33,8 +33,8 @@ #include #elif defined(__ppc64__) #include -#elif defined(__arm__) -#include +#elif defined(__arm__) || defined(__arm64__) +/*#include */ #else #error unknown architecture #endif diff --git a/cctools/include/foreign/mach/thread_act.h b/cctools/include/foreign/mach/thread_act.h index ac2309bf..61e86a1f 100644 --- a/cctools/include/foreign/mach/thread_act.h +++ b/cctools/include/foreign/mach/thread_act.h @@ -33,8 +33,8 @@ #include #elif defined(__ppc64__) #include -#elif defined(__arm__) -#include +#elif defined(__arm__) || defined(__arm64__) +/*#include */ #else #error unknown architecture #endif diff --git a/cctools/include/foreign/mach/vm_statistics.h b/cctools/include/foreign/mach/vm_statistics.h index 4e7467d0..cf89a647 100644 --- a/cctools/include/foreign/mach/vm_statistics.h +++ b/cctools/include/foreign/mach/vm_statistics.h @@ -113,15 +113,6 @@ struct vm_statistics { typedef struct vm_statistics *vm_statistics_t; typedef struct vm_statistics vm_statistics_data_t; -#if defined(__ppc__) /* On ppc, vm statistics are still 32-bit */ - -typedef struct vm_statistics *vm_statistics64_t; -typedef struct vm_statistics vm_statistics64_data_t; - -#define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) value - -#else /* !(defined(__ppc__)) */ - /* * vm_statistics64 * @@ -133,6 +124,8 @@ typedef struct vm_statistics vm_statistics64_data_t; * rev3 - changed name to vm_statistics64. * changed some fields in structure to 64-bit on * arm, i386 and x86_64 architectures. + * rev4 - require 64-bit alignment for efficient access + * in the kernel. No change to reported data. * */ @@ -149,12 +142,8 @@ struct vm_statistics64 { uint64_t cow_faults; /* # of copy-on-writes */ uint64_t lookups; /* object cache lookups */ uint64_t hits; /* object cache hits */ - - /* added for rev1 */ uint64_t purges; /* # of pages purged */ natural_t purgeable_count; /* # of pages purgeable */ - - /* added for rev2 */ /* * NB: speculative pages are already accounted for in "free_count", * so "speculative_count" is the number of "free" pages that are @@ -163,11 +152,17 @@ struct vm_statistics64 { */ natural_t speculative_count; /* # of pages speculative */ -} -#ifdef __arm__ -__attribute__((aligned(8))) -#endif -; + /* added for rev1 */ + uint64_t decompressions; /* # of pages decompressed */ + uint64_t compressions; /* # of pages compressed */ + uint64_t swapins; /* # of pages swapped in (via compression segments) */ + uint64_t swapouts; /* # of pages swapped out (via compression segments) */ + natural_t compressor_page_count; /* # of pages used by the compressed pager to hold all the compressed data */ + natural_t throttled_count; /* # of pages throttled */ + natural_t external_page_count; /* # of pages that are file-backed (non-swap) */ + natural_t internal_page_count; /* # of pages that are anonymous */ + uint64_t total_uncompressed_pages_in_compressor; /* # of pages (uncompressed) held within the compressor. */ +} __attribute__((aligned(8))); typedef struct vm_statistics64 *vm_statistics64_t; typedef struct vm_statistics64 vm_statistics64_data_t; @@ -180,8 +175,40 @@ typedef struct vm_statistics64 vm_statistics64_data_t; */ #define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) ((uint32_t)(((value) > UINT32_MAX ) ? UINT32_MAX : (value))) -#endif /* !(defined(__ppc__)) */ +/* + * vm_extmod_statistics + * + * Structure to record modifications to a task by an + * external agent. + * + * History: + * rev0 - original structure. + */ + +struct vm_extmod_statistics { + int64_t task_for_pid_count; /* # of times task port was looked up */ + int64_t task_for_pid_caller_count; /* # of times this task called task_for_pid */ + int64_t thread_creation_count; /* # of threads created in task */ + int64_t thread_creation_caller_count; /* # of threads created by task */ + int64_t thread_set_state_count; /* # of register state sets in task */ + int64_t thread_set_state_caller_count; /* # of register state sets by task */ +} __attribute__((aligned(8))); + +typedef struct vm_extmod_statistics *vm_extmod_statistics_t; +typedef struct vm_extmod_statistics vm_extmod_statistics_data_t; + +typedef struct vm_purgeable_stat { + uint64_t count; + uint64_t size; +}vm_purgeable_stat_t; + +struct vm_purgeable_info { + vm_purgeable_stat_t fifo_data[8]; + vm_purgeable_stat_t obsolete_data; + vm_purgeable_stat_t lifo_data[8]; +}; +typedef struct vm_purgeable_info *vm_purgeable_info_t; /* included for the vm_map_page_query call */ @@ -196,6 +223,43 @@ typedef struct vm_statistics64 vm_statistics64_data_t; #define VM_PAGE_QUERY_PAGE_CS_VALIDATED 0x100 #define VM_PAGE_QUERY_PAGE_CS_TAINTED 0x200 +#ifdef MACH_KERNEL_PRIVATE + +/* + * Each machine dependent implementation is expected to + * keep certain statistics. They may do this anyway they + * so choose, but are expected to return the statistics + * in the following structure. + */ + +struct pmap_statistics { + integer_t resident_count; /* # of pages mapped (total)*/ + integer_t resident_max; /* # of pages mapped (peak) */ + integer_t wired_count; /* # of pages wired */ + + integer_t device; + integer_t device_peak; + integer_t internal; + integer_t internal_peak; + integer_t external; + integer_t external_peak; + integer_t reusable; + integer_t reusable_peak; + uint64_t compressed; + uint64_t compressed_peak; + uint64_t compressed_lifetime; +}; + +typedef struct pmap_statistics *pmap_statistics_t; + +#define PMAP_STATS_PEAK(field) \ + MACRO_BEGIN \ + if (field > field##_peak) { \ + field##_peak = field; \ + } \ + MACRO_END + +#endif /* MACH_KERNEL_PRIVATE */ /* * VM allocation flags: @@ -229,8 +293,20 @@ typedef struct vm_statistics64 vm_statistics64_data_t; #define VM_FLAGS_ANYWHERE 0x0001 #define VM_FLAGS_PURGABLE 0x0002 #define VM_FLAGS_NO_CACHE 0x0010 +#ifdef KERNEL_PRIVATE +#define VM_FLAGS_PERMANENT 0x0100 /* mapping can NEVER be unmapped */ +#define VM_FLAGS_GUARD_AFTER 0x0200 /* guard page after the mapping */ +#define VM_FLAGS_GUARD_BEFORE 0x0400 /* guard page before the mapping */ +#define VM_FLAGS_SUBMAP 0x0800 /* mapping a VM submap */ +#define VM_FLAGS_ALREADY 0x1000 /* OK if same mapping already exists */ +#define VM_FLAGS_BEYOND_MAX 0x2000 /* map beyond the map's max offset */ +#endif /* KERNEL_PRIVATE */ #define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */ - +#ifdef KERNEL_PRIVATE +#define VM_FLAGS_NO_PMAP_CHECK 0x8000 /* do not check that pmap is empty */ +#define VM_FLAGS_MAP_JIT 0x80000 /* Used to mark an entry as describing a JIT region */ +#endif /* KERNEL_PRIVATE */ +#define VM_FLAGS_RETURN_DATA_ADDR 0x100000 /* Return address of target data, rather than base of page */ /* * VM_FLAGS_SUPERPAGE_MASK * 3 bits that specify whether large pages should be used instead of @@ -240,10 +316,12 @@ typedef struct vm_statistics64 vm_statistics64_data_t; #define VM_FLAGS_SUPERPAGE_SHIFT 16 #define SUPERPAGE_NONE 0 /* no superpages, if all bits are 0 */ -#define VM_FLAGS_SUPERPAGE_NONE (SUPERPAGE_NONE< #elif defined (__i386__) || defined(__x86_64__) #include -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include #else #error architecture not supported diff --git a/cctools/include/foreign/machine/param.h b/cctools/include/foreign/machine/param.h index 0b2a2ad3..716f548a 100644 --- a/cctools/include/foreign/machine/param.h +++ b/cctools/include/foreign/machine/param.h @@ -35,7 +35,7 @@ #include "ppc/param.h" #elif defined (__i386__) || defined(__x86_64__) #include "i386/param.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "arm/param.h" #else #error architecture not supported diff --git a/cctools/include/foreign/machine/profile.h b/cctools/include/foreign/machine/profile.h index 45e4de8d..cc8a5eac 100644 --- a/cctools/include/foreign/machine/profile.h +++ b/cctools/include/foreign/machine/profile.h @@ -33,12 +33,8 @@ #ifndef _BSD_MACHINE_PROFILE_H_ #define _BSD_MACHINE_PROFILE_H_ -#if defined (__ppc__) || defined (__ppc64__) -#include "ppc/profile.h" -#elif defined (__i386__) || defined(__x86_64__) +#if defined (__i386__) || defined(__x86_64__) #include "i386/profile.h" -#elif defined (__arm__) -#include "arm/profile.h" #else #error architecture not supported #endif diff --git a/cctools/include/foreign/machine/setjmp.h b/cctools/include/foreign/machine/setjmp.h index 9aa71b5a..d39d26a1 100644 --- a/cctools/include/foreign/machine/setjmp.h +++ b/cctools/include/foreign/machine/setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * Copyright (c) 2000-2011 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -28,17 +28,9 @@ /* * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ -#ifndef _MACHINE_SETJMP_H_ -#define _MACHINE_SETJMP_H_ +#ifndef _MACHINE_SETJMP_H_ +#define _MACHINE_SETJMP_H_ -#if defined (__ppc__) || defined (__ppc64__) -#include "ppc/setjmp.h" -#elif defined (__i386__) || defined(__x86_64__) -#include "i386/setjmp.h" -#elif defined (__arm__) -#include "arm/setjmp.h" -#else -#error architecture not supported -#endif +#include -#endif /* _MACHINE_SETJMP_H_ */ +#endif /* _MACHINE_SETJMP_H_ */ diff --git a/cctools/include/foreign/machine/signal.h b/cctools/include/foreign/machine/signal.h index 7457d1ca..586334c6 100644 --- a/cctools/include/foreign/machine/signal.h +++ b/cctools/include/foreign/machine/signal.h @@ -32,7 +32,7 @@ #include "ppc/signal.h" #elif defined (__i386__) || defined(__x86_64__) #include "i386/signal.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "arm/signal.h" #else #error architecture not supported diff --git a/cctools/include/foreign/machine/types.h b/cctools/include/foreign/machine/types.h index 2bff8098..51524618 100644 --- a/cctools/include/foreign/machine/types.h +++ b/cctools/include/foreign/machine/types.h @@ -35,7 +35,7 @@ #include "ppc/types.h" #elif defined (__i386__) || defined(__x86_64__) #include "i386/types.h" -#elif defined (__arm__) +#elif defined (__arm__) || defined(__arm64__) #include "arm/types.h" #else #error architecture not supported diff --git a/cctools/include/foreign/machine/vmparam.h b/cctools/include/foreign/machine/vmparam.h index d9d0d74e..54b21238 100644 --- a/cctools/include/foreign/machine/vmparam.h +++ b/cctools/include/foreign/machine/vmparam.h @@ -28,12 +28,8 @@ #ifndef _BSD_MACHINE_VMPARAM_H_ #define _BSD_MACHINE_VMPARAM_H_ -#if defined (__ppc__) || defined (__ppc64__) -#include "ppc/vmparam.h" -#elif defined (__i386__) || defined(__x86_64__) +#if defined (__i386__) || defined(__x86_64__) #include "i386/vmparam.h" -#elif defined (__arm__) -#include "arm/vmparam.h" #else #error architecture not supported #endif diff --git a/cctools/ld/Makefile.am b/cctools/ld/Makefile.am index 364e6141..ed34eb03 100644 --- a/cctools/ld/Makefile.am +++ b/cctools/ld/Makefile.am @@ -1,8 +1,8 @@ bin_PROGRAMS = ld_classic ld_classic_LDADD = \ - $(top_srcdir)/libstuff/libstuff.la $(UUID_LIBS) + $(top_srcdir)/libstuff/libstuff.la $(UUID_LIB) -ld_classic_CFLAGS = -D__DARWIN_UNIX03 -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff $(WARNINGS) $(LTO_DEFS) $(ENDIAN_FLAG) -DDEBUG +ld_classic_CFLAGS = -D__DARWIN_UNIX03 -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff $(WARNINGS) $(LTO_DEF) $(ENDIAN_FLAG) -DDEBUG ld_classic_SOURCES = \ ld.c pass1.c objects.c sections.c cstring_literals.c symbols.c \ diff --git a/cctools/ld64/src/3rd/Makefile.am b/cctools/ld64/src/3rd/Makefile.am index 25f496cf..7f69fdd6 100644 --- a/cctools/ld64/src/3rd/Makefile.am +++ b/cctools/ld64/src/3rd/Makefile.am @@ -7,4 +7,5 @@ libhelper_la_SOURCES = \ helper.c \ qsort_r.c \ strlcat.c \ - strlcpy.c + strlcpy.c \ + eprintf.c diff --git a/cctools/ld64/src/3rd/eprintf.c b/cctools/ld64/src/3rd/eprintf.c new file mode 100644 index 00000000..f4b0ad4d --- /dev/null +++ b/cctools/ld64/src/3rd/eprintf.c @@ -0,0 +1,33 @@ +/* ===---------- eprintf.c - Implements __eprintf --------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + */ + +#ifdef __APPLE__ + +#include +#include + +/* + * __eprintf() was used in an old version of . + * It can eventually go away, but it is needed when linking + * .o files built with the old . + * + * It should never be exported from a dylib, so it is marked + * visibility hidden. + */ +__attribute__((visibility("hidden"))) +void __eprintf(const char* format, const char* assertion_expression, + const char* line, const char* file) +{ + fprintf(stderr, format, assertion_expression, line, file); + fflush(stderr); + abort(); +} + +#endif /* __APPLE__ */ diff --git a/cctools/ld64/src/3rd/helper.c b/cctools/ld64/src/3rd/helper.c index 19f4be79..84ac401c 100644 --- a/cctools/ld64/src/3rd/helper.c +++ b/cctools/ld64/src/3rd/helper.c @@ -1,3 +1,7 @@ +const char ldVersionString[] = "236.3\n"; + +#ifndef __APPLE__ + #include #include #include @@ -20,9 +24,6 @@ #include "helper.h" -const char ldVersionString[] = "236.3\n"; - - void __assert_rtn(const char *func, const char *file, int line, const char *msg) { #ifdef __FreeBSD__ @@ -100,3 +101,5 @@ int64_t OSAtomicAdd64(int64_t theAmount, volatile int64_t *theValue) { __sync_fetch_and_add(theValue, theAmount); return *theValue; } + +#endif /* __APPLE__ */ \ No newline at end of file diff --git a/cctools/ld64/src/3rd/strlcat.c b/cctools/ld64/src/3rd/strlcat.c index 500d038f..ef1a10a2 100644 --- a/cctools/ld64/src/3rd/strlcat.c +++ b/cctools/ld64/src/3rd/strlcat.c @@ -21,6 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#ifndef __APPLE__ + #include size_t @@ -36,3 +38,5 @@ strlcat(char * restrict dst, const char * restrict src, size_t maxlen) { } return dstlen + srclen; } + +#endif /* ! __APPLE__ */ \ No newline at end of file diff --git a/cctools/ld64/src/3rd/strlcat.h b/cctools/ld64/src/3rd/strlcat.h index d730aa2e..3aaa0323 100644 --- a/cctools/ld64/src/3rd/strlcat.h +++ b/cctools/ld64/src/3rd/strlcat.h @@ -1,3 +1,5 @@ +#ifndef __APPLE__ + #ifndef STRLCAT_H #define STRLCAT_H @@ -14,3 +16,4 @@ size_t strlcat(char *dst, const char *src, size_t siz); #endif +#endif /* ! __APPLE__ */ \ No newline at end of file diff --git a/cctools/ld64/src/3rd/strlcpy.c b/cctools/ld64/src/3rd/strlcpy.c index c69f1075..69b43a73 100644 --- a/cctools/ld64/src/3rd/strlcpy.c +++ b/cctools/ld64/src/3rd/strlcpy.c @@ -21,6 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#ifndef __APPLE__ + #include size_t @@ -35,3 +37,4 @@ strlcpy(char * restrict dst, const char * restrict src, size_t maxlen) { return srclen; } +#endif /* ! __APPLE__ */ diff --git a/cctools/ld64/src/3rd/strlcpy.h b/cctools/ld64/src/3rd/strlcpy.h index 4cd8bdbe..d3fcc04b 100644 --- a/cctools/ld64/src/3rd/strlcpy.h +++ b/cctools/ld64/src/3rd/strlcpy.h @@ -1,3 +1,5 @@ +#ifndef __APPLE__ + #ifndef STRLCPY_H #define STRLCPY_H @@ -14,3 +16,4 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #endif +#endif /* ! __APPLE__ */ \ No newline at end of file diff --git a/cctools/ld64/src/ld/HeaderAndLoadCommands.hpp b/cctools/ld64/src/ld/HeaderAndLoadCommands.hpp index acbdf4f3..b6bcae94 100644 --- a/cctools/ld64/src/ld/HeaderAndLoadCommands.hpp +++ b/cctools/ld64/src/ld/HeaderAndLoadCommands.hpp @@ -32,6 +32,15 @@ #include +#if defined(__arm__) || defined(__arm64__) +#undef THREAD_STATE_NONE +#undef VALID_THREAD_STATE_FLAVOR +#undef MACHINE_THREAD_STATE +#undef MACHINE_THREAD_STATE_COUNT +#endif + +#include + #include "MachOFileAbstraction.hpp" #include "Options.h" #include "ld.hpp" diff --git a/cctools/ld64/src/ld/InputFiles.cpp b/cctools/ld64/src/ld/InputFiles.cpp index 904dcf5c..8e1b1199 100644 --- a/cctools/ld64/src/ld/InputFiles.cpp +++ b/cctools/ld64/src/ld/InputFiles.cpp @@ -769,6 +769,8 @@ void InputFiles::inferArchitecture(Options& opts, const char** archName) opts.setArchitecture(CPU_TYPE_X86_64, CPU_SUBTYPE_X86_64_ALL); #elif __arm__ opts.setArchitecture(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V6); +#elif __arm64__ + opts.setArchitecture(CPU_TYPE_ARM, CPU_SUBTYPE_ARM64_ALL); #else #error unknown default architecture #endif diff --git a/cctools/ld64/src/ld/Makefile.am b/cctools/ld64/src/ld/Makefile.am index cbe5cd3e..e32d9ebc 100644 --- a/cctools/ld64/src/ld/Makefile.am +++ b/cctools/ld64/src/ld/Makefile.am @@ -6,18 +6,18 @@ ld_LDADD = \ $(top_srcdir)/ld64/src/3rd/BlocksRuntime/libBlocksRuntime.la \ $(top_srcdir)/ld64/src/ld/parsers/libParsers.la \ $(top_srcdir)/ld64/src/ld/passes/libPasses.la \ - $(DL_LIBS) \ - $(CRYPT_LIBS) \ - $(UUID_LIBS) \ - $(LTO_LIBS) + $(DL_LIB) \ + $(CRYPTO_LIB) \ + $(UUID_LIB) \ + $(LTO_LIB) -ld_LDFLAGS = $(PTHREAD_FLAGS) -lssl +ld_LDFLAGS = $(PTHREAD_FLAGS) $(SSL_LIB) ld_CXXFLAGS = \ -fblocks \ -D__DARWIN_UNIX03 \ $(WARNINGS) \ - $(LTO_DEFS) \ + $(LTO_DEF) \ $(ENDIAN_FLAG) \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/foreign \ @@ -27,14 +27,14 @@ ld_CXXFLAGS = \ -I$(top_srcdir)/ld64/src/3rd/BlocksRuntime \ -I$(top_srcdir)/ld64/src/ld \ -I$(top_srcdir)/ld64/src/ld/parsers \ - -I$(top_srcdir)/ld64/src/ld/passes \ - -DPROGRAM_PREFIX="\"$(PROGRAM_PREFIX)\"" + -I$(top_srcdir)/ld64/src/ld/passes \ + -DPROGRAM_PREFIX="\"$(PROGRAM_PREFIX)\"" ld_CFLAGS = \ -fblocks \ -D__DARWIN_UNIX03 \ $(WARNINGS) \ - $(LTO_DEFS) \ + $(LTO_DEF) \ $(ENDIAN_FLAG) \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/foreign \ diff --git a/cctools/ld64/src/ld/Options.cpp b/cctools/ld64/src/ld/Options.cpp index 3a78df8d..b2d6b23e 100644 --- a/cctools/ld64/src/ld/Options.cpp +++ b/cctools/ld64/src/ld/Options.cpp @@ -52,7 +52,12 @@ namespace lto { // magic to place command line in crash reports const int crashreporterBufferSize = 2000; static char crashreporterBuffer[crashreporterBufferSize]; -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 +#if defined(__has_include) && __has_include() +#define HAVE_CRASHREPORTER_HEADER 1 +#else +#define HAVE_CRASHREPORTER_HEADER 0 +#endif +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && HAVE_CRASHREPORTER_HEADER #include // hack until ld does not need to build on 10.6 anymore struct crashreporter_annotations_t gCRAnnotations @@ -4564,7 +4569,7 @@ void Options::checkForClassic(int argc, const char* argv[]) bool newLinker = false; // build command line buffer in case ld crashes -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && HAVE_CRASHREPORTER_HEADER CRSetCrashLogMessage(crashreporterBuffer); #endif const char* srcRoot = getenv("SRCROOT"); diff --git a/cctools/ld64/src/ld/parsers/Makefile.am b/cctools/ld64/src/ld/parsers/Makefile.am index dd5cecfe..5d8df126 100644 --- a/cctools/ld64/src/ld/parsers/Makefile.am +++ b/cctools/ld64/src/ld/parsers/Makefile.am @@ -14,7 +14,7 @@ libParsers_la_CXXFLAGS = \ -fblocks \ -D__DARWIN_UNIX03 \ $(WARNINGS) \ - $(LTO_DEFS) \ + $(LTO_DEF) \ $(ENDIAN_FLAGS) \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/foreign \ diff --git a/cctools/ld64/src/ld/parsers/libunwind/AddressSpace.hpp b/cctools/ld64/src/ld/parsers/libunwind/AddressSpace.hpp index bebd3e66..f3cd99ad 100644 --- a/cctools/ld64/src/ld/parsers/libunwind/AddressSpace.hpp +++ b/cctools/ld64/src/ld/parsers/libunwind/AddressSpace.hpp @@ -36,6 +36,14 @@ #include #include #include + +#if defined(__arm__) || defined(__arm64__) +#undef THREAD_STATE_NONE +#undef VALID_THREAD_STATE_FLAVOR +#undef MACHINE_THREAD_STATE +#undef MACHINE_THREAD_STATE_COUNT +#endif + #include #include diff --git a/cctools/ld64/src/ld/parsers/libunwind/Registers.hpp b/cctools/ld64/src/ld/parsers/libunwind/Registers.hpp index 02470665..42098ddf 100644 --- a/cctools/ld64/src/ld/parsers/libunwind/Registers.hpp +++ b/cctools/ld64/src/ld/parsers/libunwind/Registers.hpp @@ -35,6 +35,14 @@ #include #include #include + +#if defined(__arm__) || defined(__arm64__) +#undef THREAD_STATE_NONE +#undef VALID_THREAD_STATE_FLAVOR +#undef MACHINE_THREAD_STATE +#undef MACHINE_THREAD_STATE_COUNT +#endif + #include #include "libunwind.h" diff --git a/cctools/ld64/src/ld/passes/Makefile.am b/cctools/ld64/src/ld/passes/Makefile.am index 136a617e..76da3a89 100644 --- a/cctools/ld64/src/ld/passes/Makefile.am +++ b/cctools/ld64/src/ld/passes/Makefile.am @@ -15,7 +15,7 @@ libPasses_la_CXXFLAGS = \ -fblocks \ -D__DARWIN_UNIX03 \ $(WARNINGS) \ - $(LTO_DEFS) \ + $(LTO_DEF) \ $(ENDIAN_FLAGS) \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/foreign \ diff --git a/cctools/ld64/src/other/Makefile.am b/cctools/ld64/src/other/Makefile.am index 2835d444..7d1df8a4 100644 --- a/cctools/ld64/src/other/Makefile.am +++ b/cctools/ld64/src/other/Makefile.am @@ -9,7 +9,7 @@ AM_CXXFLAGS = \ -D__DARWIN_UNIX03 \ $(WARNINGS) \ -Wno-switch \ - $(LTO_DEFS) \ + $(LTO_DEF) \ $(ENDIAN_FLAGS) \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/foreign \ @@ -24,7 +24,7 @@ AM_CFLAGS = \ -fblocks \ -D__DARWIN_UNIX03 \ $(WARNINGS) \ - $(LTO_DEFS) \ + $(LTO_DEF) \ $(ENDIAN_FLAGS) \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/foreign \ @@ -42,7 +42,7 @@ ObjectDump_SOURCES = \ $(top_srcdir)/ld64/src/ld/debugline.c ObjectDump_LDADD = \ $(top_srcdir)/ld64/src/ld/parsers/libParsers.la \ - $(LTO_LIBS) + $(LTO_LIB) dyldinfo_SOURCES = dyldinfo.cpp diff --git a/cctools/libobjc2/Makefile.am b/cctools/libobjc2/Makefile.am index 27f98f18..d8bddbbb 100644 --- a/cctools/libobjc2/Makefile.am +++ b/cctools/libobjc2/Makefile.am @@ -1,6 +1,6 @@ noinst_LTLIBRARIES = libobjc.la -libobjc_la_CFLAGS = -std=gnu99 -fPIC -fexceptions -Wno-deprecated-objc-isa-usage -DTYPE_DEPENDENT_DISPATCH -DGNUSTEP -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 -D__BSD_VISIBLE=1 -D_BSD_SOURCE=1 -DNO_SELECTOR_MISMATCH_WARNINGS +libobjc_la_CFLAGS = -std=gnu99 -fPIC -fexceptions -Wno-deprecated-objc-isa-usage -DTYPE_DEPENDENT_DISPATCH -DGNUSTEP -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 -D__BSD_VISIBLE=1 -D_BSD_SOURCE=1 -DNO_SELECTOR_MISMATCH_WARNINGS $(WARNINGS) libobjc_la_SOURCES = \ NSBlocks.m\ diff --git a/cctools/libstuff/Makefile.am b/cctools/libstuff/Makefile.am index b48481d4..a51d266d 100644 --- a/cctools/libstuff/Makefile.am +++ b/cctools/libstuff/Makefile.am @@ -1,6 +1,6 @@ noinst_LTLIBRARIES = libstuff.la -libstuff_la_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -D__DARWIN_UNIX03 $(WARNINGS) $(LTO_DEFS) -DPROGRAM_PREFIX="\"$(PROGRAM_PREFIX)\"" $(ENDIAN_FLAG) +libstuff_la_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -D__DARWIN_UNIX03 $(WARNINGS) $(LTO_DEF) -DPROGRAM_PREFIX="\"$(PROGRAM_PREFIX)\"" $(ENDIAN_FLAG) libstuff_la_SOURCES = \ allocate.c \ diff --git a/cctools/libstuff/emulated.c b/cctools/libstuff/emulated.c index 956d7bd1..c201397d 100644 --- a/cctools/libstuff/emulated.c +++ b/cctools/libstuff/emulated.c @@ -37,9 +37,9 @@ int _NSGetExecutablePath(char *path, unsigned int *size) ret_size = readlink("/proc/self/exe", path, bufsize-1); if (ret_size != -1) { - *size = ret_size; - path[ret_size]=0; - return 0; + *size = ret_size; + path[ret_size]=0; + return 0; } else return -1; diff --git a/cctools/m4/llvm.m4 b/cctools/m4/llvm.m4 new file mode 100644 index 00000000..5b6a7c44 --- /dev/null +++ b/cctools/m4/llvm.m4 @@ -0,0 +1,45 @@ +AC_DEFUN([CHECK_LLVM], +[ + AC_ARG_ENABLE([lto], + AS_HELP_STRING([--enable-lto], + [enable link time optimization support]), + [], [enable_lto=yes]) + + if test "x$enable_lto" = "xyes"; then + AC_PATH_PROGS(LLVM_CONFIG, + [llvm-config \ + llvm-config-3.6 llvm-config-3.5 llvm-config-3.4 \ + llvm-config-3.3 llvm-config-3.2 llvm-config-3.1 \ + llvm-config36 llvm-config35 llvm-config34 \ + llvm-config33 llvm-config32 llvm-config31], + no) + + if test "x$LLVM_CONFIG" != "xno"; then + LLVM_INCLUDE_DIR="`${LLVM_CONFIG} --includedir`" + LLVM_LIB_DIR="`${LLVM_CONFIG} --libdir`" + + ORIGLDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -L${LLVM_LIB_DIR}" + + AC_CHECK_LIB([LTO],[lto_get_version], + [ LTO_LIB="-L${LLVM_LIB_DIR} -lLTO" + if test "x$rpathlink" = "xyes"; then + LTO_LIB="-Wl,-rpath,$LLVM_LIB_DIR,--enable-new-dtags $LTO_LIB" + fi + LTO_DEF=-DLTO_SUPPORT + # DO NOT include the LLVM include dir directly, + # it may cause the build to fail. + `ln -sf $LLVM_INCLUDE_DIR/llvm-c/lto.h include/llvm-c/lto.h 2>/dev/null 1>&2` + AC_SUBST([LTO_DEF]) + AC_SUBST([LTO_LIB]) ]) + + LDFLAGS=$ORIGLDFLAGS + else + AC_MSG_WARN([llvm-config not found, disabling LTO support]) + fi + fi + + AC_SUBST(LLVM_CONFIG) + AC_SUBST(LLVM_INCLUDE_DIR) + AC_SUBST(LLVM_LIB_DIR) +]) diff --git a/cctools/misc/Makefile.am b/cctools/misc/Makefile.am index 8a18884c..6a4bbe7d 100644 --- a/cctools/misc/Makefile.am +++ b/cctools/misc/Makefile.am @@ -16,12 +16,12 @@ bin_PROGRAMS = \ pagestuff \ ranlib \ codesign_allocate - + LDADD = \ - $(top_srcdir)/libstuff/libstuff.la \ - $(DL_LIBS) - -AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff $(WARNINGS) $(LTO_DEFS) -D__DARWIN_UNIX03 $(ENDIAN_FLAG) + $(top_srcdir)/libstuff/libstuff.la \ + $(DL_LIB) + +AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff $(WARNINGS) $(LTO_DEF) -D__DARWIN_UNIX03 $(ENDIAN_FLAG) checksyms_SOURCES = checksyms.c lipo_SOURCES = lipo.c diff --git a/cctools/otool/Makefile.am b/cctools/otool/Makefile.am index 4adb7429..50b28578 100644 --- a/cctools/otool/Makefile.am +++ b/cctools/otool/Makefile.am @@ -1,12 +1,16 @@ -bin_PROGRAMS = otool -otool_LDADD = \ - $(top_srcdir)/libstuff/libstuff.la \ - $(top_srcdir)/libobjc2/libobjc.la \ - $(DL_LIBS) +bin_PROGRAMS = otool -otool_LDFLAGS = $(PTHREAD_FLAGS) $(CXXABI_LIB) +if ISDARWIN +otool_LDADD = $(top_srcdir)/libstuff/libstuff.la +otool_LDFLAGS = $(PTHREAD_FLAGS) $(CXXABI_LIB) $(DL_LIB) -lobjc +else +otool_LDADD = \ +$(top_srcdir)/libstuff/libstuff.la \ +$(top_srcdir)/libobjc2/libobjc.la +otool_LDFLAGS = $(PTHREAD_FLAGS) $(CXXABI_LIB) $(DL_LIB) +endif -otool_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/libobjc2 $(WARNINGS) $(LTO_DEFS) -D_DARWIN_C_SOURCE -D__DARWIN_UNIX03 $(ENDIAN_FLAG) -DOTOOL +otool_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/libobjc2 $(WARNINGS) $(LTO_DEF) -D_DARWIN_C_SOURCE -D__DARWIN_UNIX03 $(ENDIAN_FLAG) -DOTOOL otool_SOURCES = \ main.c \ diff --git a/package.sh b/package.sh index 0d9915bf..61d7c4d3 100755 --- a/package.sh +++ b/package.sh @@ -9,7 +9,7 @@ REVHASH=`git rev-parse --short HEAD` CCTOOLSVER=`cat README.md | grep "Current Version: " | awk '{print $3}'` LD64VER=`cat README.md | grep "Current Version: " | awk '{print $5}'` -PACKAGE=cctools-${CCTOOLSVER}-${LD64VER}_$REVHASH +PACKAGE=cctools-${CCTOOLSVER}-${LD64VER%?}_$REVHASH mkdir $PACKAGETMP/$PACKAGE cp -r . $PACKAGETMP/$PACKAGE @@ -17,10 +17,14 @@ cp -r . $PACKAGETMP/$PACKAGE pushd $PACKAGETMP &>/dev/null pushd $PACKAGE &>/dev/null +git clean -fdx &>/dev/null rm -rf .git rm -f cctools*.tar.* rm -f package.sh rm -f .gitignore +pushd cctools &>/dev/null +./autogen.sh +popd &>/dev/null popd &>/dev/null tar -cf - * | xz -9 -c - > $DIR/$PACKAGE.tar.xz diff --git a/tools/find_lto_header.sh b/tools/find_lto_header.sh deleted file mode 100755 index aee3a4a7..00000000 --- a/tools/find_lto_header.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -test -n "$DISABLE_LTO_SUPPORT" && exit 0 - -function try() -{ - LLVM_CONFIG="llvm-config$1" - which $LLVM_CONFIG &>/dev/null - - if [ $? -eq 0 ]; then - set -e - LLVM_INC_DIR=`$LLVM_CONFIG --includedir` - LLVM_LIB_DIR=`$LLVM_CONFIG --libdir` - # Adding the include directory with -I causes the build to fail. - ln -sf "$LLVM_INC_DIR/llvm-c/lto.h" "include/llvm-c/lto.h" - mkdir -p tmp - echo -n "-Wl,-rpath,$LLVM_LIB_DIR,--enable-new-dtags -L$LLVM_LIB_DIR -lLTO " > tmp/ldflags - echo -n "-DLTO_SUPPORT=1 " > tmp/cflags - echo -n "-DLTO_SUPPORT=1 " > tmp/cxxflags - echo -n "$LLVM_LIB_DIR" > tmp/ldpath - exit 0 - fi -} - -try "" -try "-3.2" -try "-3.3" -try "-3.4" -try "-3.5" -try "-3.6" -try "-devel" - -try "32" -try "33" -try "34" -try "35" -try "36" - -exit 1 diff --git a/tools/fix_unistd_issue.sh b/tools/fix_unistd_issue.sh index b56ecaa0..31adf87d 100755 --- a/tools/fix_unistd_issue.sh +++ b/tools/fix_unistd_issue.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +set -ex + +pushd "${0%/*}/../cctools" + find . -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.cc" -o -name "*.h" -o -name "*.hpp" \) -print0 | \ xargs -0 sed -i "s/#include /#undef __block\n#include \n#define __block __attribute__((__blocks__(byref)))/g"