Fix building with older clang compilers

This commit is contained in:
Thomas Pöchtrager 2019-11-04 20:25:36 +01:00
parent a889ea66b7
commit 406ce466ac
4 changed files with 50 additions and 18 deletions

9
cctools/configure vendored
View File

@ -2693,15 +2693,6 @@ case $host_cpu in
EXTRAFLAGS="$EXTRAFLAGS -D__arm64__"
;;
arm*)
case "$CXXVERSION" in
*clang* )
echo "" >&2
echo "clang is known to miscompile ld64 on arm platforms:" >&2
echo "https://github.com/tpoechtrager/cctools-port/issues/1#issuecomment-59118615" >&2
echo "" >&2
sleep 2
;;
esac
EXTRAFLAGS="$EXTRAFLAGS -D__arm__"
;;
esac

View File

@ -102,15 +102,6 @@ case $host_cpu in
EXTRAFLAGS="$EXTRAFLAGS -D__arm64__"
;;
arm*)
case "$CXXVERSION" in
*clang* )
echo "" >&2
echo "clang is known to miscompile ld64 on arm platforms:" >&2
echo "https://github.com/tpoechtrager/cctools-port/issues/1#issuecomment-59118615" >&2
echo "" >&2
sleep 2
;;
esac
EXTRAFLAGS="$EXTRAFLAGS -D__arm__"
;;
esac

View File

@ -90,6 +90,45 @@
#endif
#endif
#if defined(__clang_major__) && __clang_major__ == 3 && \
__clang_minor__ == 4
#ifndef __UINT8_TYPE__
#define __UINT8_TYPE__ unsigned char
#endif
#ifndef __UINT16_TYPE__
#define __UINT16_TYPE__ unsigned __INT16_TYPE__
#endif
#ifndef __UINT32_TYPE__
#define __UINT32_TYPE__ unsigned __INT32_TYPE__
#endif
#ifndef __UINT64_TYPE__
#define __UINT64_TYPE__ unsigned __INT64_TYPE__
#endif
#ifndef __UINTPTR_TYPE__
#define __UINTPTR_TYPE__ unsigned __INTPTR_TYPE__
#endif
/*
clang 3.4:
$ clang -target x86_64-unknown-linux -dM -E - < /dev/null|grep __INT8_TYPE__
#define __INT8_TYPE__ char
clang 3.5:
$ clang -target x86_64-unknown-linux -dM -E - < /dev/null|grep __INT8_TYPE__
#define __INT8_TYPE__ signed char
*/
#undef __INT8_TYPE__
#define __INT8_TYPE__ signed char
#endif /* clang 3.4 */
#ifndef _INT8_T
#define _INT8_T
typedef __INT8_TYPE__ int8_t;

View File

@ -1757,6 +1757,17 @@ typename A::P::uint_t Parser<A>::realAddr(typename A::P::uint_t addr)
return addr;
}
#if !__has_builtin(__builtin_mul_overflow) // ld64-port (clang < 3.8)
template<typename T>
bool __builtin_mul_overflow(uint32_t a, uint32_t b, T *r)
{
static_assert(sizeof(T) == sizeof(uint32_t), "");
uint64_t lr = a * b;
*r = (T)lr;
return lr > (uint64_t)uint32_t(-1);
}
#endif
#define STACK_ALLOC_IF_SMALL(_type, _name, _actual_count, _maxCount) \
_type* _name = NULL; \
uint32_t _name##_count = 1; \