From 6443c155f1b0bd3e26753075143a1a9ca5597d05 Mon Sep 17 00:00:00 2001 From: Joe deBlaquiere Date: Tue, 27 Oct 2015 13:29:22 -0400 Subject: [PATCH] build hostpython using MacOS libffi instead of cross-compiled ffi --- recipes/hostlibffi/__init__.py | 52 +++++++ recipes/hostlibffi/ffi-3.0.13-sysv.S.patch | 137 +++++++++++++++++ .../fix-win32-unreferenced-symbol.patch | 94 ++++++++++++ recipes/hostlibffi/public_include.patch | 141 ++++++++++++++++++ recipes/hostlibffi/staticlib.patch | 18 +++ recipes/hostlibffi/staticlib2.patch | 66 ++++++++ recipes/hostpython/__init__.py | 16 +- recipes/hostpython/ldfix.patch | 11 ++ toolchain.py | 5 +- tools/liblink | 3 +- 10 files changed, 532 insertions(+), 11 deletions(-) create mode 100644 recipes/hostlibffi/__init__.py create mode 100644 recipes/hostlibffi/ffi-3.0.13-sysv.S.patch create mode 100644 recipes/hostlibffi/fix-win32-unreferenced-symbol.patch create mode 100644 recipes/hostlibffi/public_include.patch create mode 100644 recipes/hostlibffi/staticlib.patch create mode 100644 recipes/hostlibffi/staticlib2.patch create mode 100644 recipes/hostpython/ldfix.patch diff --git a/recipes/hostlibffi/__init__.py b/recipes/hostlibffi/__init__.py new file mode 100644 index 0000000..fe353cc --- /dev/null +++ b/recipes/hostlibffi/__init__.py @@ -0,0 +1,52 @@ +from toolchain import Recipe, shprint +import sh + + +class LibffiRecipe(Recipe): + version = "3.2.1" + url = "ftp://sourceware.org/pub/libffi/libffi-{version}.tar.gz" + library = "build/Release-{arch.sdk}/libffi.a" + include_per_arch = True + include_dir = "build_{arch.sdk}-{arch.arch}/include" + archs = ["x86_64"] + + def build_all(self): + filtered_archs = self.filtered_archs + print("Build {} for {} (filtered)".format( + self.name, + ", ".join([x.arch for x in filtered_archs]))) + for arch in self.filtered_archs: + self.build(arch) + + def prebuild_arch(self, arch): + if self.has_marker("patched"): + return + # necessary as it doesn't compile with XCode 6.0. If we use 5.1.1, the + # compiler for i386 is not working. + #shprint(sh.sed, + # "-i.bak", + # "s/-miphoneos-version-min=5.1.1/-miphoneos-version-min=6.0/g", + # "generate-darwin-source-and-headers.py") + self.apply_patch("fix-win32-unreferenced-symbol.patch") + self.apply_patch("public_include.patch") + self.apply_patch("staticlib.patch") + self.apply_patch("staticlib2.patch") + self.set_marker("patched") + + def build_arch(self, arch): + shprint(sh.xcodebuild, + "ONLY_ACTIVE_ARCH=NO", + "ARCHS={}".format(arch.arch), + "-sdk", "macosx10.11", + "install", "installhdrs", + "-project", "libffi.xcodeproj", + "-target", "libffi-Mac", + "-configuration", "Release", + "DSTROOT={}/hostlibffi".format(self.ctx.dist_dir)) + + + def postbuild_arch(self, arch): + pass + +recipe = LibffiRecipe() + diff --git a/recipes/hostlibffi/ffi-3.0.13-sysv.S.patch b/recipes/hostlibffi/ffi-3.0.13-sysv.S.patch new file mode 100644 index 0000000..436b03d --- /dev/null +++ b/recipes/hostlibffi/ffi-3.0.13-sysv.S.patch @@ -0,0 +1,137 @@ +--- libffi-3.0.13-old/src/arm/sysv.S 2013-03-16 12:19:39.000000000 +0100 ++++ libffi-3.0.13-new/src/arm/sysv.S 2013-08-26 19:33:28.000000000 +0200 +@@ -109,58 +109,35 @@ + #define UNWIND @ + #endif + ++.syntax unified + + #if defined(__thumb__) && !defined(__THUMB_INTERWORK__) +-.macro ARM_FUNC_START name +- .text +- .align 0 +- .thumb +- .thumb_func +-#ifdef __APPLE__ +- ENTRY($0) ++#define ARM_FUNC_START(name) \ ++ .text; \ ++ .align 4; \ ++ .thumb; \ ++ .thumb_func; \ ++ ENTRY(name); \ ++ bx pc; \ ++ nop; \ ++ .arm; \ ++ UNWIND .fnstart; \ ++_L__##name: + #else +- ENTRY(\name) +-#endif +- bx pc +- nop +- .arm +- UNWIND .fnstart +-/* A hook to tell gdb that we've switched to ARM mode. Also used to call +- directly from other local arm routines. */ +-#ifdef __APPLE__ +-_L__$0: +-#else +-_L__\name: +-#endif +-.endm +-#else +-.macro ARM_FUNC_START name +- .text +- .align 0 +- .arm +-#ifdef __APPLE__ +- ENTRY($0) +-#else +- ENTRY(\name) +-#endif ++#define ARM_FUNC_START(name) \ ++ .text; \ ++ .align 4; \ ++ .arm; \ ++ ENTRY(name); \ + UNWIND .fnstart +-.endm + #endif + +-.macro RETLDM regs=, cond=, dirn=ia ++.macro RETLDM + #if defined (__INTERWORKING__) +- .ifc "\regs","" +- ldr\cond lr, [sp], #4 +- .else +- ldm\cond\dirn sp!, {\regs, lr} +- .endif +- bx\cond lr ++ ldr lr, [sp], #4 ++ bx lr + #else +- .ifc "\regs","" +- ldr\cond pc, [sp], #4 +- .else +- ldm\cond\dirn sp!, {\regs, pc} +- .endif ++ ldr pc, [sp], #4 + #endif + .endm + +@@ -170,8 +147,7 @@ + @ r3: fig->flags + @ sp+0: ecif.rvalue + +- @ This assumes we are using gas. +-ARM_FUNC_START ffi_call_SYSV ++ARM_FUNC_START(ffi_call_SYSV) + @ Save registers + stmfd sp!, {r0-r3, fp, lr} + UNWIND .save {r0-r3, fp, lr} +@@ -228,7 +204,7 @@ + #if defined(__SOFTFP__) || defined(__ARM_EABI__) + cmpne r3, #FFI_TYPE_DOUBLE + #endif +- stmeqia r2, {r0, r1} ++ stmiaeq r2, {r0, r1} + + #if !defined(__SOFTFP__) && !defined(__ARM_EABI__) + beq LSYM(Lepilogue) +@@ -266,7 +242,7 @@ + void *args; + */ + +-ARM_FUNC_START ffi_closure_SYSV ++ARM_FUNC_START(ffi_closure_SYSV) + UNWIND .pad #16 + add ip, sp, #16 + stmfd sp!, {ip, lr} +@@ -345,7 +321,7 @@ + @ r3: fig->flags + @ sp+0: ecif.rvalue + +-ARM_FUNC_START ffi_call_VFP ++ARM_FUNC_START(ffi_call_VFP) + @ Save registers + stmfd sp!, {r0-r3, fp, lr} + UNWIND .save {r0-r3, fp, lr} +@@ -410,7 +386,7 @@ + beq LSYM(Lepilogue_vfp) + + cmp r3, #FFI_TYPE_SINT64 +- stmeqia r2, {r0, r1} ++ stmiaeq r2, {r0, r1} + beq LSYM(Lepilogue_vfp) + + cmp r3, #FFI_TYPE_FLOAT +@@ -433,7 +409,7 @@ + .size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP) + + +-ARM_FUNC_START ffi_closure_VFP ++ARM_FUNC_START(ffi_closure_VFP) + fstmfdd sp!, {d0-d7} + @ r0-r3, then d0-d7 + UNWIND .pad #80 diff --git a/recipes/hostlibffi/fix-win32-unreferenced-symbol.patch b/recipes/hostlibffi/fix-win32-unreferenced-symbol.patch new file mode 100644 index 0000000..40dfecc --- /dev/null +++ b/recipes/hostlibffi/fix-win32-unreferenced-symbol.patch @@ -0,0 +1,94 @@ +diff -Naur --exclude 'build*' --exclude darwin_ios --exclude '*.swp' ../armv7/libffi-3.2.1/generate-darwin-source-and-headers.py libffi-3.2.1/generate-darwin-source-and-headers.py +--- ../armv7/libffi-3.2.1/generate-darwin-source-and-headers.py 2015-02-11 02:28:30.000000000 +0100 ++++ libffi-3.2.1/generate-darwin-source-and-headers.py 2015-02-11 12:33:38.000000000 +0100 +@@ -19,7 +19,7 @@ + prefix = "#ifdef __i386__\n\n" + suffix = "\n\n#endif" + src_dir = 'x86' +- src_files = ['darwin.S', 'win32.S', 'ffi.c'] ++ src_files = ['darwin.S', 'ffi.c'] + + + class simulator64_platform(Platform): +diff -Naur --exclude 'build*' --exclude darwin_ios --exclude '*.swp' ../armv7/libffi-3.2.1/src/x86/ffi.c libffi-3.2.1/src/x86/ffi.c +--- ../armv7/libffi-3.2.1/src/x86/ffi.c 2014-11-08 13:47:24.000000000 +0100 ++++ libffi-3.2.1/src/x86/ffi.c 2015-02-11 12:41:27.000000000 +0100 +@@ -393,6 +393,7 @@ + case FFI_SYSV: + case FFI_MS_CDECL: + #endif ++#ifdef X86_WIN322 + case FFI_STDCALL: + case FFI_THISCALL: + case FFI_FASTCALL: +@@ -402,6 +403,7 @@ + ecif.rvalue, fn); + break; + #endif ++#endif + default: + FFI_ASSERT(0); + break; +@@ -741,6 +743,7 @@ + &ffi_closure_SYSV, + (void*)codeloc); + } ++#ifdef X86_WIN32 + else if (cif->abi == FFI_REGISTER) + { + FFI_INIT_TRAMPOLINE_WIN32 (&closure->tramp[0], +@@ -765,7 +768,6 @@ + &ffi_closure_STDCALL, + (void*)codeloc); + } +-#ifdef X86_WIN32 + else if (cif->abi == FFI_MS_CDECL) + { + FFI_INIT_TRAMPOLINE (&closure->tramp[0], +@@ -909,7 +911,7 @@ + case FFI_SYSV: + case FFI_MS_CDECL: + #endif +-#ifndef X86_WIN64 ++#ifdef X86_WIN32 + case FFI_STDCALL: + case FFI_THISCALL: + case FFI_FASTCALL: +diff -Naur --exclude 'build*' --exclude darwin_ios --exclude '*.swp' ../armv7/libffi-3.2.1/src/x86/win32.S libffi-3.2.1/src/x86/win32.S +--- ../armv7/libffi-3.2.1/src/x86/win32.S 2014-11-11 15:41:37.000000000 +0100 ++++ libffi-3.2.1/src/x86/win32.S 2015-02-11 12:33:46.000000000 +0100 +@@ -37,8 +37,6 @@ + #define CIF_BYTES_OFFSET 16 + #define CIF_FLAGS_OFFSET 20 + +-#ifdef _MSC_VER +- + #define CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) AND NOT 3) + + .386 +@@ -1344,8 +1342,6 @@ + .align 4 + .LEFDE5: + +-#endif /* !_MSC_VER */ +- + #if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",@progbits + #endif +diff -Naur --exclude 'build*' --exclude darwin_ios --exclude '*.swp' ../armv7/libffi-3.2.1/src/x86/win64.S libffi-3.2.1/src/x86/win64.S +--- ../armv7/libffi-3.2.1/src/x86/win64.S 2014-11-08 13:47:24.000000000 +0100 ++++ libffi-3.2.1/src/x86/win64.S 2015-02-11 12:31:27.000000000 +0100 +@@ -16,7 +16,6 @@ + unsigned *rvalue, void (*fn)()); + */ + +-#ifdef _MSC_VER + PUBLIC ffi_call_win64 + + EXTRN __chkstk:NEAR +@@ -516,5 +515,4 @@ + pop %rbp + retq + .seh_endproc +-#endif /* !_MSC_VER */ + diff --git a/recipes/hostlibffi/public_include.patch b/recipes/hostlibffi/public_include.patch new file mode 100644 index 0000000..b30927d --- /dev/null +++ b/recipes/hostlibffi/public_include.patch @@ -0,0 +1,141 @@ +diff -u libffi-3.2.1/libffi.xcodeproj/project.pbxproj libffi-3.2.1-orig/libffi.xcodeproj/project.pbxproj +--- libffi-3.2.1/libffi.xcodeproj/project.pbxproj 2015-10-26 18:06:27.000000000 -0400 ++++ libffi-3.2.1-orig/libffi.xcodeproj/project.pbxproj 2014-11-08 07:47:24.000000000 -0500 +@@ -7,10 +7,10 @@ + objects = { + + /* Begin PBXBuildFile section */ +- DBFA714A187F1D8600A76262 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713E187F1D8600A76262 /* ffi.h */; settings = {ATTRIBUTES = (Public, ); }; }; +- DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713F187F1D8600A76262 /* ffi_common.h */; settings = {ATTRIBUTES = (Public, ); }; }; +- DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7140187F1D8600A76262 /* fficonfig.h */; settings = {ATTRIBUTES = (Private, ); }; }; +- DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7141187F1D8600A76262 /* ffitarget.h */; settings = {ATTRIBUTES = (Public, ); }; }; ++ DBFA714A187F1D8600A76262 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713E187F1D8600A76262 /* ffi.h */; }; ++ DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713F187F1D8600A76262 /* ffi_common.h */; }; ++ DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7140187F1D8600A76262 /* fficonfig.h */; }; ++ DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7141187F1D8600A76262 /* ffitarget.h */; }; + DBFA714E187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; }; + DBFA714F187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; }; + DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; }; +@@ -28,12 +28,12 @@ + DBFA717D187F1D9B00A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7174187F1D9B00A76262 /* darwin_i386.S */; }; + DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */; }; + DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7176187F1D9B00A76262 /* ffi_i386.c */; }; +- DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7182187F1DA100A76262 /* ffi_i386.h */; settings = {ATTRIBUTES = (Private, ); }; }; +- DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7183187F1DA100A76262 /* ffi_x86_64.h */; settings = {ATTRIBUTES = (Private, ); }; }; +- DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7184187F1DA100A76262 /* fficonfig_i386.h */; settings = {ATTRIBUTES = (Private, ); }; }; +- DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */; settings = {ATTRIBUTES = (Private, ); }; }; +- DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7186187F1DA100A76262 /* ffitarget_i386.h */; settings = {ATTRIBUTES = (Private, ); }; }; +- DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */; settings = {ATTRIBUTES = (Private, ); }; }; ++ DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7182187F1DA100A76262 /* ffi_i386.h */; }; ++ DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7183187F1DA100A76262 /* ffi_x86_64.h */; }; ++ DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7184187F1DA100A76262 /* fficonfig_i386.h */; }; ++ DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */; }; ++ DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7186187F1DA100A76262 /* ffitarget_i386.h */; }; ++ DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */; }; + DBFA7194187F1DA100A76262 /* darwin64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */; }; + DBFA7195187F1DA100A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718B187F1DA100A76262 /* darwin_i386.S */; }; + DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */; }; +@@ -123,7 +123,7 @@ + DBFA713D187F1D8600A76262 /* include */, + DBFA7142187F1D8600A76262 /* src */, + ); +- path = darwin_common; ++ path = "darwin_common"; + sourceTree = ""; + }; + DBFA713D187F1D8600A76262 /* include */ = { +@@ -155,7 +155,7 @@ + DBFA715D187F1D9B00A76262 /* include */, + DBFA716A187F1D9B00A76262 /* src */, + ); +- path = darwin_ios; ++ path = "darwin_ios"; + sourceTree = ""; + }; + DBFA715D187F1D9B00A76262 /* include */ = { +@@ -223,7 +223,7 @@ + DBFA7181187F1DA100A76262 /* include */, + DBFA7188187F1DA100A76262 /* src */, + ); +- path = darwin_osx; ++ path = "darwin_osx"; + sourceTree = ""; + }; + DBFA7181187F1DA100A76262 /* include */ = { +@@ -265,16 +265,16 @@ + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( +- DBFA714A187F1D8600A76262 /* ffi.h in Headers */, ++ DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */, + DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */, +- DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */, ++ DBFA714A187F1D8600A76262 /* ffi.h in Headers */, + DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */, +- DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */, +- DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */, +- DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */, +- DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */, + DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */, ++ DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */, + DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */, ++ DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */, ++ DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */, ++ DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +@@ -414,7 +414,7 @@ + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", +- darwin_common/include, ++ "darwin_common/include", + ); + ONLY_ACTIVE_ARCH = YES; + }; +@@ -425,7 +425,7 @@ + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", +- darwin_common/include, ++ "darwin_common/include", + ); + }; + name = Release; +@@ -465,7 +465,7 @@ + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", +- darwin_ios/include, ++ "darwin_ios/include", + ); + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; +@@ -505,7 +505,7 @@ + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", +- darwin_ios/include, ++ "darwin_ios/include", + ); + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0; +@@ -552,7 +552,7 @@ + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", +- darwin_osx/include, ++ "darwin_osx/include", + ); + MACOSX_DEPLOYMENT_TARGET = 10.6; + ONLY_ACTIVE_ARCH = YES; +@@ -592,7 +592,7 @@ + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", +- darwin_osx/include, ++ "darwin_osx/include", + ); + MACOSX_DEPLOYMENT_TARGET = 10.6; + OTHER_LDFLAGS = "-Wl,-no_compact_unwind"; diff --git a/recipes/hostlibffi/staticlib.patch b/recipes/hostlibffi/staticlib.patch new file mode 100644 index 0000000..cbd620e --- /dev/null +++ b/recipes/hostlibffi/staticlib.patch @@ -0,0 +1,18 @@ +--- libffi-3.2.1/libffi.xcodeproj/project.pbxproj 2015-10-26 18:32:03.000000000 -0400 ++++ libffi-3.2.1-orig/libffi.xcodeproj/project.pbxproj 2015-10-26 18:10:09.000000000 -0400 +@@ -554,7 +554,6 @@ + "$(inherited)", + darwin_osx/include, + ); +- MACH_O_TYPE = staticlib; + MACOSX_DEPLOYMENT_TARGET = 10.6; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "-Wl,-no_compact_unwind"; +@@ -595,7 +594,6 @@ + "$(inherited)", + darwin_osx/include, + ); +- MACH_O_TYPE = staticlib; + MACOSX_DEPLOYMENT_TARGET = 10.6; + OTHER_LDFLAGS = "-Wl,-no_compact_unwind"; + PRODUCT_NAME = ffi; diff --git a/recipes/hostlibffi/staticlib2.patch b/recipes/hostlibffi/staticlib2.patch new file mode 100644 index 0000000..35acf09 --- /dev/null +++ b/recipes/hostlibffi/staticlib2.patch @@ -0,0 +1,66 @@ +diff -u libffi-3.2.1/libffi.xcodeproj/project.pbxproj libffi-3.2.1-orig/libffi.xcodeproj/project.pbxproj +--- libffi-3.2.1/libffi.xcodeproj/project.pbxproj 2015-10-26 20:02:36.000000000 -0400 ++++ libffi-3.2.1-orig/libffi.xcodeproj/project.pbxproj 2015-10-26 19:41:01.000000000 -0400 +@@ -54,7 +54,7 @@ + + /* Begin PBXFileReference section */ + DB13B1661849DF1E0010F42D /* libffi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libffi.a; sourceTree = BUILT_PRODUCTS_DIR; }; +- DB13B1911849DF510010F42D /* libffi.a */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libffi.a; sourceTree = BUILT_PRODUCTS_DIR; }; ++ DB13B1911849DF510010F42D /* ffi.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = ffi.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; + DBFA713E187F1D8600A76262 /* ffi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi.h; sourceTree = ""; }; + DBFA713F187F1D8600A76262 /* ffi_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_common.h; sourceTree = ""; }; + DBFA7140187F1D8600A76262 /* fficonfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig.h; sourceTree = ""; }; +@@ -112,7 +112,7 @@ + isa = PBXGroup; + children = ( + DB13B1661849DF1E0010F42D /* libffi.a */, +- DB13B1911849DF510010F42D /* libffi.a */, ++ DB13B1911849DF510010F42D /* ffi.dylib */, + ); + name = Products; + sourceTree = ""; +@@ -312,7 +312,7 @@ + ); + name = "libffi-Mac"; + productName = ffi; +- productReference = DB13B1911849DF510010F42D /* libffi.a */; ++ productReference = DB13B1911849DF510010F42D /* ffi.dylib */; + productType = "com.apple.product-type.library.dynamic"; + }; + /* End PBXNativeTarget section */ +@@ -535,7 +535,6 @@ + COPY_PHASE_STRIP = NO; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; +- EXECUTABLE_EXTENSION = a; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; +@@ -559,7 +558,7 @@ + MACOSX_DEPLOYMENT_TARGET = 10.6; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "-Wl,-no_compact_unwind"; +- PRODUCT_NAME = libffi; ++ PRODUCT_NAME = ffi; + SDKROOT = macosx; + }; + name = Debug; +@@ -584,7 +583,6 @@ + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + ENABLE_NS_ASSERTIONS = NO; +- EXECUTABLE_EXTENSION = a; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; +@@ -600,7 +598,7 @@ + MACH_O_TYPE = staticlib; + MACOSX_DEPLOYMENT_TARGET = 10.6; + OTHER_LDFLAGS = "-Wl,-no_compact_unwind"; +- PRODUCT_NAME = libffi; ++ PRODUCT_NAME = ffi; + SDKROOT = macosx; + }; + name = Release; +Only in libffi-3.2.1/libffi.xcodeproj: project.xcworkspace +Only in libffi-3.2.1/libffi.xcodeproj: xcuserdata diff --git a/recipes/hostpython/__init__.py b/recipes/hostpython/__init__.py index 21d913f..cc675d3 100644 --- a/recipes/hostpython/__init__.py +++ b/recipes/hostpython/__init__.py @@ -8,8 +8,8 @@ import shutil class HostpythonRecipe(Recipe): version = "2.7.1" url = "https://www.python.org/ftp/python/{version}/Python-{version}.tar.bz2" - depends = ["libffi", ] - archs = ["i386"] + depends = ["hostlibffi", ] + archs = ["x86_64"] def init_with_ctx(self, ctx): super(HostpythonRecipe, self).init_with_ctx(ctx) @@ -25,6 +25,7 @@ class HostpythonRecipe(Recipe): self.apply_patch("ssize-t-max.patch") self.apply_patch("dynload.patch") self.apply_patch("static-_sqlite3.patch") + self.apply_patch("ldfix.patch") self.copy_file("ModulesSetup", "Modules/Setup.local") self.set_marker("patched") @@ -45,23 +46,22 @@ class HostpythonRecipe(Recipe): with open(makefile_fn, "w") as fd: fd.writelines(lines) - def build_i386(self): + def build_x86_64(self): sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip() build_env = self.ctx.env.copy() build_env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics" build_env["LDFLAGS"] = " ".join([ - "-lsqlite3", - "-lffi", - "-L{}".format(join(self.ctx.dist_dir, "lib")) - ]) + "-L{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib")), + "-lsqlite3"]) build_env["CFLAGS"] = " ".join([ "--sysroot={}".format(sdk_path), - "-I{}".format(join(self.ctx.dist_dir, "include", "i386", "libffi")) + "-I{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include")) ]) configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, "--prefix={}".format(join(self.ctx.dist_dir, "hostpython")), "--disable-toolbox-glue", + "--with-system-ffi", "--without-gcc", _env=build_env) shprint(sh.make, "-C", self.build_dir, "-j4", "python.exe", "Parser/pgen", diff --git a/recipes/hostpython/ldfix.patch b/recipes/hostpython/ldfix.patch new file mode 100644 index 0000000..175f27c --- /dev/null +++ b/recipes/hostpython/ldfix.patch @@ -0,0 +1,11 @@ +--- Python-2.7.1/Makefile.pre.in 2015-10-26 19:29:02.000000000 -0400 ++++ Python-2.7.1-orig/Makefile.pre.in 2015-10-26 19:28:35.000000000 -0400 +@@ -395,7 +395,7 @@ + $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) + $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \ + Modules/python.o \ +- $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) -lffi ++ $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) + + platform: $(BUILDPYTHON) + $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform diff --git a/toolchain.py b/toolchain.py index f59051c..e5a22c4 100755 --- a/toolchain.py +++ b/toolchain.py @@ -161,6 +161,7 @@ class Arch(object): ] + include_dirs) env["LDFLAGS"] = " ".join([ "-arch", self.arch, + "-ios_version_min", "7.0", "--sysroot", self.sysroot, "-L{}/{}".format(self.ctx.dist_dir, "lib"), "-lsqlite3", @@ -174,7 +175,7 @@ class ArchSimulator(Arch): sdk = "iphonesimulator" arch = "i386" triple = "i386-apple-darwin11" - version_min = "-miphoneos-version-min=6.0.0" + version_min = "-miphoneos-version-min=7.0" sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip() @@ -190,7 +191,7 @@ class ArchIOS(Arch): sdk = "iphoneos" arch = "armv7" triple = "arm-apple-darwin11" - version_min = "-miphoneos-version-min=6.0.0" + version_min = "-miphoneos-version-min=7.0" sysroot = sh.xcrun("--sdk", "iphoneos", "--show-sdk-path").strip() diff --git a/tools/liblink b/tools/liblink index 8fad701..4ce493f 100755 --- a/tools/liblink +++ b/tools/liblink @@ -76,4 +76,5 @@ f.close() print('Liblink redirect linking with', objects) ld = environ.get('ARM_LD') arch = environ.get('ARCH', 'armv7') -subprocess.call([ld, '-r', '-o', output + '.o', '-arch', arch] + objects) +print('linking with {} for arch {}'.format(ld, arch)) +subprocess.call([ld, '-r', '-arch', arch, '-ios_version_min', '7.0', '-o', output + '.o'] + objects)