diff --git a/build.sh b/build.sh index af98afb..361f6a8 100755 --- a/build.sh +++ b/build.sh @@ -149,6 +149,7 @@ 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-misc-fixes.patch echo "" CONFFLAGS="--prefix=$TARGET_DIR --target=x86_64-apple-$TARGET " CONFFLAGS+="--disable-clang-as " diff --git a/patches/cctools-ld64-misc-fixes.patch b/patches/cctools-ld64-misc-fixes.patch new file mode 100644 index 0000000..457143d --- /dev/null +++ b/patches/cctools-ld64-misc-fixes.patch @@ -0,0 +1,87 @@ +commit fb07e9db8009ba58cf1fafc031e3850b50c3dcca +Author: Thomas Pöchtrager +Date: Tue Aug 9 21:02:37 2016 +0200 + + Misc fixes & Cleanup + +diff --git cctools/ld64/src/3rd/helper.h cctools/ld64/src/3rd/helper.h +index 7649666..a705ac3 100644 +--- cctools/ld64/src/3rd/helper.h ++++ cctools/ld64/src/3rd/helper.h +@@ -32,7 +32,7 @@ typedef char uuid_string_t__[37]; + #endif + + #ifdef __NetBSD__ +-#define stoi(a,b) atoi(a.c_str()); do { const char *p = a.c_str(); *b = 0; while (isdigit(*p++)) (*b)++; } while (0) ++#define stoi(a,b) atoi(a.c_str()); do { if (!b) break; const char *p = a.c_str(); *b = 0; while (isdigit(*p++)) (*b)++; } while (0) + #endif + + #include +diff --git cctools/ld64/src/ld/parsers/libunwind/InternalMacros.h cctools/ld64/src/ld/parsers/libunwind/InternalMacros.h +index 25c1631..4e01e00 100644 +--- cctools/ld64/src/ld/parsers/libunwind/InternalMacros.h ++++ cctools/ld64/src/ld/parsers/libunwind/InternalMacros.h +@@ -46,8 +46,15 @@ struct v128 { unsigned int vec[4]; }; + + #define EXPORT __attribute__((visibility("default"))) + ++#if 0 // ld64-port + #define COMPILE_TIME_ASSERT( expr ) \ + extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ] __attribute__( ( unused ) ); ++#endif ++ ++// ld64-port start ++#define COMPILE_TIME_ASSERT( expr ) \ ++ static_assert(expr, ""); ++// ld64-port end + + #define ABORT(msg) __assert_rtn(__func__, __FILE__, __LINE__, msg) + +diff --git cctools/ld64/src/ld/passes/bitcode_bundle.cpp cctools/ld64/src/ld/passes/bitcode_bundle.cpp +index 162fc77..d4d7509 100644 +--- cctools/ld64/src/ld/passes/bitcode_bundle.cpp ++++ cctools/ld64/src/ld/passes/bitcode_bundle.cpp +@@ -53,13 +53,6 @@ extern "C" { + static unsigned int lto_api_version() { + return LTO_API_VERSION; + } +- +-#if LTO_API_VERSION < 11 +-static lto_code_gen_t lto_codegen_create_in_local_context() { +- // ::lto_api_version() < 14 makes this function unreachable +- __builtin_unreachable(); +-} +-#endif + #endif + // ld64-port end + +diff --git cctools/libstuff/ofile.c cctools/libstuff/ofile.c +index 35121ce..1b9199c 100644 +--- cctools/libstuff/ofile.c ++++ cctools/libstuff/ofile.c +@@ -1965,6 +1965,8 @@ struct ofile *ofile) + struct ar_hdr *ar_hdr; + uint32_t ar_name_size, member_name_offset, n; + ++ ar_name_size = 0; /* cctools-port */ ++ + /* + * Get the address and size of the archive. + */ +diff --git cctools/misc/nm.c cctools/misc/nm.c +index e398f30..77de393 100644 +--- cctools/misc/nm.c ++++ cctools/misc/nm.c +@@ -527,7 +527,11 @@ void *cookie) + llvm_bundle_found = FALSE; + #endif /* LTO_SUPPORT */ + +- memset(&process_flags, '\0', sizeof(process_flags)); /* cctools-port */ ++ /* cctools-port start */ ++ memset(&process_flags, '\0', sizeof(process_flags)); ++ llvm_bundle_pointer = NULL; ++ llvm_bundle_size = 0; ++ /* cctools-port end */ + + cmd_flags = (struct cmd_flags *)cookie; +