From owner-svn-ports-head@FreeBSD.ORG Sun Dec 8 06:22:09 2013 Return-Path: Delivered-To: svn-ports-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 64C2117B; Sun, 8 Dec 2013 06:22:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4EF7E1615; Sun, 8 Dec 2013 06:22:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rB86M9Vk027790; Sun, 8 Dec 2013 06:22:09 GMT (envelope-from koobs@svn.freebsd.org) Received: (from koobs@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rB86M8qp027785; Sun, 8 Dec 2013 06:22:08 GMT (envelope-from koobs@svn.freebsd.org) Message-Id: <201312080622.rB86M8qp027785@svn.freebsd.org> From: Kubilay Kocak Date: Sun, 8 Dec 2013 06:22:08 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r335867 - in head/lang: python26/files python27/files python31/files python32/files python33/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Dec 2013 06:22:09 -0000 Author: koobs Date: Sun Dec 8 06:22:07 2013 New Revision: 335867 URL: http://svnweb.freebsd.org/changeset/ports/335867 Log: All Python ports: Address abort() for ctypes import on FreeBSD/ARM The current FreeBSD/ARM __clear_cache() implementation does nothing #if __i386__ || __x86_64__ #else abort(); cognet@ advises this is an issue for anything !Apple that is using the libcompiler_rt provided by Clang on ARM, and requires upstreaming. This is the root cause of abort() on import for the ctypes module in Python, as they bundle libffi. [1] This change patches the bundled libffi library in all Python ports, even though it is a NOOP for the ports that use devel/libffi. These ports, currently python31, will get the fix via ports/184517 A huge shout out to cognet@ who helped diagnose the issue and created the patch to address it. Thank you! PR: ports/149167 [1] PR: ports/184517 Submitted by: cognet [3] Reviewed by: cognet, eadler, milki, ak Added: head/lang/python26/files/patch-Modules___ctypes__libffi__src__arm__ffi.c (contents, props changed) head/lang/python27/files/patch-Modules___ctypes__libffi__src__arm__ffi.c (contents, props changed) head/lang/python31/files/patch-Modules___ctypes__libffi__src__arm__ffi.c (contents, props changed) head/lang/python32/files/patch-Modules___ctypes__libffi__src__arm__ffi.c (contents, props changed) head/lang/python33/files/patch-Modules___ctypes__libffi__src__arm__ffi.c (contents, props changed) Added: head/lang/python26/files/patch-Modules___ctypes__libffi__src__arm__ffi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lang/python26/files/patch-Modules___ctypes__libffi__src__arm__ffi.c Sun Dec 8 06:22:07 2013 (r335867) @@ -0,0 +1,36 @@ +# Description: Fix _ctypes abort on import for FreeBSD/ARM. This is an issue +# for anything !apple that is using the libcompiler_rt provided by clang on arm +# PR: ports/149167 ports/184517 +# Patch by: cognet@ (to be upstreamed @ LLVM) + +--- ./Modules/_ctypes/libffi/src/arm/ffi.c.orig 2013-12-06 00:45:21.870941788 +1100 ++++ ./Modules/_ctypes/libffi/src/arm/ffi.c 2013-12-06 00:46:42.804848626 +1100 +@@ -29,6 +29,11 @@ + + #include + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include ++#include ++#endif ++ + /* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +@@ -273,6 +278,16 @@ + + /* How to make a trampoline. */ + ++#if defined(__FreeBSD__) && defined(__arm__) ++#define __clear_cache(start, end) do { \ ++ struct arm_sync_icache_args ua; \ ++ \ ++ ua.addr = (uintptr_t)(start); \ ++ ua.len = (char *)(end) - (char *)start; \ ++ sysarch(ARM_SYNC_ICACHE, &ua); \ ++ } while (0); ++#endif ++ + #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ + ({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ Added: head/lang/python27/files/patch-Modules___ctypes__libffi__src__arm__ffi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lang/python27/files/patch-Modules___ctypes__libffi__src__arm__ffi.c Sun Dec 8 06:22:07 2013 (r335867) @@ -0,0 +1,36 @@ +# Description: Fix _ctypes abort on import for FreeBSD/ARM. This is an issue +# for anything !apple that is using the libcompiler_rt provided by clang on arm +# PR: ports/149167 ports/184517 +# Patch by: cognet@ (to be upstreamed @ LLVM) + +--- ./Modules/_ctypes/libffi/src/arm/ffi.c.orig 2013-11-10 18:36:41.000000000 +1100 ++++ ./Modules/_ctypes/libffi/src/arm/ffi.c 2013-12-03 18:05:51.461078888 +1100 +@@ -33,6 +33,11 @@ + + #include + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include ++#include ++#endif ++ + /* Forward declares. */ + static int vfp_type_p (ffi_type *); + static void layout_vfp_args (ffi_cif *); +@@ -582,6 +587,16 @@ + + #else + ++#if defined(__FreeBSD__) && defined(__arm__) ++#define __clear_cache(start, end) do { \ ++ struct arm_sync_icache_args ua; \ ++ \ ++ ua.addr = (uintptr_t)(start); \ ++ ua.len = (char *)(end) - (char *)start; \ ++ sysarch(ARM_SYNC_ICACHE, &ua); \ ++ } while (0); ++#endif ++ + #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ + ({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ Added: head/lang/python31/files/patch-Modules___ctypes__libffi__src__arm__ffi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lang/python31/files/patch-Modules___ctypes__libffi__src__arm__ffi.c Sun Dec 8 06:22:07 2013 (r335867) @@ -0,0 +1,36 @@ +# Description: Fix _ctypes abort on import for FreeBSD/ARM. This is an issue +# for anything !apple that is using the libcompiler_rt provided by clang on arm +# PR: ports/149167 ports/184517 +# Patch by: cognet@ (to be upstreamed @ LLVM) + +--- ./Modules/_ctypes/libffi/src/arm/ffi.c.orig 2013-12-08 15:55:58.351993767 +1100 ++++ ./Modules/_ctypes/libffi/src/arm/ffi.c 2013-12-08 15:57:40.531068291 +1100 +@@ -29,6 +29,11 @@ + + #include + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include ++#include ++#endif ++ + /* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +@@ -273,6 +278,16 @@ + + /* How to make a trampoline. */ + ++#if defined(__FreeBSD__) && defined(__arm__) ++#define __clear_cache(start, end) do { \ ++ struct arm_sync_icache_args ua; \ ++ \ ++ ua.addr = (uintptr_t)(start); \ ++ ua.len = (char *)(end) - (char *)start; \ ++ sysarch(ARM_SYNC_ICACHE, &ua); \ ++ } while (0); ++#endif ++ + #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ + ({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ Added: head/lang/python32/files/patch-Modules___ctypes__libffi__src__arm__ffi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lang/python32/files/patch-Modules___ctypes__libffi__src__arm__ffi.c Sun Dec 8 06:22:07 2013 (r335867) @@ -0,0 +1,36 @@ +# Description: Fix _ctypes abort on import for FreeBSD/ARM. This is an issue +# for anything !apple that is using the libcompiler_rt provided by clang on arm +# PR: ports/149167 ports/184517 +# Patch by: cognet@ (to be upstreamed @ LLVM) + +--- ./Modules/_ctypes/libffi/src/arm/ffi.c.orig 2013-05-16 02:33:52.000000000 +1000 ++++ ./Modules/_ctypes/libffi/src/arm/ffi.c 2013-12-03 19:19:36.700951785 +1100 +@@ -33,6 +33,11 @@ + + #include + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include ++#include ++#endif ++ + /* Forward declares. */ + static int vfp_type_p (ffi_type *); + static void layout_vfp_args (ffi_cif *); +@@ -582,6 +587,16 @@ + + #else + ++#if defined(__FreeBSD__) && defined(__arm__) ++#define __clear_cache(start, end) do { \ ++ struct arm_sync_icache_args ua; \ ++ \ ++ ua.addr = (uintptr_t)(start); \ ++ ua.len = (char *)(end) - (char *)start; \ ++ sysarch(ARM_SYNC_ICACHE, &ua); \ ++ } while (0); ++#endif ++ + #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ + ({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ Added: head/lang/python33/files/patch-Modules___ctypes__libffi__src__arm__ffi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lang/python33/files/patch-Modules___ctypes__libffi__src__arm__ffi.c Sun Dec 8 06:22:07 2013 (r335867) @@ -0,0 +1,36 @@ +# Description: Fix _ctypes abort on import for FreeBSD/ARM. This is an issue +# for anything !apple that is using the libcompiler_rt provided by clang on arm +# PR: ports/149167 ports/184517 +# Patch by: cognet@ (to be upstreamed @ LLVM) + +--- ./Modules/_ctypes/libffi/src/arm/ffi.c.orig 2013-11-17 18:22:57.000000000 +1100 ++++ ./Modules/_ctypes/libffi/src/arm/ffi.c 2013-12-03 19:23:24.521993369 +1100 +@@ -33,6 +33,11 @@ + + #include + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include ++#include ++#endif ++ + /* Forward declares. */ + static int vfp_type_p (ffi_type *); + static void layout_vfp_args (ffi_cif *); +@@ -582,6 +587,16 @@ + + #else + ++#if defined(__FreeBSD__) && defined(__arm__) ++#define __clear_cache(start, end) do { \ ++ struct arm_sync_icache_args ua; \ ++ \ ++ ua.addr = (uintptr_t)(start); \ ++ ua.len = (char *)(end) - (char *)start; \ ++ sysarch(ARM_SYNC_ICACHE, &ua); \ ++ } while (0); ++#endif ++ + #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ + ({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \