Update cctools to 877.5 and ld64 to 253.3

This finally adds support for Xcode 7 / El Capitan.

With this commit I am also removing ld64-134.9 support.
I kept ld64-134.9 for users with an old C++ standard library.
A decent C++ standard library with C++11 support is now mandatory.
This commit is contained in:
Thomas Pöchtrager 2015-10-24 17:50:27 +02:00
parent 6aa6f7941b
commit a4e9a2aea8
12 changed files with 29 additions and 460 deletions

View File

@ -1,3 +1,12 @@
/****************************** v0.12 ********************************/
changed:
* updated cctools to 877.5
* updated ld64 to 253.3
added:
* support for Xcode 7.x / El Capitan
/****************************** v0.11 ********************************/
changed:

View File

@ -33,10 +33,14 @@ Then ensure you have the following installed on your system:
`Clang 3.2+`, `patch`, `libxml2-devel` (<=10.6 only) and the `bash shell`.
Optional:
*Optional:*
`llvm-devel`: For Link Time Optimization support
`uuid-devel`: For ld64 `-random_uuid` support
`uuid-devel`: For ld64 `-random_uuid` support
`llvm-devel` + `xar-devel`: For ld64 `-bitcode_bundle` support
You can find xar [here](https://github.com/mackyle/xar).
Do not install libxar-dev on Ubuntu, it's a different package.
\--
You can run 'sudo tools/get\_dependencies.sh' to get these automatically.
@ -82,13 +86,13 @@ You can turn this behavior off with `OSXCROSS_GCC_NO_STATIC_RUNTIME=1` (env).
##### Packaging the SDK on Mac OS X: #####
1. [Download [Xcode](https://developer.apple.com/downloads/index.action?name=Xcode%205.1.1) \*\*]
1. [Download [Xcode](https://developer.apple.com/downloads/index.action?name=Xcode%207.0.1) \*\*]
2. [Mount Xcode.dmg (Open With -> DiskImageMounter) \*\*\*]
3. Run: `./tools/gen_sdk_package.sh` (from the OSXCross package)
4. Copy the packaged SDK (\*.tar.\* or \*.pkg) on a USB Stick
5. (On Linux/BSD) Copy or move the SDK into the tarballs/ directory of OSXCross
\*\* Xcode up to 6.4 is known to work; 7.x is not working (yet).
\*\* Xcode up to 7.1.x is known to work.
\*\*\* If you get a dialog with a crossed circle, ignore it, you don't need to install Xcode.
Step 1. and 2. can be skipped if you have Xcode installed.
@ -213,7 +217,7 @@ You can build OSXCross with GCC this way:
`CC=gcc CXX=g++ ./build.sh`
You will need gcc/g++/gcc-objc 4.6+.
You will need gcc/g++/gcc-objc 4.7+.
### LICENSE: ####
* scripts/wrapper: GPLv2

1
TODO
View File

@ -1,3 +1,2 @@
document 'osxcross-man'
Xcode 7 compatibility (requires a newer not yet open sourced linker)
verify downloaded archive tarballs (gcc, llvm, ...) with sha256sum or similar

View File

@ -74,7 +74,7 @@ if [ -z "$OSX_VERSION_MIN" ]; then
fi
fi
OSXCROSS_VERSION=0.11
OSXCROSS_VERSION=0.12
X86_64H_SUPPORTED=0
@ -86,6 +86,7 @@ case $SDK_VERSION in
10.8*) TARGET=darwin12; X86_64H_SUPPORTED=1; ;;
10.9*) TARGET=darwin13; X86_64H_SUPPORTED=1; ;;
10.10*) TARGET=darwin14; X86_64H_SUPPORTED=1; ;;
10.11*) TARGET=darwin15; X86_64H_SUPPORTED=1; ;;
*) echo "Invalid SDK Version" && exit 1 ;;
esac
@ -129,49 +130,8 @@ function remove_locks()
source $BASE_DIR/tools/trap_exit.sh
# CCTOOLS
if [ "$PLATFORM" == "Darwin" ]; then
PREVCXX=$CXX
CXX+=" -stdlib=libc++"
fi
res=$(check_cxx_stdlib)
if [ "$PLATFORM" == "Darwin" ]; then
CXX=$PREVCXX
unset PREVCXX
fi
# CCTOOLS
if [ -z $LINKER_VERSION ]; then
if [ "$PLATFORM" == "Darwin" ]; then
PREVCXX=$CXX
CXX+=" -stdlib=libc++"
fi
res=$(check_cxx_stdlib)
if [ "$PLATFORM" == "Darwin" ]; then
CXX=$PREVCXX
unset PREVCXX
fi
if [ $res -ne 0 ]; then
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=242
fi
fi
if [ "$LINKER_VERSION" != "242" ] && [ "$LINKER_VERSION" != "134.9" ]; then
echo "LINKER_VERSION must be 242 or 134.9"
exit 1
fi
CCTOOLS="cctools-870-ld64-$LINKER_VERSION"
LINKER_VERSION=253.3
CCTOOLS="cctools-877.5-ld64-$LINKER_VERSION"
CCTOOLS_TARBALL=$(ls $TARBALL_DIR/$CCTOOLS*.tar.* | head -n1)
CCTOOLS_REVHASH=$(echo $(basename "$CCTOOLS_TARBALL") | tr '_' '\n' | \
tr '.' '\n' | tail -n3 | head -n1)
@ -189,17 +149,10 @@ pushd .. &>/dev/null
popd &>/dev/null
patch -p0 < $PATCH_DIR/cctools-ld64-1.patch
patch -p0 < $PATCH_DIR/cctools-ld64-2.patch
if [ $PLATFORM == "OpenBSD" ] || [ $PLATFORM == "DragonFly" ]; then
pushd .. &>/dev/null
patch -p0 < $PATCH_DIR/cctools-ld64-epath.patch
popd &>/dev/null
fi
if [ $LINKER_VERSION == "134.9" ]; then
patch -p1 < $PATCH_DIR/cctools-ld64-134.9-old-compiler.patch
fi
echo ""
CONFFLAGS="--prefix=$TARGET_DIR --target=x86_64-apple-$TARGET"
[ -n "$DISABLE_LTO_SUPPORT" ] && CONFFLAGS+=" --enable-lto=no"
CONFFLAGS="--prefix=$TARGET_DIR --target=x86_64-apple-$TARGET "
CONFFLAGS+="--disable-clang-as "
[ -n "$DISABLE_LTO_SUPPORT" ] && CONFFLAGS+="--disable-lto-support "
./configure $CONFFLAGS
$MAKE -j$JOBS
$MAKE install -j$JOBS

