diff --git a/README.md b/README.md index 8b419a2..0cd2972 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Apple cctools port for Linux and FreeBSD # +# Apple cctools port for Linux, FreeBSD and NetBSD # Current Version: 845 + ld64-136 Originally ported by cjacker from the [ios-toolchain-for-linux](https://code.google.com/p/ios-toolchain-based-on-clang-for-linux/) project. diff --git a/cctools/ar/contents.c b/cctools/ar/contents.c index b5bf05d..9df1a33 100644 --- a/cctools/ar/contents.c +++ b/cctools/ar/contents.c @@ -81,7 +81,9 @@ static char rcsid[] = "$OpenBSD: contents.c,v 1.2 1996/06/26 05:31:19 deraadt Ex #include "archive.h" #include "extern.h" +#ifndef HAVE_STRMODE extern void strmode(int mode, char *p); +#endif /* * contents -- diff --git a/cctools/configure.ac b/cctools/configure.ac index e02730e..737e9fc 100644 --- a/cctools/configure.ac +++ b/cctools/configure.ac @@ -10,11 +10,13 @@ AC_ARG_PROGRAM CC=clang CXX=clang++ -CFLAGS="$CFLAGS `cat tmp/cflags 2>/dev/null` -O3" -CXXFLAGS="$CXXFLAGS `cat tmp/libcxx-conf 2>/dev/null || echo -stdlib=libc++` `cat tmp/cxxflags 2>/dev/null` -O3" +CFLAGS="$CFLAGS `cat tmp/cflags 2>/dev/null`" +CFLAGS="$CFLAGS -isystem /usr/local/include -isystem /usr/pkg/include -O3" +CXXFLAGS="$CXXFLAGS `cat tmp/libcxx-conf 2>/dev/null || echo -stdlib=libc++` `cat tmp/cxxflags 2>/dev/null`" +CXXFLAGS="$CXXFLAGS -isystem /usr/local/include -isystem /usr/pkg/include -O3" + LDFLAGS="$LDFLAGS -L/usr/local/lib `cat tmp/ldflags 2>/dev/null`" export LD_LIBRARY_PATH="`cat tmp/ldpath 2>/dev/null`" -export C_INCLUDE_PATH="$C_INCLUDE_PATH:/usr/local/include" CPP="clang -E" @@ -225,6 +227,17 @@ AC_COMPILE_IFELSE( ) CFLAGS=$ORIGCFLAGS +ORIGCFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wno-char-subscripts" +AC_MSG_CHECKING([if -Wno-char-subscripts is supported]) +AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[const char hw[] = "Hello, World\n";]])], + [WARNINGS="$WARNINGS -Wno-char-subscripts" + AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])] +) +CFLAGS=$ORIGCFLAGS + AC_SUBST([WARNINGS], [$WARNINGS]) @@ -251,6 +264,8 @@ AC_SUBST(CRYPT_LIBS) 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]) AC_CONFIG_FILES([as/Makefile]) diff --git a/cctools/include/foreign/i386/endian.h b/cctools/include/foreign/i386/endian.h index 2dbebcb..2fbd938 100644 --- a/cctools/include/foreign/i386/endian.h +++ b/cctools/include/foreign/i386/endian.h @@ -96,9 +96,9 @@ #define BYTE_ORDER __DARWIN_BYTE_ORDER -#ifndef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include -#endif /* !__FreeBSD__ */ +#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */ #endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ #endif /* !_I386__ENDIAN_H_ */ diff --git a/cctools/include/foreign/i386/signal.h b/cctools/include/foreign/i386/signal.h index d729a28..5ddde95 100644 --- a/cctools/include/foreign/i386/signal.h +++ b/cctools/include/foreign/i386/signal.h @@ -40,9 +40,9 @@ typedef int sig_atomic_t; #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) #include -#endif /* __FreeBSD__ */ +#endif /* !__FreeBSD__ && !__NetBSD__ && !__OpenBSD__ */ #ifdef __APPLE_API_OBSOLETE diff --git a/cctools/include/foreign/i386/types.h b/cctools/include/foreign/i386/types.h index 80e9e80..13d95ec 100644 --- a/cctools/include/foreign/i386/types.h +++ b/cctools/include/foreign/i386/types.h @@ -67,6 +67,9 @@ #define _MACHTYPES_H_ #ifndef __ASSEMBLER__ +#if defined(__NetBSD__) || defined(__OpenBSD__) +#include_next /* __cpu_simple_lock_t */ +#endif /* __NetBSD__ || __OpenBSD__ */ #include #include /* @@ -90,9 +93,17 @@ typedef int int32_t; typedef unsigned int u_int32_t; #ifndef _INT64_T #define _INT64_T +#if !defined(__NetBSD__) && !defined(__OpenBSD__) typedef long long int64_t; +#else +typedef long int64_t; +#endif /* ! __NetBSD__ && !__OpenBSD__ */ #endif +#if !defined(__NetBSD__) && !defined(__OpenBSD__) typedef unsigned long long u_int64_t; +#else +typedef unsigned long u_int64_t; +#endif /* ! __NetBSD__ && !__OpenBSD__ */ #if __LP64__ typedef int64_t register_t; diff --git a/cctools/include/foreign/mach/vm_inherit.h b/cctools/include/foreign/mach/vm_inherit.h index d6440e4..27cf97b 100644 --- a/cctools/include/foreign/mach/vm_inherit.h +++ b/cctools/include/foreign/mach/vm_inherit.h @@ -72,7 +72,11 @@ * vm_inherit_t inheritance codes. */ -typedef unsigned int vm_inherit_t; /* might want to change this */ +#if defined(__NetBSD__) || defined(__OpenBSD__) +typedef int vm_inherit_t; /* might want to change this */ +#else +typedef unsigned int vm_inherit_t; /* might want to change this */ +#endif /* __NetBSD__ || __OpenBSD__ */ /* * Enumeration of valid values for vm_inherit_t. diff --git a/cctools/include/foreign/mach/vm_prot.h b/cctools/include/foreign/mach/vm_prot.h index 6fe17d4..e5c8c12 100644 --- a/cctools/include/foreign/mach/vm_prot.h +++ b/cctools/include/foreign/mach/vm_prot.h @@ -88,6 +88,7 @@ typedef int vm_prot_t; * The default protection for newly-created virtual memory */ +#undef VM_PROT_DEFAULT #define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE) /* diff --git a/cctools/include/foreign/machine/_limits.h b/cctools/include/foreign/machine/_limits.h index ef021a2..61ceec2 100644 --- a/cctools/include/foreign/machine/_limits.h +++ b/cctools/include/foreign/machine/_limits.h @@ -25,7 +25,7 @@ * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include_next #else #ifndef _BSD_MACHINE__LIMITS_H_ @@ -42,4 +42,4 @@ #endif #endif /* _BSD_MACHINE__LIMITS_H_ */ -#endif /* __FreeBSD__ */ +#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */ diff --git a/cctools/include/foreign/machine/_types.h b/cctools/include/foreign/machine/_types.h index d1b89b4..789a323 100644 --- a/cctools/include/foreign/machine/_types.h +++ b/cctools/include/foreign/machine/_types.h @@ -25,7 +25,7 @@ * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) #include_next #else #ifndef _BSD_MACHINE__TYPES_H_ diff --git a/cctools/include/foreign/machine/endian.h b/cctools/include/foreign/machine/endian.h index 9fd936a..2341cdd 100644 --- a/cctools/include/foreign/machine/endian.h +++ b/cctools/include/foreign/machine/endian.h @@ -28,7 +28,7 @@ /* * Copyright 1995 NeXT Computer, Inc. All rights reserved. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include_next #else #ifndef _BSD_MACHINE_ENDIAN_H_ @@ -45,4 +45,4 @@ #endif #endif /* _BSD_MACHINE_ENDIAN_H_ */ -#endif /* __FreeBSD__ */ +#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */ diff --git a/cctools/ld64/src/3rd/helper.c b/cctools/ld64/src/3rd/helper.c index 7d26f77..453fa09 100644 --- a/cctools/ld64/src/3rd/helper.c +++ b/cctools/ld64/src/3rd/helper.c @@ -14,7 +14,7 @@ #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include #endif @@ -27,6 +27,8 @@ void __assert_rtn(const char *func, const char *file, int line, const char *msg) { #ifdef __FreeBSD__ __assert(msg, file, line, func); +#elif defined(__NetBSD__) || defined(__OpenBSD__) + __assert(msg, line, file); #else __assert(msg, file, line); #endif /* __FreeBSD__ */ diff --git a/cctools/ld64/src/ld/ld.cpp b/cctools/ld64/src/ld/ld.cpp index 3c027a6..1511c5e 100644 --- a/cctools/ld64/src/ld/ld.cpp +++ b/cctools/ld64/src/ld/ld.cpp @@ -37,9 +37,9 @@ #include #include #include -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) #include -#endif /* __FreeBSD__ */ +#endif /* !__FreeBSD__ && !__NetBSD__ && !__OpenBSD__ */ #include #include #include @@ -756,7 +756,7 @@ int main(int argc, const char* argv[]) // implement assert() function to print out a backtrace before aborting void __assert_rtn(const char* func, const char* file, int line, const char* failedexpr) { -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) Snapshot *snapshot = Snapshot::globalSnapshot; snapshot->setSnapshotMode(Snapshot::SNAPSHOT_DEBUG); @@ -782,7 +782,7 @@ void __assert_rtn(const char* func, const char* file, int line, const char* fail snapshot->recordAssertionMessage("%d %p %s + %ld\n", i, callStack[i], symboName, offset); } fprintf(stderr, "A linker snapshot was created at:\n\t%s\n", snapshot->rootDir()); -#endif /* __FreeBSD__ */ +#endif /* !__FreeBSD__ && !__NetBSD__ && !__OpenBSD__ */ fprintf(stderr, "ld: Assertion failed: (%s), function %s, file %s, line %d.\n", failedexpr, func, file, line); exit(1); } diff --git a/cctools/libstuff/dylib_roots.c b/cctools/libstuff/dylib_roots.c index eb661b0..74b6519 100644 --- a/cctools/libstuff/dylib_roots.c +++ b/cctools/libstuff/dylib_roots.c @@ -32,6 +32,7 @@ #include #endif #include +#include #include "stuff/bool.h" #include "stuff/SymLoc.h" #include "stuff/ofile.h" diff --git a/package.sh b/package.sh index 6b3e7b6..0d9915b 100755 --- a/package.sh +++ b/package.sh @@ -3,7 +3,7 @@ set -ex DIR=`pwd` -PACKAGETMP=`mktemp -d` +PACKAGETMP=`mktemp -d /tmp/XXXXXXXX` REVHASH=`git rev-parse --short HEAD` CCTOOLSVER=`cat README.md | grep "Current Version: " | awk '{print $3}'` @@ -23,7 +23,7 @@ rm -f package.sh rm -f .gitignore popd &>/dev/null -XZ_OPT=-9 tar cJf $DIR/$PACKAGE.tar.xz * +tar -cf - * | xz -9 -c - > $DIR/$PACKAGE.tar.xz popd &>/dev/null diff --git a/tools/find_lto_header.sh b/tools/find_lto_header.sh index 665683d..6ce5979 100755 --- a/tools/find_lto_header.sh +++ b/tools/find_lto_header.sh @@ -26,6 +26,7 @@ try "-3.2" try "-3.3" try "-3.4" try "-3.5" +try "-devel" try "32" try "33"