diff --git a/README.md b/README.md index 054f5a5..627afdd 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,12 @@ Move your packaged SDK to the tarballs/ directory. Then ensure you have the following installed on your Linux/BSD box: -`Clang 3.2+`, `llvm-devel`, `patch`, `libxml2-devel` (<=10.5 only), -`uuid-devel`, `openssl-devel` and the `bash shell`. +`Clang 3.2+`, `patch`, `libxml2-devel` (<=10.6 only) and the `bash shell`. + +Optional: + +`llvm-devel`: For Link Time Optimization support +`uuid-devel`: For ld64 `-random_uuid` support \-- You can run 'sudo tools/get\_dependencies.sh' to get these automatically. @@ -198,6 +202,14 @@ can be overriden by explicitly passing `-stdlib=libstdc++` to clang. x86\_64h defaults to `Mac OS X 10.8` and requires clang 3.5+. x86\_64h = x86\_64 with optimizations for the Intel Haswell Architecture. +### BUILDING OSXCROSS WITH GCC: ### + +You can build OSXCross with GCC this way: + +`CC=gcc CXX=g++ ./build.sh` + +You will need gcc/g++/gcc-objc 4.6+. + ### LICENSE: #### * scripts/wrapper: GPLv2 * cctools/ld64: APSL 2.0 diff --git a/build.sh b/build.sh index 7c48b5c..4289b46 100755 --- a/build.sh +++ b/build.sh @@ -114,6 +114,7 @@ mkdir -p $SDK_DIR require $CC require $CXX + require clang require patch require sed @@ -135,7 +136,7 @@ if [ "$PLATFORM" == "Darwin" ]; then CXX+=" -stdlib=libc++" fi -res=`check_cxx_stdlib` +res=$(check_cxx_stdlib) if [ "$PLATFORM" == "Darwin" ]; then CXX=$PREVCXX @@ -143,18 +144,19 @@ if [ "$PLATFORM" == "Darwin" ]; then fi if [ $res -ne 0 ]; then - echo "Your C++ standard library is either broken or too old to build ld64-241.9" - echo "Building ld64-134.9 instead" - echo "" + echo "Your C++ standard library is either broken or too old to build ld64-241.9" 1>&2 + echo "Building ld64-134.9 instead" 1>&2 + echo "" 1>&2 sleep 3 LINKER_VERSION=134.9 else - LINKER_VERSION=241.9 + LINKER_VERSION=242 fi -CCTOOLS="cctools-862-ld64-$LINKER_VERSION" +CCTOOLS="cctools-870-ld64-$LINKER_VERSION" CCTOOLS_TARBALL=$(ls $TARBALL_DIR/$CCTOOLS*.tar.* | head -n1) -CCTOOLS_REVHASH=$(echo $(basename "$CCTOOLS_TARBALL") | tr '_' ' ' | tr '.' ' ' | awk '{print $3}') +CCTOOLS_REVHASH=$(echo $(basename "$CCTOOLS_TARBALL") | tr '_' '\n' | \ + tr '.' '\n' | tail -n3 | head -n1) if [ ! -f "have_cctools_${CCTOOLS_REVHASH}_$TARGET" ]; then @@ -169,14 +171,6 @@ pushd .. &>/dev/null popd &>/dev/null patch -p0 < $PATCH_DIR/cctools-ld64-1.patch patch -p0 < $PATCH_DIR/cctools-ld64-2.patch -patch -p1 < $PATCH_DIR/cctools-ld64-strnlen.patch -patch -p0 < $PATCH_DIR/cctools-ld64-llvm-3.7.patch -patch -p0 < $PATCH_DIR/cctools-ld64-abs-warning.patch -patch -p0 < $PATCH_DIR/cctools-ld64-rpath.patch -pushd .. &>/dev/null -patch -p0 < $PATCH_DIR/cctools-ld64-otool-disasm.patch -chmod +x tools/fix_liblto.sh -popd &>/dev/null echo "" CONFFLAGS="--prefix=$TARGET_DIR --target=x86_64-apple-$TARGET" [ -n "$DISABLE_LTO_SUPPORT" ] && CONFFLAGS+=" --enable-lto=no" diff --git a/patches/cctools-ld64-abs-warning.patch b/patches/cctools-ld64-abs-warning.patch deleted file mode 100644 index 4ebf025..0000000 --- a/patches/cctools-ld64-abs-warning.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- as/arm.c -+++ as/arm.c -@@ -17839,7 +17839,7 @@ - { - bfd_vma insn; - bfd_vma encoded_addend; -- bfd_vma addend_abs = abs (value); -+ bfd_vma addend_abs = abs ((int)value); - - /* Check that the absolute value of the addend can be - expressed as an 8-bit constant plus a rotation. */ -@@ -17884,7 +17884,7 @@ - #endif - { - bfd_vma insn; -- bfd_vma addend_abs = abs (value); -+ bfd_vma addend_abs = abs ((int)value); - - /* Check that the absolute value of the addend can be - encoded in 12 bits. */ -@@ -17927,7 +17927,7 @@ - #endif - { - bfd_vma insn; -- bfd_vma addend_abs = abs (value); -+ bfd_vma addend_abs = abs ((int)value); - - /* Check that the absolute value of the addend can be - encoded in 8 bits. */ -@@ -17971,7 +17971,7 @@ - #endif - { - bfd_vma insn; -- bfd_vma addend_abs = abs (value); -+ bfd_vma addend_abs = abs ((int)value); - - /* Check that the absolute value of the addend is a multiple of - four and, when divided by four, fits in 8 bits. */ diff --git a/patches/cctools-ld64-llvm-3.7.patch b/patches/cctools-ld64-llvm-3.7.patch deleted file mode 100644 index ae35139..0000000 --- a/patches/cctools-ld64-llvm-3.7.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- configure -+++ configure -@@ -8147,6 +8147,10 @@ - $RM -r conftest* - - -+## CAVEAT EMPTOR: -+## There is no encapsulation within the following macros, do not change -+## the running order or otherwise move them around unless you know exactly -+## what you are doing... - if test -n "$compiler"; then - - lt_prog_compiler_no_builtin_flag= -@@ -16686,10 +16690,12 @@ - - if test "x$enable_lto" = "xyes"; then - for ac_prog in 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 -+ llvm-config-3.7 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-config37 llvm-config36 llvm-config35 \ -+ llvm-config34 llvm-config33 llvm-config32 \ -+ llvm-config31 - do - # Extract the first word of "$ac_prog", so it can be a program name with args. - set dummy $ac_prog; ac_word=$2 ---- m4/llvm.m4 -+++ m4/llvm.m4 -@@ -8,10 +8,12 @@ - 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], -+ llvm-config-3.7 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-config37 llvm-config36 llvm-config35 \ -+ llvm-config34 llvm-config33 llvm-config32 \ -+ llvm-config31], - no) - - if test "x$LLVM_CONFIG" != "xno"; then diff --git a/patches/cctools-ld64-otool-disasm.patch b/patches/cctools-ld64-otool-disasm.patch deleted file mode 100644 index 70f529e..0000000 --- a/patches/cctools-ld64-otool-disasm.patch +++ /dev/null @@ -1,139 +0,0 @@ -diff --git cctools/libstuff/llvm.c cctools/libstuff/llvm.c -index 447140d..26b0a66 100644 ---- cctools/libstuff/llvm.c -+++ cctools/libstuff/llvm.c -@@ -14,7 +14,11 @@ - * plan to include it (along with the current libLTO APIs) in a generic - * libLLVM.dylib. - */ -+#ifdef __APPLE__ -+#define LIB_LLVM "libLTO.dylib" -+#else - #define LIB_LLVM "libLTO.so" -+#endif /* __APPLE__ */ - - static int tried_to_load_llvm = 0; - static void *llvm_handle = NULL; -@@ -62,12 +66,20 @@ static void load_llvm(void) - p[1] = '\0'; - llvm_path = makestr(prefix, "../lib/" LIB_LLVM, NULL); - -+#ifdef __APPLE__ - llvm_handle = dlopen(llvm_path, RTLD_NOW); - if(llvm_handle == NULL){ - free(llvm_path); - llvm_path = NULL; -- llvm_handle = dlopen("/usr/lib/llvm/" LIB_LLVM, RTLD_NOW); -+ llvm_handle = dlopen("/Applications/Xcode.app/Contents/" -+ "Developer/Toolchains/XcodeDefault." -+ "xctoolchain/usr/lib/" LIB_LLVM, -+ RTLD_NOW); - } -+#else -+ llvm_handle = dlopen(LIB_LLVM, RTLD_NOW); -+#endif /* __APPLE__ */ -+ - if(llvm_handle == NULL) - return; - -@@ -80,6 +92,13 @@ static void load_llvm(void) - createCPU = dlsym(llvm_handle, "LLVMCreateDisasmCPU"); - version = dlsym(llvm_handle, "lto_get_version"); - -+#ifndef __APPLE__ -+ if(create == NULL){ -+ fprintf(stderr, "Your " LIB_LLVM " lacks required symbols.\n"); -+ fprintf(stderr, "Please run: tools/fix_liblto.sh (or http://git.io/AyZP) to fix libLTO.\n"); -+ } -+#endif /* __APPLE__ */ -+ - if(create == NULL || - dispose == NULL || - disasm == NULL){ -diff --git tools/fix_liblto.sh tools/fix_liblto.sh -new file mode 100755 -index 0000000..6cb05e8 ---- /dev/null -+++ tools/fix_liblto.sh -@@ -0,0 +1,81 @@ -+#!/usr/bin/env bash -+## http://llvm.org/PR22677 -+ -+pushd "${0%/*}" &>/dev/null -+ -+if [ $(uname -s) == "Darwin" ]; then -+ echo "Darwin works out of the box." -+ exit 1 -+fi -+ -+if [ -z "$LLVM_CONFIG" ]; then -+ LLVM_CONFIG=llvm-config -+fi -+ -+which $LLVM_CONFIG &>/dev/null -+ -+if [ $? -ne 0 ]; then -+ echo -n "Cannot find $LLVM_CONFIG, you may want to try " 1>&2 -+ echo "LLVM_CONFIG=llvm-config $0" 1>&2 -+ exit 1 -+fi -+ -+LIBDIR=$($LLVM_CONFIG --libdir) -+INCDIR=$($LLVM_CONFIG --includedir) -+ -+V="$(readelf -Ws $LIBDIR/libLTO.so 2>/dev/null | grep LLVMCreateDisasm)" -+ -+if [ -n "$V" ]; then -+ echo "No fix needed." -+ exit 1 -+fi -+ -+VERSION=$($LLVM_CONFIG --version | awk -F \. {'print $1$2'} | sed 's/svn//g') -+ -+if [ $VERSION -lt 34 ]; then -+ echo "This tool requires LLVM 3.4 or later." 1>&2 -+ exit 1 -+fi -+ -+LIBS=$($LLVM_CONFIG --libs all) -+SYSLIBS=$($LLVM_CONFIG --system-libs 2>/dev/null || echo "-ldl -lz -ltinfo -pthread") -+CXXFLAGS=$($LLVM_CONFIG --cxxflags) -+ -+if [ $VERSION -ge 35 ]; then -+ SYSLIBS+=" -ledit" -+fi -+ -+set -e -+TMP=$(mktemp -d) -+set +e -+ -+pushd $TMP &>/dev/null -+wget https://raw.githubusercontent.com/llvm-mirror/llvm/release_$VERSION/tools/lto/lto.cpp -+wget https://raw.githubusercontent.com/llvm-mirror/llvm/release_$VERSION/tools/lto/LTODisassembler.cpp -+wget https://raw.githubusercontent.com/llvm-mirror/llvm/release_$VERSION/tools/lto/lto.exports -+ -+echo "{" > lto.ls -+echo " global:" >> lto.ls -+while read p; do -+ echo " $p;" >> lto.ls -+done < lto.exports -+echo " LLVM*;" >> lto.ls -+echo " local: *;" >> lto.ls -+echo "};" >> lto.ls -+popd &>/dev/null -+ -+set -x -+ -+clang++ -shared \ -+ -L$LIBDIR -I$INCDIR -Wl,--whole-archive $LIBS -Wl,--no-whole-archive $SYSLIBS \ -+ $CXXFLAGS $TMP/lto.cpp $TMP/LTODisassembler.cpp -Wl,-version-script,$TMP/lto.ls \ -+ -Wl,-no-undefined -fno-rtti -fPIC -o libLTO.so -+ -+rm -r $TMP -+ -+mv -f libLTO.so $LIBDIR || { -+ set +x -+ echo "Try again as root." -+ echo "Or run the following command by hand: mv $PWD/libLTO.so $LIBDIR" -+ exit 1 -+} diff --git a/patches/cctools-ld64-rpath.patch b/patches/cctools-ld64-rpath.patch deleted file mode 100644 index 034a7d2..0000000 --- a/patches/cctools-ld64-rpath.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- configure -+++ configure -@@ -16789,7 +16789,6 @@ - LTO_LIB="-L${LLVM_LIB_DIR} -lLTO" - if test "x$rpathlink" = "xyes"; then - LTO_RPATH="-Wl,-rpath,$LLVM_LIB_DIR,--enable-new-dtags" -- LTO_LIB="$LTO_RPATH $LTO_LIB" - fi - LTO_DEF=-DLTO_SUPPORT - # DO NOT include the LLVM include dir directly, -@@ -16813,6 +16812,8 @@ - - - -+LDFLAGS="$LDFLAGS $LTO_RPATH" -+ - ### Check endianness ### - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 ---- m4/llvm.m4 -+++ m4/llvm.m4 -@@ -27,7 +27,6 @@ - [ LTO_LIB="-L${LLVM_LIB_DIR} -lLTO" - if test "x$rpathlink" = "xyes"; then - LTO_RPATH="-Wl,-rpath,$LLVM_LIB_DIR,--enable-new-dtags" -- LTO_LIB="$LTO_RPATH $LTO_LIB" - fi - LTO_DEF=-DLTO_SUPPORT - # DO NOT include the LLVM include dir directly, diff --git a/patches/cctools-ld64-strnlen.patch b/patches/cctools-ld64-strnlen.patch deleted file mode 100644 index c40bbf9..0000000 --- a/patches/cctools-ld64-strnlen.patch +++ /dev/null @@ -1,67 +0,0 @@ -diff --git cctools/include/foreign/i386/_types.h cctools/include/foreign/i386/_types.h -index 601b196..8bffd6f 100644 ---- cctools/include/foreign/i386/_types.h -+++ cctools/include/foreign/i386/_types.h -@@ -33,6 +33,15 @@ - * flotaing point and other arithmetic types, as needed, later. - */ - -+/* -+ * Silence old glibc -Wtypedef-redefinition warnings. -+ * https://github.com/tpoechtrager/cctools-port/pull/8 -+ */ -+#ifdef __clang__ -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wtypedef-redefinition" -+#endif -+ - #ifdef __GNUC__ - typedef __signed char __int8_t; - #else /* !__GNUC__ */ -@@ -121,4 +130,8 @@ typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */ - typedef long __darwin_ssize_t; /* byte count or error */ - typedef long __darwin_time_t; /* time() */ - -+#ifdef __clang__ -+#pragma clang diagnostic pop -+#endif -+ - #endif /* _BSD_I386__TYPES_H_ */ -diff --git cctools/ld64/src/3rd/strlcat.c cctools/ld64/src/3rd/strlcat.c -index ef1a10a..faf09e3 100644 ---- cctools/ld64/src/3rd/strlcat.c -+++ cctools/ld64/src/3rd/strlcat.c -@@ -23,6 +23,14 @@ - - #ifndef __APPLE__ - -+/* -+ * Otherwise string.h may hide strnlen(). -+ * https://github.com/tpoechtrager/cctools-port/pull/8 -+ */ -+#ifndef _GNU_SOURCE -+#define _GNU_SOURCE -+#endif -+ - #include - - size_t -diff --git cctools/otool/ofile_print.c cctools/otool/ofile_print.c -index 3eb6506..4e9493a 100644 ---- cctools/otool/ofile_print.c -+++ cctools/otool/ofile_print.c -@@ -201,6 +201,14 @@ - #define __dr6 dr6 - #define __dr7 dr7 - -+/* -+ * Otherwise string.h may hide strnlen(). -+ * https://github.com/tpoechtrager/cctools-port/pull/8 -+ */ -+#ifndef _GNU_SOURCE -+#define _GNU_SOURCE -+#endif -+ - #include - #include - #include diff --git a/tarballs/cctools-862-ld64-134.9_6b0448a.tar.xz b/tarballs/cctools-862-ld64-134.9_6b0448a.tar.xz deleted file mode 100644 index 494b875..0000000 Binary files a/tarballs/cctools-862-ld64-134.9_6b0448a.tar.xz and /dev/null differ diff --git a/tarballs/cctools-862-ld64-241.9_2201b7b.tar.xz b/tarballs/cctools-862-ld64-241.9_2201b7b.tar.xz deleted file mode 100644 index 7876a7c..0000000 Binary files a/tarballs/cctools-862-ld64-241.9_2201b7b.tar.xz and /dev/null differ diff --git a/tarballs/cctools-870-ld64-134.9_46e5f8b.tar.xz b/tarballs/cctools-870-ld64-134.9_46e5f8b.tar.xz new file mode 100644 index 0000000..51fe2df Binary files /dev/null and b/tarballs/cctools-870-ld64-134.9_46e5f8b.tar.xz differ diff --git a/tarballs/cctools-870-ld64-242_9372d4c.tar.xz b/tarballs/cctools-870-ld64-242_9372d4c.tar.xz new file mode 100644 index 0000000..915822f Binary files /dev/null and b/tarballs/cctools-870-ld64-242_9372d4c.tar.xz differ diff --git a/tools/tools.sh b/tools/tools.sh index 6354404..451def4 100755 --- a/tools/tools.sh +++ b/tools/tools.sh @@ -11,13 +11,45 @@ PATCH_DIR=$BASE_DIR/patches SDK_DIR=$TARGET_DIR/SDK if [ -z "$USESYSTEMCOMPILER" ]; then - export CC=clang - export CXX=clang++ + # Default to gcc on some OSs rather than clang due to either + # libstdc++ issues (clang uses an outdated version on those) + # or some other incompatibilities + + case "$PLATFORM" in + CYGWIN* | DragonFly ) + cc=gcc + cxx=g++ + ;; + OpenBSD ) + cc=egcc + cxx=eg++ + ;; + Darwin ) + cc=clang + cxx=clang++ + ;; + * ) + case "$ARCH" in + arm* ) + cc=gcc + cxx=g++ + ;; + * ) + cc=clang + cxx=clang++ + ;; + esac + ;; + esac + + [ -z "$CC" ] && export CC=$cc + [ -z "$CXX" ] && export CXX=$cxx elif [ -n "$CC" -o -n "$CXX" ]; then echo "CC/CXX should not be set, continuing in 5 seconds..." 1>&2 sleep 5 fi + # enable debug messages test -n "$OCDEBUG" && set -x