View File

@ -1,29 +0,0 @@
diff --git cctools/ld64/src/ld/code-sign-blobs/memutils.h cctools/ld64/src/ld/code-sign-blobs/memutils.h
index b0421f0..30514d3 100644
--- cctools/ld64/src/ld/code-sign-blobs/memutils.h
+++ cctools/ld64/src/ld/code-sign-blobs/memutils.h
@@ -34,6 +34,7 @@
#include <algorithm>
#ifdef __GLIBCXX__
+#include <stddef.h>
using namespace __gnu_cxx;
#endif
diff --git cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp
index 37cd0f2..e63d1ef 100644
--- cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp
+++ cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp
@@ -1499,6 +1499,12 @@ ld::relocatable::File* Parser<A>::parse(const ParserOptions& opts)
uint32_t countOfCFIs = 0;
if ( _EHFrameSection != NULL )
countOfCFIs = _EHFrameSection->cfiCount();
+#ifdef __clang__
+ // Workaround to get rid of the following clang <= 3.4 error:
+ // macho_relocatable_file.cpp:1506:49: error: variable length array of non-POD element type 'typename CFISection<arm>::CFI_Atom_Info' (aka 'CFI_Atom_Info<mach_o::relocatable::CFISection<arm>::OAS>')
+ // Don't ask me why this fixes the error.
+ typename CFISection<A>::CFI_Atom_Info __clang_workaround[2];
+#endif
typename CFISection<A>::CFI_Atom_Info cfiArray[countOfCFIs];
// stack allocate (if not too large) a copy of __eh_frame to apply relocations to
uint8_t* ehBuffer = NULL;

