Date: Fri, 6 Dec 2013 01:50:25 +1100 (EST) From: Kubilay Kocak <koobs.freebsd@gmail.com> To: FreeBSD-gnats-submit@freebsd.org Cc: zeising@FreeBSD.org Subject: ports/184517: [PATCH] devel/libffi: Fix abort() on ARM related to __clear_cache() Message-ID: <20131205145025.424DE39F1F@9-STABLE-amd64.elysium> Resent-Message-ID: <201312051500.rB5F00dP051513@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 184517 >Category: ports >Synopsis: [PATCH] devel/libffi: Fix abort() on ARM related to __clear_cache() >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Dec 05 15:00:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Kubilay Kocak >Release: FreeBSD 9.2-STABLE amd64 >Organization: >Environment: System: FreeBSD 9-STABLE-amd64.elysium 9.2-STABLE FreeBSD 9.2-STABLE #3 r258507: Sun Nov 24 18:59:42 EST >Description: devel/libffi: Fix abort() on ARM related to __clear_cache() The current ARM __clear_cache() implementation does nothing #if __i386__ || __x86_64__ #else abort(); This is also the root cause of abort() on import for the ctypes module on Python, as they bundle libffi. [1] This change addresses that issue until a permanent fix is committed to base, and in addition is required to support Python ports that use devel/libffi unconditionally, or users that compile Python against this port. A huge shout out to cognet@ who helped diagnose the issue and created the patch to address it. Thank you! While I'm here: - Enable STAGE support, remove MAN macros - Sort USE_* section PR: ports/149167 [1] Submitted by: cognet Reviewed by: cognet Port maintainer (zeising@FreeBSD.org) is cc'd. Generated with FreeBSD Port Tools 0.99_11 (mode: change, diff: ports) >How-To-Repeat: >Fix: --- libffi-3.0.13_1.patch begins here --- diff -ruN /usr/ports/devel/libffi/Makefile ./Makefile --- /usr/ports/devel/libffi/Makefile 2013-09-21 03:13:42.000000000 +1000 +++ ./Makefile 2013-12-04 00:52:22.225037815 +1100 @@ -1,8 +1,9 @@ # Created by: Horance Chou <horance@freedom.ie.cycu.edu.tw> -# $FreeBSD: devel/libffi/Makefile 327724 2013-09-20 17:13:42Z bapt $ +# $FreeBSD: head/devel/libffi/Makefile 327724 2013-09-20 17:13:42Z bapt $ PORTNAME= libffi PORTVERSION= 3.0.13 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= SOURCEWARE MASTER_SITE_SUBDIR= ${PORTNAME} @@ -12,30 +13,27 @@ 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} - 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 diff -ruN /usr/ports/devel/libffi/files/patch-src__arm__ffi.c ./files/patch-src__arm__ffi.c --- /usr/ports/devel/libffi/files/patch-src__arm__ffi.c 1970-01-01 10:00:00.000000000 +1000 +++ ./files/patch-src__arm__ffi.c 2013-12-03 19:32:11.292023441 +1100 @@ -0,0 +1,35 @@ +# Description: Fix _ctypes abort on import for FreeBSD/ARM +# PR: ports/149167 +# Patch by: cognet@ + +--- ./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); \ diff -ruN /usr/ports/devel/libffi/pkg-plist ./pkg-plist --- /usr/ports/devel/libffi/pkg-plist 2013-01-29 11:35:32.000000000 +1100 +++ ./pkg-plist 2013-12-04 00:01:30.161316938 +1100 @@ -7,5 +7,9 @@ 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%% --- libffi-3.0.13_1.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20131205145025.424DE39F1F>