Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Is a QNX port available for ARM for libffi (portable foreign function interface library)?: (6 Items)
   
Is a QNX port available for ARM for libffi (portable foreign function interface library)?  
I was wondering if anybody at QNX has looked into supporting the libffi library (see http://sourceware.org/libffi/) on 
QNX ARM platforms.

This library has been adopted internally by Python in the "ctypes" module and allows you to make calls into 'C' code and
 even have 'C' code make callbacks back into Python.

After a ***tremendous*** amount of effort, I managed to get Python 2.6.2 compiled under QNX 6.4.0 x86, SH (haven't 
tested it yet), and ARM. I know QNX supports Python 2.5.2 with the 6.4.0 distro but apparently no one ever tested the 
'ctypes' module since it isn't available with the distro. Well, my Python 2.6.2 port *does* support the ctypes module 
(passes all regression tests) under x86 but seg-faults under ARM:

# python /lib/python2.6/test/regrtest.py -v test_ctypes.py  
test_ctypes
test_anon (ctypes.test.test_anon.AnonTest) ... ok
test_anon_nonmember (ctypes.test.test_anon.AnonTest) ... ok
test_anon_nonseq (ctypes.test.test_anon.AnonTest) ... ok
test_nested (ctypes.test.test_anon.AnonTest) ... ok
test_cache (ctypes.test.test_arrays.ArrayTestCase) ... ok
test_classcache (ctypes.test.test_arrays.ArrayTestCase) ... ok
test_from_address (ctypes.test.test_arrays.ArrayTestCase) ... ok
test_from_addressW (ctypes.test.test_arrays.ArrayTestCase) ... ok
test_numeric_arrays (ctypes.test.test_arrays.ArrayTestCase) ... ok
test_simple (ctypes.test.test_arrays.ArrayTestCase) ... ok
test (ctypes.test.test_array_in_pointer.Test) ... ok
test_2 (ctypes.test.test_array_in_pointer.Test) ... ok
test_byval (ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase) ... ok
test_callbacks (ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase) ... 
Process 1527858 (python) terminated SIGSEGV code=1 fltno=11 ip=78295168(_ctypes.so@ffi_closure_SYS
V_inner+0x18) mapaddr=00015168. ref=00000004
Memory fault (core dumped)

Looking at the documentation (and code) for the FFI library I see that it's only been verified on ARM Linux. I'm not 
sure how compatible the Linux ARM ABI is compared to the QNX ARM ABI and I suspect that this might be the cause for my 
segfault. I know the Linux ARM is expecting a system defined '__clear_cache' function that the QNX compiler warns that 
it isn't explicitly defined (although it still builds and links).

The subtle differences between the Linux ARM ABI and the QNX ARM ABI is a little over my head. I was hoping a QNX guru 
might be able to look at the libffi library code (for ARM) and possibly tell me what's missing. I'm asking a lot, I know
, but I'm soooooo close to having most of the modules for a completely cross-compiled Python 2.6.2 for x86, SH, and ARM 
working I'd hate to say I didn't at least try to resolve this issue. Are there any takers at QNX with ARM experience 
that might be interested in taking a look at this code?

Thanks . . .
Re: Is a QNX port available for ARM for libffi (portable foreign function interface library)?  
I am about to embark on building 2.6.2 (or even 2.5 if it's easier) for QNX on arm (6.4.0 and 6.4.1 only support python 
for x86...grrr).

Any advice...or even any link to your work?

Cheers
Re: Is a QNX port available for ARM for libffi (portable foreign function interface library)?  
Hi Adrian -

It's definitely doable (although painful) to build Python 2.6.2 on ARM/SH/PPC for QNX (6.4.X). I've done it and have it 
running on an ARM platform with a few limitations.

To help you along, I'll include my "build-hooks" file (I'm assuming you know how to use this) along with a little README
 file which provides some details on the changes I had to make.

Good luck . . . I wish QNX (are you listening?) would support Python more fully on all their targets (not just x86).

Glenn


Attachment: Text build-hooks 5.03 KB
Re: Is a QNX port available for ARM for libffi (portable foreign function interface library)?  
Here's the README . . . I guess I can't attach more than one file to a message.
Attachment: Text README.QNX 12.42 KB
Re: Is a QNX port available for ARM for libffi (portable foreign function interface library)?  
> Hi Adrian -
> 
> It's definitely doable (although painful) to build Python 2.6.2 on ARM/SH/PPC 
> for QNX (6.4.X). I've done it and have it running on an ARM platform with a 
> few limitations.
> 
> To help you along, I'll include my "build-hooks" file (I'm assuming you know 
> how to use this) along with a little README file which provides some details 
> on the changes I had to make.
> 
> Good luck . . . I wish QNX (are you listening?) would support Python more 
> fully on all their targets (not just x86).
> 
> Glenn
> 
> 

Hi Glenn:
Silly question to ask, I have no idea how to use build-hooks, could you explain a bit more.

and in the read me file, indicated there are 5 new files
nto-x86-o/GNUmakefile
nto-arm-le/GNUmakefile
nto-sh-le/GNUmakefile
where I can find these?



Re: Is a QNX port available for ARM for libffi (portable foreign function interface library)?  
Hello,

I have tried to run python 2.7.3 on QNX 6.5.0 over arm-v7. If I comment the "_reset_cache()" function I can run some 
tests of the ctypes module.

I get memory fault when I run callbacks and pointers tests.
I think that it is the same problem that you are talking about in the first post. Has someone solved it?

Thanks a lot,
Jonathan.