View File

@ -1,343 +0,0 @@
diff --git cctools/ld64/src/3rd/helper.c cctools/ld64/src/3rd/helper.c
index 2bed724..3a8d4b9 100644
--- cctools/ld64/src/3rd/helper.c
+++ cctools/ld64/src/3rd/helper.c
@@ -17,11 +17,17 @@ const char ldVersionString[] = "242\n";
#include <mach/host_info.h>
#include <sys/time.h>
#include <assert.h>
-
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#include <sys/sysctl.h>
#endif
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sys/stat.h>
+#endif
+
#include "helper.h"
void __assert_rtn(const char *func, const char *file, int line, const char *msg)
@@ -36,39 +42,75 @@ void __assert_rtn(const char *func, const char *file, int line, const char *msg)
}
-int _NSGetExecutablePath(char *path, unsigned int *size)
+int _NSGetExecutablePath(char *epath, unsigned int *size)
{
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
int mib[4];
- mib[0] = CTL_KERN;
+ mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PATHNAME;
mib[3] = -1;
size_t cb = *size;
- if (sysctl(mib, 4, path, &cb, NULL, 0) != 0)
+ if (sysctl(mib, 4, epath, &cb, NULL, 0) != 0)
return -1;
*size = cb;
- return 0;
+ return 0;
#elif defined(__OpenBSD__)
int mib[4];
- const char *tmp[100];
- size_t l = sizeof(tmp);
+ char **argv;
+ size_t len;
+ const char *comm;
+ int ok = 0;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC_ARGS;
mib[2] = getpid();
mib[3] = KERN_PROC_ARGV;
- if (sysctl(mib, 4, tmp, &l, NULL, 0) != 0)
- return -1;
- *size = strlcpy(path, tmp[0], *size);
- return 0;
+ if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0)
+ abort();
+ if (!(argv = malloc(len)))
+ abort();
+ if (sysctl(mib, 4, argv, &len, NULL, 0) < 0)
+ abort();
+ comm = argv[0];
+ if (*comm == '/' || *comm == '.') {
+ char *rpath;
+ if ((rpath = realpath(comm, NULL))) {
+ strlcpy(epath, rpath, *size);
+ free(rpath);
+ ok = 1;
+ }
+ } else {
+ char *sp;
+ char *xpath = strdup(getenv("PATH"));
+ char *path = strtok_r(xpath, ":", &sp);
+ struct stat st;
+ if (!xpath)
+ abort();
+ while (path) {
+ snprintf(epath, *size, "%s/%s", path, comm);
+ if (!stat(epath, &st) && (st.st_mode & S_IXUSR)) {
+ ok = 1;
+ break;
+ }
+ path = strtok_r(NULL, ":", &sp);
+ }
+ free(xpath);
+ }
+ free(argv);
+ if (ok) {
+ *strrchr(epath, '/') = '\0';
+ *size = strlen(epath);
+ return 0;
+ }
+ return -1;
#else
int bufsize = *size;
int ret_size;
- ret_size = readlink("/proc/self/exe", path, bufsize-1);
+ ret_size = readlink("/proc/self/exe", epath, bufsize-1);
if (ret_size != -1)
{
*size = ret_size;
- path[ret_size]=0;
+ epath[ret_size]=0;
return 0;
}
else
diff --git cctools/libstuff/emulated.c cctools/libstuff/emulated.c
index 1aa355c..633c9dc 100644
--- cctools/libstuff/emulated.c
+++ cctools/libstuff/emulated.c
@@ -14,46 +14,88 @@
#include <mach/host_info.h>
#include <sys/time.h>
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#include <sys/sysctl.h>
#endif
-int _NSGetExecutablePath(char *path, unsigned int *size)
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sys/stat.h>
+#endif
+
+int _NSGetExecutablePath(char *epath, unsigned int *size)
{
-#ifdef __FreeBSD__
- int mib[4];
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_PATHNAME;
- mib[3] = -1;
- size_t cb = *size;
- if (sysctl(mib, 4, path, &cb, NULL, 0) != 0)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+ int mib[4];
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PATHNAME;
+ mib[3] = -1;
+ size_t cb = *size;
+ if (sysctl(mib, 4, epath, &cb, NULL, 0) != 0)
return -1;
- *size = cb;
- return 0;
+ *size = cb;
+ return 0;
#elif defined(__OpenBSD__)
- int mib[4];
- const char *tmp[100];
- size_t l = sizeof(tmp);
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC_ARGS;
- mib[2] = getpid();
- mib[3] = KERN_PROC_ARGV;
- if (sysctl(mib, 4, tmp, &l, NULL, 0) != 0)
- return -1;
- *size = strlcpy(path, tmp[0], *size);
- return 0;
+ int mib[4];
+ char **argv;
+ size_t len;
+ const char *comm;
+ int ok = 0;
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC_ARGS;
+ mib[2] = getpid();
+ mib[3] = KERN_PROC_ARGV;
+ if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0)
+ abort();
+ if (!(argv = malloc(len)))
+ abort();
+ if (sysctl(mib, 4, argv, &len, NULL, 0) < 0)
+ abort();
+ comm = argv[0];
+ if (*comm == '/' || *comm == '.') {
+ char *rpath;
+ if ((rpath = realpath(comm, NULL))) {
+ strlcpy(epath, rpath, *size);
+ free(rpath);
+ ok = 1;
+ }
+ } else {
+ char *sp;
+ char *xpath = strdup(getenv("PATH"));
+ char *path = strtok_r(xpath, ":", &sp);
+ struct stat st;
+ if (!xpath)
+ abort();
+ while (path) {
+ snprintf(epath, *size, "%s/%s", path, comm);
+ if (!stat(epath, &st) && (st.st_mode & S_IXUSR)) {
+ ok = 1;
+ break;
+ }
+ path = strtok_r(NULL, ":", &sp);
+ }
+ free(xpath);
+ }
+ free(argv);
+ if (ok) {
+ *strrchr(epath, '/') = '\0';
+ *size = strlen(epath);
+ return 0;
+ }
+ return -1;
#else
- int bufsize = *size;
- int ret_size;
- ret_size = readlink("/proc/self/exe", path, bufsize-1);
- if (ret_size != -1)
- {
+ int bufsize = *size;
+ int ret_size;
+ ret_size = readlink("/proc/self/exe", epath, bufsize-1);
+ if (ret_size != -1)
+ {
*size = ret_size;
- path[ret_size]=0;
+ epath[ret_size]=0;
return 0;
- }
- else
+ }
+ else
return -1;
#endif
}
diff --git usage_examples/ios_toolchain/wrapper.c usage_examples/ios_toolchain/wrapper.c
index a55bd41..5764c92 100644
--- usage_examples/ios_toolchain/wrapper.c
+++ usage_examples/ios_toolchain/wrapper.c
@@ -19,30 +19,79 @@
#include <mach-o/dyld.h>
#endif
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#include <sys/sysctl.h>
#endif
-char *get_executable_path(char *buf, size_t len)
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sys/stat.h>
+#endif
+
+char *get_executable_path(char *epath, size_t buflen)
{
char *p;
#ifdef __APPLE__
- unsigned int l = len;
- if (_NSGetExecutablePath(buf, &l) != 0) return NULL;
-#elif defined(__FreeBSD__)
+ unsigned int l = buflen;
+ if (_NSGetExecutablePath(epath, &l) != 0) return NULL;
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
- size_t l = len;
- if (sysctl(mib, 4, buf, &l, NULL, 0) != 0) return NULL;
-#elif defined(_WIN32)
- size_t l = GetModuleFileName(NULL, buf, (DWORD)len);
+ size_t l = buflen;
+ if (sysctl(mib, 4, epath, &l, NULL, 0) != 0) return NULL;
+#elif defined(__OpenBSD__)
+ int mib[4];
+ char **argv;
+ size_t len;
+ size_t l;
+ const char *comm;
+ int ok = 0;
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC_ARGS;
+ mib[2] = getpid();
+ mib[3] = KERN_PROC_ARGV;
+ if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0)
+ abort();
+ if (!(argv = malloc(len)))
+ abort();
+ if (sysctl(mib, 4, argv, &len, NULL, 0) < 0)
+ abort();
+ comm = argv[0];
+ if (*comm == '/' || *comm == '.') {
+ char *rpath;
+ if ((rpath = realpath(comm, NULL))) {
+ strlcpy(epath, rpath, buflen);
+ free(rpath);
+ ok = 1;
+ }
+ } else {
+ char *sp;
+ char *xpath = strdup(getenv("PATH"));
+ char *path = strtok_r(xpath, ":", &sp);
+ struct stat st;
+ if (!xpath)
+ abort();
+ while (path) {
+ snprintf(epath, buflen, "%s/%s", path, comm);
+ if (!stat(epath, &st) && (st.st_mode & S_IXUSR)) {
+ ok = 1;
+ break;
+ }
+ path = strtok_r(NULL, ":", &sp);
+ }
+ free(xpath);
+ }
+ free(argv);
+ if (!ok) return NULL;
+ l = strlen(epath);
#else
- ssize_t l = readlink("/proc/self/exe", buf, len);
+ ssize_t l = readlink("/proc/self/exe", epath, buflen);
#endif
if (l <= 0) return NULL;
- buf[len - 1] = '\0';
- p = strrchr(buf, '/');
+ epath[buflen - 1] = '\0';
+ p = strrchr(epath, '/');
if (p) *p = '\0';
- return buf;
+ return epath;
}
char *get_filename(char *str)
@@ -88,7 +137,7 @@ int main(int argc, char *argv[])
target_info(argv, &target, &compiler);
if (!get_executable_path(execpath, sizeof(execpath))) abort();
snprintf(sdkpath, sizeof(sdkpath), "%s/../SDK", execpath);
-
+
snprintf(codesign_allocate, sizeof(codesign_allocate),
"%s-codesign_allocate", target);

