* linux ppc/ppc64 & arm/arm64/aarch64 port

(compiles now - everything else is *untested*)

other changes:

* rename 'machochecker' to 'machocheck'
* get rid of duplicate $CFLAGS
* fix a typo in the ios toolchain README
* package.sh: remove the autom4te.cache directory
This commit is contained in:
Thomas Pöchtrager 2015-03-15 22:21:16 +01:00
parent 0c32be78e9
commit 42109667d4
22 changed files with 408 additions and 66 deletions

View File

@ -5,14 +5,18 @@ Originally ported by [cjacker](http://ios-toolchain-based-on-clang-for-linux.goo
## SUPPORTED HOSTS ## ## SUPPORTED HOSTS ##
Linux ** SUPPORTED OPERATING SYSTEMS: **
FreeBSD
NetBSD Linux, FreeBSD, NetBSD, OpenBSD, DragonFlyBSD,
OpenBSD Windows (Cygwin), Mac OS X and iOS
DragonFlyBSD
Windows (Cygwin) ** SUPPORTED HOST ARCHITECTURES: **
Mac OS X
iOS x86, x86_64
Untested, but compiles:
arm, aarch64, ppc, ppc64
## SUPPORTED TARGETS ## ## SUPPORTED TARGETS ##

View File

@ -3,7 +3,7 @@ libexec_PROGRAMS = i386-as
i386_as_LDADD = \ i386_as_LDADD = \
$(top_srcdir)/libstuff/libstuff.la $(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_DEF) -DNeXT_MOD -DASLIBEXECDIR="\"$(ASLIBEXECDIR)/\"" -D__DARWIN_UNIX03 -DI386 -Di486 -Di586 -Di686 $(ENDIAN_FLAG) 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 -UPPC $(ENDIAN_FLAG)
i386_as_SOURCES = ../app.c ../as.c ../atof-generic.c ../atof-ieee.c ../expr.c ../fixes.c ../flonum-const.c \ 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 \ ../flonum-copy.c ../flonum-mult.c ../frags.c ../hash.c ../hex-value.c ../input-file.c \

View File

@ -75,11 +75,17 @@
#define RELOC_PAIR SPARC_RELOC_PAIR #define RELOC_PAIR SPARC_RELOC_PAIR
#endif #endif
#if defined(M68K) || defined(I386) #if defined(M68K) || defined(I386)
#undef RELOC_SECTDIFF /* cctools-port: need to undef these to avoid warnings */
#undef RELOC_LOCAL_SECTDIFF
#undef RELOC_PAIR
#define RELOC_SECTDIFF GENERIC_RELOC_SECTDIFF #define RELOC_SECTDIFF GENERIC_RELOC_SECTDIFF
#define RELOC_LOCAL_SECTDIFF GENERIC_RELOC_LOCAL_SECTDIFF #define RELOC_LOCAL_SECTDIFF GENERIC_RELOC_LOCAL_SECTDIFF
#define RELOC_PAIR GENERIC_RELOC_PAIR #define RELOC_PAIR GENERIC_RELOC_PAIR
#endif #endif
#ifdef ARM #ifdef ARM
#undef RELOC_SECTDIFF /* cctools-port: need to undef these to avoid warnings */
#undef RELOC_LOCAL_SECTDIFF
#undef RELOC_PAIR
#define RELOC_SECTDIFF ARM_RELOC_SECTDIFF #define RELOC_SECTDIFF ARM_RELOC_SECTDIFF
#define RELOC_LOCAL_SECTDIFF ARM_RELOC_SECTDIFF #define RELOC_LOCAL_SECTDIFF ARM_RELOC_SECTDIFF
#define RELOC_PAIR ARM_RELOC_PAIR #define RELOC_PAIR ARM_RELOC_PAIR

View File

@ -93,7 +93,7 @@ case "`$CC --version`" in
WARNINGS="$WARNINGS -Wno-unused-but-set-variable -Wno-deprecated -Wno-deprecated-declarations" WARNINGS="$WARNINGS -Wno-unused-but-set-variable -Wno-deprecated -Wno-deprecated-declarations"
WARNINGS="$WARNINGS -Wno-char-subscripts -Wno-strict-aliasing" WARNINGS="$WARNINGS -Wno-char-subscripts -Wno-strict-aliasing"
OBJCWARNINGS="-Wall" OBJCWARNINGS="-Wall"
CFLAGS="$CFLAGS -std=gnu99 $CFLAGS -D__private_extern__= " CFLAGS="$CFLAGS -std=gnu99 -D__private_extern__="
CXXFLAGS="$CXXFLAGS -D__private_extern__=" CXXFLAGS="$CXXFLAGS -D__private_extern__="
;; ;;
esac esac
@ -112,6 +112,21 @@ case "`$CXX --version`" in
;; ;;
esac esac
case $target_cpu in
powerpc)
EXTRAFLAGS="$EXTRAFLAGS -D__ppc__"
;;
powerpc64*)
EXTRAFLAGS="$EXTRAFLAGS -D__ppc__ -D__ppc64__"
;;
arm64*|aarch64)
EXTRAFLAGS="$EXTRAFLAGS -D__arm64__"
;;
arm*)
EXTRAFLAGS="$EXTRAFLAGS -D__arm__"
;;
esac
if test "x$EXTRAFLAGS" != "x"; then if test "x$EXTRAFLAGS" != "x"; then
CFLAGS="$CFLAGS $EXTRAFLAGS" CFLAGS="$CFLAGS $EXTRAFLAGS"
OBJCFLAGS="$OBJCFLAGS $EXTRAFLAGS" OBJCFLAGS="$OBJCFLAGS $EXTRAFLAGS"
@ -162,13 +177,14 @@ fi
AC_CHECK_HEADERS([uuid/uuid.h], [], [AC_MSG_ERROR([*** uuid.h not found, please install uuid 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])])
#for libstuff emulated.c #for libstuff emulated.c
case $target_cpu in case $target_cpu in
powerpc) powerpc)
AC_DEFINE(EMULATED_HOST_CPU_TYPE, 18, [Emulated CPU type]) AC_DEFINE(EMULATED_HOST_CPU_TYPE, 18, [Emulated CPU type])
AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 100, [Emulated CPU subtype]) AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 100, [Emulated CPU subtype])
;; ;;
powerpc64) powerpc64*)
AC_DEFINE(EMULATED_HOST_CPU_TYPE, 16777234, [Emulated CPU type]) AC_DEFINE(EMULATED_HOST_CPU_TYPE, 16777234, [Emulated CPU type])
AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 0, [Emulated CPU subtype]) AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 0, [Emulated CPU subtype])
;; ;;
@ -180,7 +196,7 @@ case $target_cpu in
AC_DEFINE(EMULATED_HOST_CPU_TYPE, 16777223, [Emulated CPU type]) AC_DEFINE(EMULATED_HOST_CPU_TYPE, 16777223, [Emulated CPU type])
AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 3, [Emulated CPU subtype]) AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 3, [Emulated CPU subtype])
;; ;;
arm64*) arm64*|aarch64)
AC_DEFINE(EMULATED_HOST_CPU_TYPE, 16777228, [Emulated CPU type]) AC_DEFINE(EMULATED_HOST_CPU_TYPE, 16777228, [Emulated CPU type])
AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 0, [Emulated CPU subtype]) AC_DEFINE(EMULATED_HOST_CPU_SUBTYPE, 0, [Emulated CPU subtype])
;; ;;
@ -203,7 +219,7 @@ AC_SUBST([ASLIBEXECDIR], ['${libexecdir}/as'])
# set PROGRAM PREFIX # set PROGRAM PREFIX
if test "$target_alias"; then if test "$target_alias"; then
AC_SUBST([PROGRAM_PREFIX], ['${target_alias}-']) AC_SUBST([PROGRAM_PREFIX], ['${target_alias}-'])
fi fi
AC_CHECK_LIB([dl],[dlopen],[DL_LIB=-ldl]) AC_CHECK_LIB([dl],[dlopen],[DL_LIB=-ldl])
@ -213,8 +229,8 @@ AC_CHECK_LIB([pthread],[pthread_create],[PTHREAD_FLAGS=-pthread])
AC_SUBST(PTHREAD_FLAGS) AC_SUBST(PTHREAD_FLAGS)
if test "x$isdarwin" = "xno"; then if test "x$isdarwin" = "xno"; then
AC_CHECK_LIB([uuid],[uuid_generate_random],[UUID_LIB=-luuid],[exit 1]) AC_CHECK_LIB([uuid],[uuid_generate_random],[UUID_LIB=-luuid],[exit 1])
AC_SUBST(UUID_LIB) AC_SUBST(UUID_LIB)
fi fi
AC_CHECK_LIB([execinfo],[backtrace],[DL_LIB=-lexecinfo]) AC_CHECK_LIB([execinfo],[backtrace],[DL_LIB=-lexecinfo])
@ -238,7 +254,7 @@ AC_SUBST(CXXABI_LIB)
ORIGLDFLAGS=$LDFLAGS ORIGLDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/lib,--enable-new-dtags" LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/lib,--enable-new-dtags"
AC_MSG_CHECKING([if -Wl,-rpath,<path>,--enable-new-dtags is supported]) AC_MSG_CHECKING([if -Wl,-rptah,<path>,--enable-new-dtags is supported])
AC_LINK_IFELSE( AC_LINK_IFELSE(
[AC_LANG_SOURCE([[int main(){}]])], [AC_LANG_SOURCE([[int main(){}]])],
[rpathlink=yes [rpathlink=yes

1
cctools/include/foreign/arm Symbolic link
View File

@ -0,0 +1 @@
i386/

View File

@ -82,7 +82,8 @@ __inline static
int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue ) int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue )
{ return OSAtomicAdd32Barrier( -1, __theValue); } { return OSAtomicAdd32Barrier( -1, __theValue); }
#if defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__) /* cctools-port: added defined(__ppc__) || */
#if defined(__ppc__) || defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__)
int64_t OSAtomicAdd64( int64_t __theAmount, volatile int64_t *__theValue ); int64_t OSAtomicAdd64( int64_t __theAmount, volatile int64_t *__theValue );
int64_t OSAtomicAdd64Barrier( int64_t __theAmount, volatile int64_t *__theValue ); int64_t OSAtomicAdd64Barrier( int64_t __theAmount, volatile int64_t *__theValue );
@ -101,7 +102,7 @@ __inline static
int64_t OSAtomicDecrement64Barrier( volatile int64_t *__theValue ) int64_t OSAtomicDecrement64Barrier( volatile int64_t *__theValue )
{ return OSAtomicAdd64Barrier( -1, __theValue); } { return OSAtomicAdd64Barrier( -1, __theValue); }
#endif /* defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__) */ #endif /* defined(__ppc__) || defined(__ppc64__) || defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__) */
/* Boolean functions (and, or, xor.) These come in four versions for each operation: /* Boolean functions (and, or, xor.) These come in four versions for each operation:

View File

@ -0,0 +1,130 @@
#ifndef _OS_OSBYTEORDERARM_H
#define _OS_OSBYTEORDERARM_H
#include <stdint.h>
#ifndef OS_INLINE
#define OS_INLINE static __inline__
#endif
OS_INLINE
uint16_t _OSSwapInt16(uint16_t data)
{
return __builtin_bswap16(data);
}
OS_INLINE
uint32_t _OSSwapInt32(uint32_t data)
{
return __builtin_bswap32(data);
}
OS_INLINE
uint64_t _OSSwapInt64(uint64_t data)
{
return __builtin_bswap64(data);
}
/*
* Copyright (c) 1999-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
OS_INLINE
uint16_t
OSReadSwapInt16(
const volatile void * base,
uintptr_t byteOffset
)
{
uint16_t result;
result = *(volatile uint16_t *)((uintptr_t)base + byteOffset);
return _OSSwapInt16(result);
}
OS_INLINE
uint32_t
OSReadSwapInt32(
const volatile void * base,
uintptr_t byteOffset
)
{
uint32_t result;
result = *(volatile uint32_t *)((uintptr_t)base + byteOffset);
return _OSSwapInt32(result);
}
OS_INLINE
uint64_t
OSReadSwapInt64(
const volatile void * base,
uintptr_t byteOffset
)
{
uint64_t result;
result = *(volatile uint64_t *)((uintptr_t)base + byteOffset);
return _OSSwapInt64(result);
}
/* Functions for byte reversed stores. */
OS_INLINE
void
OSWriteSwapInt16(
volatile void * base,
uintptr_t byteOffset,
uint16_t data
)
{
*(volatile uint16_t *)((uintptr_t)base + byteOffset) = _OSSwapInt16(data);
}
OS_INLINE
void
OSWriteSwapInt32(
volatile void * base,
uintptr_t byteOffset,
uint32_t data
)
{
*(volatile uint32_t *)((uintptr_t)base + byteOffset) = _OSSwapInt32(data);
}
OS_INLINE
void
OSWriteSwapInt64(
volatile void * base,
uintptr_t byteOffset,
uint64_t data
)
{
*(volatile uint64_t *)((uintptr_t)base + byteOffset) = _OSSwapInt64(data);
}
#endif /* ! _OS_OSBYTEORDERARM_H */

View File

@ -0,0 +1,91 @@
/*
* Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _OS__OSBYTEORDER_H
#define _OS__OSBYTEORDER_H
/*
* This header is normally included from <libkern/OSByteOrder.h>. However,
* <sys/_endian.h> also includes this in the case of little-endian
* architectures, so that we can map OSByteOrder routines to the hton* and ntoh*
* macros. This results in the asymmetry below; we only include
* <libkern/arch/_OSByteOrder.h> for little-endian architectures.
*/
#include <sys/_types.h>
/* Macros for swapping constant values in the preprocessing stage. */
#define __DARWIN_OSSwapConstInt16(x) \
((__uint16_t)((((__uint16_t)(x) & 0xff00) >> 8) | \
(((__uint16_t)(x) & 0x00ff) << 8)))
#define __DARWIN_OSSwapConstInt32(x) \
((__uint32_t)((((__uint32_t)(x) & 0xff000000) >> 24) | \
(((__uint32_t)(x) & 0x00ff0000) >> 8) | \
(((__uint32_t)(x) & 0x0000ff00) << 8) | \
(((__uint32_t)(x) & 0x000000ff) << 24)))
#define __DARWIN_OSSwapConstInt64(x) \
((__uint64_t)((((__uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \
(((__uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
(((__uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \
(((__uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
(((__uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
(((__uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
(((__uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \
(((__uint64_t)(x) & 0x00000000000000ffULL) << 56)))
#if defined(__GNUC__)
#if defined (__arm__) || defined(__arm64__)
#include <libkern/arm/OSByteOrder.h>
#endif
#define __DARWIN_OSSwapInt16(x) \
((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
#define __DARWIN_OSSwapInt32(x) \
(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt32(x) : _OSSwapInt32(x))
#define __DARWIN_OSSwapInt64(x) \
(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x))
#else /* ! __GNUC__ */
#define __DARWIN_OSSwapInt16(x) _OSSwapInt16(x)
#define __DARWIN_OSSwapInt32(x) _OSSwapInt32(x)
#define __DARWIN_OSSwapInt64(x) _OSSwapInt64(x)
#endif /* __GNUC__ */
#endif /* ! _OS__OSBYTEORDER_H */

View File

@ -0,0 +1 @@
i386/

View File

@ -93,7 +93,14 @@
typedef __darwin_natural_t natural_t; typedef __darwin_natural_t natural_t;
typedef int integer_t; typedef int integer_t;
#if defined(__ppc__) /*
* cctools-port: Added !defined(__ppc64__) because of:
* $ clang -target powerpc64le-linux-gnu -dM -E - < /dev/null | grep ppc
* #define __ppc64__ 1
* #define __ppc__ 1
*/
#if defined(__ppc__) && !defined(__ppc64__)
/* /*
* For 32-bit PowerPC ABIs, the scalable types were * For 32-bit PowerPC ABIs, the scalable types were

View File

@ -43,8 +43,19 @@ typedef short __int16_t;
typedef unsigned short __uint16_t; typedef unsigned short __uint16_t;
typedef int __int32_t; typedef int __int32_t;
typedef unsigned int __uint32_t; typedef unsigned int __uint32_t;
typedef long long __int64_t;
typedef unsigned long long __uint64_t; #ifdef __INT64_TYPE__
typedef __INT64_TYPE__ __int64_t;
typedef unsigned __INT64_TYPE__ __uint64_t;
#else
#if __SIZEOF_POINTER__ == 8 && !defined(__CYGWIN__)
typedef long int __int64_t;
typedef unsigned long int __uint64_t;
#else
typedef long long int __int64_t;
typedef unsigned long long int __uint64_t;
#endif
#endif
typedef long __darwin_intptr_t; typedef long __darwin_intptr_t;
typedef unsigned int __darwin_natural_t; typedef unsigned int __darwin_natural_t;
@ -73,12 +84,14 @@ typedef int __darwin_ct_rune_t; /* ct_rune_t */
* mbstate_t is an opaque object to keep conversion state, during multibyte * mbstate_t is an opaque object to keep conversion state, during multibyte
* stream conversions. The content must not be referenced by user programs. * stream conversions. The content must not be referenced by user programs.
*/ */
#if defined(__APPLE__)
typedef union { typedef union {
char __mbstate8[128]; char __mbstate8[128];
long long _mbstateL; /* for alignment */ long long _mbstateL; /* for alignment */
} __mbstate_t; } __mbstate_t;
typedef __mbstate_t __darwin_mbstate_t; /* mbstate_t */ typedef __mbstate_t __darwin_mbstate_t; /* mbstate_t */
#endif
#if defined(__GNUC__) && defined(__PTRDIFF_TYPE__) #if defined(__GNUC__) && defined(__PTRDIFF_TYPE__)
typedef __PTRDIFF_TYPE__ __darwin_ptrdiff_t; /* ptr1 - ptr2 */ typedef __PTRDIFF_TYPE__ __darwin_ptrdiff_t; /* ptr1 - ptr2 */

View File

@ -112,13 +112,21 @@
#if defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) #if defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
// cctools-port
#undef LITTLE_ENDIAN
#undef BIG_ENDIAN
#undef PDP_ENDIAN
#undef BYTE_ORDER
#define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN #define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
#define BIG_ENDIAN __DARWIN_BIG_ENDIAN #define BIG_ENDIAN __DARWIN_BIG_ENDIAN
#define PDP_ENDIAN __DARWIN_PDP_ENDIAN #define PDP_ENDIAN __DARWIN_PDP_ENDIAN
#define BYTE_ORDER __DARWIN_BYTE_ORDER #define BYTE_ORDER __DARWIN_BYTE_ORDER
#if defined(__has_include) && __has_include(<sys/_endian.h>) /* cctools-port */
#include <sys/_endian.h> #include <sys/_endian.h>
#endif
#endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ #endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */
#endif /* !_PPC_ENDIAN_H_ */ #endif /* !_PPC_ENDIAN_H_ */

View File

@ -50,6 +50,11 @@
#include <mach/i386/thread_status.h> #include <mach/i386/thread_status.h>
#include <mach/hppa/thread_status.h> #include <mach/hppa/thread_status.h>
#include <mach/sparc/thread_status.h> #include <mach/sparc/thread_status.h>
/* cctools-port: need to undef these to avoid warnings */
#undef MACHINE_THREAD_STATE
#undef MACHINE_THREAD_STATE_COUNT
#undef THREAD_STATE_NONE
#undef VALID_THREAD_STATE_FLAVOR
#include <mach/arm/thread_status.h> #include <mach/arm/thread_status.h>
#include <mach-o/nlist.h> #include <mach-o/nlist.h>
#include <mach-o/reloc.h> #include <mach-o/reloc.h>

View File

@ -38,28 +38,28 @@ void __assert_rtn(const char *func, const char *file, int line, const char *msg)
int _NSGetExecutablePath(char *path, unsigned int *size) int _NSGetExecutablePath(char *path, unsigned int *size)
{ {
#ifdef __FreeBSD__ #ifdef __FreeBSD__
int mib[4]; int mib[4];
mib[0] = CTL_KERN; mib[0] = CTL_KERN;
mib[1] = KERN_PROC; mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PATHNAME; mib[2] = KERN_PROC_PATHNAME;
mib[3] = -1; mib[3] = -1;
size_t cb = *size; size_t cb = *size;
if (sysctl(mib, 4, path, &cb, NULL, 0) != 0) if (sysctl(mib, 4, path, &cb, NULL, 0) != 0)
return -1; return -1;
*size = cb; *size = cb;
return 0; return 0;
#else #else
int bufsize = *size; int bufsize = *size;
int ret_size; int ret_size;
ret_size = readlink("/proc/self/exe", path, bufsize-1); ret_size = readlink("/proc/self/exe", path, bufsize-1);
if (ret_size != -1) if (ret_size != -1)
{ {
*size = ret_size; *size = ret_size;
path[ret_size]=0; path[ret_size]=0;
return 0; return 0;
} }
else else
return -1; return -1;
#endif #endif
} }
@ -70,36 +70,71 @@ int _dyld_find_unwind_sections(void* i, struct dyld_unwind_sections* sec)
mach_port_t mach_host_self(void) mach_port_t mach_host_self(void)
{ {
return 0; return 0;
} }
kern_return_t host_statistics ( host_t host_priv, host_flavor_t flavor, host_info_t host_info_out, mach_msg_type_number_t *host_info_outCnt) kern_return_t host_statistics ( host_t host_priv, host_flavor_t flavor, host_info_t host_info_out, mach_msg_type_number_t *host_info_outCnt)
{ {
return ENOTSUP; return ENOTSUP;
} }
uint64_t mach_absolute_time(void) { uint64_t mach_absolute_time(void)
uint64_t t = 0;
struct timeval tv;
if (gettimeofday(&tv,NULL)) return t;
t = ((uint64_t)tv.tv_sec << 32) | tv.tv_usec;
return t;
}
kern_return_t mach_timebase_info( mach_timebase_info_t info) {
info->numer = 1;
info->denom = 1;
return 0;
}
int32_t OSAtomicAdd32( int32_t theAmount, volatile int32_t *theValue )
{ {
__sync_fetch_and_add(theValue, theAmount); uint64_t t = 0;
return *theValue; struct timeval tv;
if (gettimeofday(&tv,NULL)) return t;
t = ((uint64_t)tv.tv_sec << 32) | tv.tv_usec;
return t;
} }
int64_t OSAtomicAdd64(int64_t theAmount, volatile int64_t *theValue) {
__sync_fetch_and_add(theValue, theAmount); kern_return_t mach_timebase_info( mach_timebase_info_t info)
return *theValue; {
info->numer = 1;
info->denom = 1;
return 0;
}
#if defined(__ppc__) && !defined(__ppc64__)
/*
* __sync_fetch_and_add_8 is missing on ppc 32-bit for some reason.
*/
#include <pthread.h>
static pthread_mutex_t lock;
__attribute__((constructor (101)))
static void init_mutex() { pthread_mutex_init(&lock, NULL); }
int64_t __clang_does_not_like_redeclaring_sync_fetch_and_add_8(
volatile int64_t *ptr, int64_t value, ...)
{
pthread_mutex_lock(&lock);
*ptr = value;
pthread_mutex_unlock(&lock);
return *ptr;
}
asm
(
".global __sync_fetch_and_add_8\n"
".weak __sync_fetch_and_add_8\n"
".type __sync_fetch_and_add_8, @function\n"
"__sync_fetch_and_add_8:\n"
"b __clang_does_not_like_redeclaring_sync_fetch_and_add_8\n"
".size __sync_fetch_and_add_8, .-__sync_fetch_and_add_8"
);
#endif /* __ppc__ && !__ppc64__ */
int32_t OSAtomicAdd32(int32_t __theAmount, volatile int32_t *__theValue)
{
return __sync_fetch_and_add(__theValue, __theAmount);
}
int64_t OSAtomicAdd64(int64_t __theAmount, volatile int64_t *__theValue)
{
return __sync_fetch_and_add(__theValue, __theAmount);
} }
#endif /* __APPLE__ */ #endif /* __APPLE__ */

View File

@ -813,9 +813,13 @@ void InputFiles::inferArchitecture(Options& opts, const char** archName)
opts.setArchitecture(CPU_TYPE_I386, CPU_SUBTYPE_X86_ALL); opts.setArchitecture(CPU_TYPE_I386, CPU_SUBTYPE_X86_ALL);
#elif __x86_64__ #elif __x86_64__
opts.setArchitecture(CPU_TYPE_X86_64, CPU_SUBTYPE_X86_64_ALL); opts.setArchitecture(CPU_TYPE_X86_64, CPU_SUBTYPE_X86_64_ALL);
#elif __ppc__ // ld64-port
opts.setArchitecture(CPU_TYPE_POWERPC, CPU_SUBTYPE_POWERPC_ALL);
#elif __ppc64__ // ld64-port
opts.setArchitecture(CPU_TYPE_POWERPC64, CPU_SUBTYPE_POWERPC_ALL);
#elif __arm__ #elif __arm__
opts.setArchitecture(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V6); opts.setArchitecture(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V6);
#elif __arm64__ #elif __arm64__ // ld64-port
opts.setArchitecture(CPU_TYPE_ARM, CPU_SUBTYPE_ARM64_ALL); opts.setArchitecture(CPU_TYPE_ARM, CPU_SUBTYPE_ARM64_ALL);
#else #else
#error unknown default architecture #error unknown default architecture

View File

@ -2,7 +2,7 @@ bin_PROGRAMS = \
dyldinfo \ dyldinfo \
ObjectDump \ ObjectDump \
unwinddump \ unwinddump \
machochecker machocheck
AM_CXXFLAGS = \ AM_CXXFLAGS = \
-D__DARWIN_UNIX03 \ -D__DARWIN_UNIX03 \
@ -34,7 +34,7 @@ AM_CFLAGS = \
-I$(top_srcdir)/ld64/src/ld/passes -I$(top_srcdir)/ld64/src/ld/passes
unwinddump_SOURCES = unwinddump.cpp unwinddump_SOURCES = unwinddump.cpp
machochecker_SOURCES = machochecker.cpp machocheck_SOURCES = machochecker.cpp
ObjectDump_SOURCES = \ ObjectDump_SOURCES = \
ObjectDump.cpp \ ObjectDump.cpp \
$(top_srcdir)/ld64/src/ld/debugline.c $(top_srcdir)/ld64/src/ld/debugline.c

View File

@ -200,6 +200,11 @@
#include <mach/i386/thread_status.h> #include <mach/i386/thread_status.h>
#include <mach/hppa/thread_status.h> #include <mach/hppa/thread_status.h>
#include <mach/sparc/thread_status.h> #include <mach/sparc/thread_status.h>
/* cctools-port: need to undef these to avoid warnings */
#undef MACHINE_THREAD_STATE
#undef MACHINE_THREAD_STATE_COUNT
#undef THREAD_STATE_NONE
#undef VALID_THREAD_STATE_FLAVOR
#include <mach/arm/thread_status.h> #include <mach/arm/thread_status.h>
#include <mach-o/nlist.h> #include <mach-o/nlist.h>
#include <mach-o/reloc.h> #include <mach-o/reloc.h>

View File

@ -112,11 +112,15 @@ use_default:
/* /*
* The default value is the version of the running OS. * The default value is the version of the running OS.
*/ */
#ifdef __APPLE__
osversion_name[0] = CTL_KERN; osversion_name[0] = CTL_KERN;
osversion_name[1] = KERN_OSRELEASE; osversion_name[1] = KERN_OSRELEASE;
osversion_len = sizeof(osversion) - 1; osversion_len = sizeof(osversion) - 1;
if(sysctl(osversion_name, 2, osversion, &osversion_len, NULL, 0) == -1) if(sysctl(osversion_name, 2, osversion, &osversion_len, NULL, 0) == -1)
system_error("sysctl for kern.osversion failed"); system_error("sysctl for kern.osversion failed");
#else
memcpy(osversion, "10.5", 5); /* cctools-port: claim we are on 10.5 */
#endif
/* /*
* Now parse this out. It is expected to be of the form "x.y.z" where * Now parse this out. It is expected to be of the form "x.y.z" where

View File

@ -60,6 +60,11 @@
#include <mach/i860/thread_status.h> #include <mach/i860/thread_status.h>
#include <mach/i386/thread_status.h> #include <mach/i386/thread_status.h>
#include <mach/sparc/thread_status.h> #include <mach/sparc/thread_status.h>
/* cctools-port: need to undef these to avoid warnings */
#undef MACHINE_THREAD_STATE
#undef MACHINE_THREAD_STATE_COUNT
#undef THREAD_STATE_NONE
#undef VALID_THREAD_STATE_FLAVOR
#include <mach/arm/thread_status.h> #include <mach/arm/thread_status.h>
#include <mach-o/nlist.h> #include <mach-o/nlist.h>
#include <mach-o/reloc.h> #include <mach-o/reloc.h>

View File

@ -40,6 +40,11 @@
#include <mach/i386/thread_status.h> #include <mach/i386/thread_status.h>
#include <mach/hppa/thread_status.h> #include <mach/hppa/thread_status.h>
#include <mach/sparc/thread_status.h> #include <mach/sparc/thread_status.h>
/* cctools-port: need to undef these to avoid warnings */
#undef MACHINE_THREAD_STATE
#undef MACHINE_THREAD_STATE_COUNT
#undef THREAD_STATE_NONE
#undef VALID_THREAD_STATE_FLAVOR
#include <mach/arm/thread_status.h> #include <mach/arm/thread_status.h>
#include "stuff/bool.h" #include "stuff/bool.h"
#include "stuff/bytesex.h" #include "stuff/bytesex.h"

View File

@ -24,6 +24,7 @@ rm -f package.sh
rm -f .gitignore rm -f .gitignore
pushd cctools &>/dev/null pushd cctools &>/dev/null
./autogen.sh ./autogen.sh
rm -rf autom4te.cache
popd &>/dev/null popd &>/dev/null
popd &>/dev/null popd &>/dev/null

View File

@ -6,7 +6,7 @@ USAGE:
./build.sh /path/to/sdk.tar.* <target cpu> ./build.sh /path/to/sdk.tar.* <target cpu>
Target CPU should be one of arm6, armv7, armv7s and arm64. Target CPU should be one of armv6, armv7, armv7s and arm64.
This will build an iOS toolchain prefixed with This will build an iOS toolchain prefixed with
arm-apple-darwin11-* arm-apple-darwin11-*