Skip to content

Commit

Permalink
* linux ppc/ppc64 & arm/arm64/aarch64 port
Browse files Browse the repository at this point in the history
  (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
  • Loading branch information
tpoechtrager committed Mar 15, 2015
1 parent 0c32be7 commit 4210966
Show file tree
Hide file tree
Showing 22 changed files with 404 additions and 62 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ Originally ported by [cjacker](http://ios-toolchain-based-on-clang-for-linux.goo

## SUPPORTED HOSTS ##

Linux
FreeBSD
NetBSD
OpenBSD
DragonFlyBSD
Windows (Cygwin)
Mac OS X
iOS
** SUPPORTED OPERATING SYSTEMS: **

Linux, FreeBSD, NetBSD, OpenBSD, DragonFlyBSD,
Windows (Cygwin), Mac OS X and iOS

** SUPPORTED HOST ARCHITECTURES: **

x86, x86_64

Untested, but compiles:

arm, aarch64, ppc, ppc64

## SUPPORTED TARGETS ##

Expand Down
2 changes: 1 addition & 1 deletion cctools/as/i386/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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_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 \
../flonum-copy.c ../flonum-mult.c ../frags.c ../hash.c ../hex-value.c ../input-file.c \
Expand Down
6 changes: 6 additions & 0 deletions cctools/as/write_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@
#define RELOC_PAIR SPARC_RELOC_PAIR
#endif
#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_LOCAL_SECTDIFF GENERIC_RELOC_LOCAL_SECTDIFF
#define RELOC_PAIR GENERIC_RELOC_PAIR
#endif
#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_LOCAL_SECTDIFF ARM_RELOC_SECTDIFF
#define RELOC_PAIR ARM_RELOC_PAIR
Expand Down
30 changes: 23 additions & 7 deletions cctools/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ case "`$CC --version`" in
WARNINGS="$WARNINGS -Wno-unused-but-set-variable -Wno-deprecated -Wno-deprecated-declarations"
WARNINGS="$WARNINGS -Wno-char-subscripts -Wno-strict-aliasing"
OBJCWARNINGS="-Wall"
CFLAGS="$CFLAGS -std=gnu99 $CFLAGS -D__private_extern__= "
CFLAGS="$CFLAGS -std=gnu99 -D__private_extern__="
CXXFLAGS="$CXXFLAGS -D__private_extern__="
;;
esac
Expand All @@ -112,6 +112,21 @@ case "`$CXX --version`" in
;;
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
CFLAGS="$CFLAGS $EXTRAFLAGS"
OBJCFLAGS="$OBJCFLAGS $EXTRAFLAGS"
Expand Down Expand Up @@ -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])])


#for libstuff emulated.c
case $target_cpu in
powerpc)
AC_DEFINE(EMULATED_HOST_CPU_TYPE, 18, [Emulated CPU type])
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_SUBTYPE, 0, [Emulated CPU subtype])
;;
Expand All @@ -180,7 +196,7 @@ case $target_cpu in
AC_DEFINE(EMULATED_HOST_CPU_TYPE, 16777223, [Emulated CPU type])
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_SUBTYPE, 0, [Emulated CPU subtype])
;;
Expand All @@ -203,7 +219,7 @@ AC_SUBST([ASLIBEXECDIR], ['${libexecdir}/as'])

# set PROGRAM PREFIX
if test "$target_alias"; then
AC_SUBST([PROGRAM_PREFIX], ['${target_alias}-'])
AC_SUBST([PROGRAM_PREFIX], ['${target_alias}-'])
fi

AC_CHECK_LIB([dl],[dlopen],[DL_LIB=-ldl])
Expand All @@ -213,8 +229,8 @@ AC_CHECK_LIB([pthread],[pthread_create],[PTHREAD_FLAGS=-pthread])
AC_SUBST(PTHREAD_FLAGS)

if test "x$isdarwin" = "xno"; then
AC_CHECK_LIB([uuid],[uuid_generate_random],[UUID_LIB=-luuid],[exit 1])
AC_SUBST(UUID_LIB)
AC_CHECK_LIB([uuid],[uuid_generate_random],[UUID_LIB=-luuid],[exit 1])
AC_SUBST(UUID_LIB)
fi

AC_CHECK_LIB([execinfo],[backtrace],[DL_LIB=-lexecinfo])
Expand All @@ -238,7 +254,7 @@ AC_SUBST(CXXABI_LIB)

ORIGLDFLAGS=$LDFLAGS
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_LANG_SOURCE([[int main(){}]])],
[rpathlink=yes
Expand Down
1 change: 1 addition & 0 deletions cctools/include/foreign/arm
5 changes: 3 additions & 2 deletions cctools/include/foreign/libkern/OSAtomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ __inline static
int32_t OSAtomicDecrement32Barrier( volatile int32_t *__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 OSAtomicAdd64Barrier( int64_t __theAmount, volatile int64_t *__theValue );
Expand All @@ -101,7 +102,7 @@ __inline static
int64_t OSAtomicDecrement64Barrier( volatile int64_t *__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:
Expand Down
130 changes: 130 additions & 0 deletions cctools/include/foreign/libkern/arm/OSByteOrder.h
Original file line number Diff line number Diff line change
@@ -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 */
91 changes: 91 additions & 0 deletions cctools/include/foreign/libkern/arm/_OSByteOrder.h
Original file line number Diff line number Diff line change
@@ -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 */
1 change: 1 addition & 0 deletions cctools/include/foreign/mach/arm
Loading

0 comments on commit 4210966

Please sign in to comment.