Summary: | [PATCH] devel/libffi: Fix abort() on ARM related to __clear_cache() | ||||||
---|---|---|---|---|---|---|---|
Product: | Ports & Packages | Reporter: | koobs <koobs.freebsd> | ||||
Component: | Individual Port(s) | Assignee: | Kubilay Kocak <koobs> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Only Me | CC: | zeising | ||||
Priority: | Normal | ||||||
Version: | Latest | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Attachments: |
|
Description
koobs
2013-12-05 15:00:00 UTC
Responsible Changed From-To: freebsd-ports-bugs->zeising Over to maintainer (via the GNATS Auto Assign Tool) Please note this PR is a prerequisite for ports/149167 and does not close it. There are additional changes to come 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 <stdlib.h> + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include <sys/types.h> ++#include <machine/sysarch.h> ++#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 <stdlib.h> + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include <sys/types.h> ++#include <machine/sysarch.h> ++#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 <stdlib.h> + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include <sys/types.h> ++#include <machine/sysarch.h> ++#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 <stdlib.h> + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include <sys/types.h> ++#include <machine/sysarch.h> ++#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 <stdlib.h> + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include <sys/types.h> ++#include <machine/sysarch.h> ++#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); \ _______________________________________________ svn-ports-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-ports-all To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org" Author: koobs Date: Sun Dec 8 07:13:01 2013 New Revision: 335868 URL: http://svnweb.freebsd.org/changeset/ports/335868 Log: lang/python26: Use ports libffi to address ctypes build failure on i386 Unconditionally use libffi from ports because the Python 2.6 branch was closed for maintenance when the import of libffi 3.0.13 took place. fixes _ctypes module build failure on i386. [1] This change was also committed to lang/python31 [2] and makes the recent FreeBSD/ARM patch [3] a NOOP, which will once again be addressed when ports/184517 lands [4]. This gives users the greatest amount of choice and flexibility just prior to expiry of the python27 and python31 ports [1] Fixes Issue #17192: Update the ctypes module's libffi to v3.0.13. This specifically addresses a stack misalignment issue on x86 and issues on some more recent platforms. [#17192] http://bugs.python.org/issue17192 http://hg.python.org/cpython/rev/a94b3b4599f1 http://hg.python.org/cpython/rev/688bc0b44d96 [2] https://svnweb.freebsd.org/ports?view=revision&revision=335370 [3] https://svnweb.freebsd.org/ports?view=revision&revision=335867 PR: ports/184517 [4] Modified: head/lang/python26/Makefile Modified: head/lang/python26/Makefile ============================================================================== --- head/lang/python26/Makefile Sun Dec 8 06:22:07 2013 (r335867) +++ head/lang/python26/Makefile Sun Dec 8 07:13:01 2013 (r335868) @@ -12,12 +12,15 @@ DISTFILES= ${PYTHON_DISTFILE} MAINTAINER= python@FreeBSD.org COMMENT= Interpreted object-oriented programming language +LIB_DEPENDS= libffi.so:${PORTSDIR}/devel/libffi + DEPRECATED= Python 2.6 is now end-of-life, please migrate to lang/python27 EXPIRATION_DATE=2014-01-01 DIST_SUBDIR= python GNU_CONFIGURE= yes CONFIGURE_SCRIPT= ../configure # must be relative +CONFIGURE_ARGS= --with-system-ffi CONFIGURE_ENV= SVNVERSION="echo freebsd" ac_cv_opt_olimit_ok=no MAKE_ENV= VPATH="${PYTHON_WRKSRC}" INSTALL_TARGET= altinstall _______________________________________________ svn-ports-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-ports-all To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org" Responsible Changed From-To: zeising->koobs I'll take it (maintainer timeout, 2 weeks) Author: koobs Date: Sat Dec 21 05:22:05 2013 New Revision: 337118 URL: http://svnweb.freebsd.org/changeset/ports/337118 Log: devel/libffi: Fix abort() on ARM related to __clear_cache() 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. Additionally, two Python ports (python26 and python31) use devel/libffi for unrelated reasons, so this addresses the related PR for those ports too [2]. - Enable STAGE support - Remove MAN* entries and update pkg-plist accordingly - Add LICENSE - Sort USE/USES section - Use install-strip as the INSTALL_TARGET PR: ports/149167 PR: ports/184517 [2] Approved by: maintainer timeout (2 weeks) Added: head/devel/libffi/files/ head/devel/libffi/files/patch-src__arm__ffi.c (contents, props changed) Modified: head/devel/libffi/Makefile (contents, props changed) head/devel/libffi/pkg-plist (contents, props changed) Modified: head/devel/libffi/Makefile ============================================================================== --- head/devel/libffi/Makefile Sat Dec 21 04:39:52 2013 (r337117) +++ head/devel/libffi/Makefile Sat Dec 21 05:22:05 2013 (r337118) @@ -3,6 +3,7 @@ PORTNAME= libffi PORTVERSION= 3.0.13 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= SOURCEWARE MASTER_SITE_SUBDIR= ${PORTNAME} @@ -10,32 +11,32 @@ MASTER_SITE_SUBDIR= ${PORTNAME} MAINTAINER= zeising@FreeBSD.org COMMENT= Foreign Function Interface +LICENSE= MIT + TEST_DEPENDS= runtest:${PORTSDIR}/misc/dejagnu +USES= pathfix pkgconfig +USE_LDCONFIG= yes +GNU_CONFIGURE= yes + OPTIONS_DEFINE= TESTS TESTS_DESC= Include tools for test suite -NO_STAGE= yes .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MTESTS} BUILD_DEPENDS:= ${TEST_DEPENDS} .endif -GNU_CONFIGURE= yes -USE_LDCONFIG= yes -USES= pathfix pkgconfig -PLIST_SUB= PORTVERSION=${PORTVERSION} - +INSTALL_TARGET= install-strip INFO= libffi - -MAN3= ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 +PLIST_SUB= PORTVERSION=${PORTVERSION} post-install: @${LN} -sf ../lib/libffi-${PORTVERSION}/include/ffi.h \ - ${PREFIX}/include/ + ${STAGEDIR}${PREFIX}/include/ @${LN} -sf ../lib/libffi-${PORTVERSION}/include/ffitarget.h \ - ${PREFIX}/include/ + ${STAGEDIR}${PREFIX}/include/ regression-test: build @cd ${WRKSRC} && ${MAKE} check Added: head/devel/libffi/files/patch-src__arm__ffi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/libffi/files/patch-src__arm__ffi.c Sat Dec 21 05:22:05 2013 (r337118) @@ -0,0 +1,36 @@ +# Description: Fix abort() on ARM related to __clear_cache(). 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) + +--- ./src/arm/ffi.c.orig 2013-03-16 22:19:39.000000000 +1100 ++++ ./src/arm/ffi.c 2013-12-03 19:30:58.440924300 +1100 +@@ -33,6 +33,11 @@ + + #include <stdlib.h> + ++#if defined(__FreeBSD__) && defined(__arm__) ++#include <sys/types.h> ++#include <machine/sysarch.h> ++#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); \ Modified: head/devel/libffi/pkg-plist ============================================================================== --- head/devel/libffi/pkg-plist Sat Dec 21 04:39:52 2013 (r337117) +++ head/devel/libffi/pkg-plist Sat Dec 21 05:22:05 2013 (r337118) @@ -7,5 +7,9 @@ lib/libffi.la lib/libffi.so lib/libffi.so.6 libdata/pkgconfig/libffi.pc +man/man3/ffi.3.gz +man/man3/ffi_call.3.gz +man/man3/ffi_prep_cif.3.gz +man/man3/ffi_prep_cif_var.3.gz @dirrm lib/libffi-%%PORTVERSION%%/include @dirrm lib/libffi-%%PORTVERSION%% _______________________________________________ svn-ports-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-ports-all To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org" State Changed From-To: open->closed Committed, with minor changes. Author: mat Date: Sat Dec 21 10:35:40 2013 New Revision: 337136 URL: http://svnweb.freebsd.org/changeset/ports/337136 Log: MFH: r337118 devel/libffi: Fix abort() on ARM related to __clear_cache() 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. Additionally, two Python ports (python26 and python31) use devel/libffi for unrelated reasons, so this addresses the related PR for those ports too [2]. - Enable STAGE support - Remove MAN* entries and update pkg-plist accordingly - Add LICENSE - Sort USE/USES section - Use install-strip as the INSTALL_TARGET PR: ports/149167 PR: ports/184517 [2] Approved by: maintainer timeout (2 weeks) Approved by: portmgr (implicit) Added: branches/2014Q1/devel/libffi/files/ - copied from r337118, head/devel/libffi/files/ Modified: branches/2014Q1/devel/libffi/Makefile (contents, props changed) branches/2014Q1/devel/libffi/pkg-plist (contents, props changed) Directory Properties: branches/2014Q1/ (props changed) Modified: branches/2014Q1/devel/libffi/Makefile ============================================================================== --- branches/2014Q1/devel/libffi/Makefile Sat Dec 21 10:34:16 2013 (r337135) +++ branches/2014Q1/devel/libffi/Makefile Sat Dec 21 10:35:40 2013 (r337136) @@ -3,6 +3,7 @@ PORTNAME= libffi PORTVERSION= 3.0.13 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= SOURCEWARE MASTER_SITE_SUBDIR= ${PORTNAME} @@ -10,32 +11,32 @@ MASTER_SITE_SUBDIR= ${PORTNAME} MAINTAINER= zeising@FreeBSD.org COMMENT= Foreign Function Interface +LICENSE= MIT + TEST_DEPENDS= runtest:${PORTSDIR}/misc/dejagnu +USES= pathfix pkgconfig +USE_LDCONFIG= yes +GNU_CONFIGURE= yes + OPTIONS_DEFINE= TESTS TESTS_DESC= Include tools for test suite -NO_STAGE= yes .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MTESTS} BUILD_DEPENDS:= ${TEST_DEPENDS} .endif -GNU_CONFIGURE= yes -USE_LDCONFIG= yes -USES= pathfix pkgconfig -PLIST_SUB= PORTVERSION=${PORTVERSION} - +INSTALL_TARGET= install-strip INFO= libffi - -MAN3= ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 +PLIST_SUB= PORTVERSION=${PORTVERSION} post-install: @${LN} -sf ../lib/libffi-${PORTVERSION}/include/ffi.h \ - ${PREFIX}/include/ + ${STAGEDIR}${PREFIX}/include/ @${LN} -sf ../lib/libffi-${PORTVERSION}/include/ffitarget.h \ - ${PREFIX}/include/ + ${STAGEDIR}${PREFIX}/include/ regression-test: build @cd ${WRKSRC} && ${MAKE} check Modified: branches/2014Q1/devel/libffi/pkg-plist ============================================================================== --- branches/2014Q1/devel/libffi/pkg-plist Sat Dec 21 10:34:16 2013 (r337135) +++ branches/2014Q1/devel/libffi/pkg-plist Sat Dec 21 10:35:40 2013 (r337136) @@ -7,5 +7,9 @@ lib/libffi.la lib/libffi.so lib/libffi.so.6 libdata/pkgconfig/libffi.pc +man/man3/ffi.3.gz +man/man3/ffi_call.3.gz +man/man3/ffi_prep_cif.3.gz +man/man3/ffi_prep_cif_var.3.gz @dirrm lib/libffi-%%PORTVERSION%%/include @dirrm lib/libffi-%%PORTVERSION%% _______________________________________________ svn-ports-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-ports-all To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org" |