Binary file not shown.

View File

@ -90,6 +90,9 @@ case $MACOSX_DEPLOYMENT_TARGET in
10.8* ) OSXVERSION="darwin_12" ;;
10.9* ) OSXVERSION="darwin_13" ;;
10.10* ) OSXVERSION="darwin_14" ;;
# "Downgrade" 10.11 to 10.10 until
# there are packages for 10.11
10.11* ) OSXVERSION="darwin_14" ;;
* ) unsupportedDepTarget ;;
esac
@ -187,7 +190,7 @@ verifyFileIntegrity()
exit 1
fi
verboseMsg "verifying file integrity ..."
echo "verifying file integrity of $file"
set +e

View File

@ -1,16 +0,0 @@
#include <utility>
template <typename V> struct Node {
V value;
template <typename... Args>
Node(Args &&... args)
: value(std::forward<Args>(args)...) {}
};
void foo(std::pair<int const, int> const &p) {
Node<std::pair<int const, int>> node(p);
}
int main() { return 0; }

View File

@ -163,17 +163,6 @@ function verbose_cmd()
eval "$@"
}
function check_cxx_stdlib()
{
set +e
$CXX $CXXFLAGS -std=c++0x $BASE_DIR/tools/stdlib-test.cpp -S -o- \
2>$BUILD_DIR/stdlib-test.log 1>/dev/null
echo "$?"
set -e
}
function test_compiler()
{
echo -ne "testing $1 ... "