[unix] Unrecognized opcode in FFI on PowerPC SPE

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[unix] Unrecognized opcode in FFI on PowerPC SPE

Bert Freudenberg
 
Begin forwarded message:

> Resent-From: Roland Stigge <[hidden email]>
> From: Roland Stigge <[hidden email]>
> Subject: Bug#693633: squeak-vm: FTBFS on powerpcspe (asm stfd/lfd)
> Date: 18. November 2012 21:10:04 MEZ
> Resent-To: [hidden email]
> To: Debian Bug Tracking System <[hidden email]>
> Resent-Cc: Debian Squeak Team <[hidden email]>
> Reply-To: Roland Stigge <[hidden email]>, [hidden email]
>
> Package: squeak-vm
> Version: 1:4.4.7.2357-1.1
> Severity: wishlist
> Tags: sid patch
> User: [hidden email]
> Usertags: powerpcspe
>
> Hi,
>
> squeak-vm FTBFS on powerpcspe [1] like this:
>
> [ 82%] Building ASM object SqueakFFIPrims/CMakeFiles/SqueakFFIPrims.dir/<C2><AB>PKGBUILDDIR<C2><BB>/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S.o
> /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S: Assembler messages:
> /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S:109: Error: Unrecognized opcode: `lfd'
> [...]
>
> There are some asm statements that only work on powerpc but not on powerpcspe.
>
> Attaching a patch that fixes it by disabling the SqueakFFIPrims plugin on
> powerpcspe.
>
> Thanks,
>
> Roland
>
>
> [1] http://wiki.debian.org/PowerPCSPEPort
>
> -- System Information:
> Debian Release: wheezy/sid
>  APT prefers unstable
>  APT policy: (500, 'unstable'), (1, 'experimental')
> Architecture: amd64 (x86_64)
>
> Kernel: Linux 3.5.0 (SMP w/4 CPU cores)
> Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_GB.UTF-8)
> Shell: /bin/sh linked to /bin/dash

>


squeak-vm.patch (417 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [unix] Unrecognized opcode in FFI on PowerPC SPE

David T. Lewis
 
To summarize my understanding of this issue (see below for background):

- powerpcspe is variant of powerpc that lacks certain parts of the powerpc
instruction set, as explained here: http://wiki.debian.org/PowerPCSPEPort

- The FFI plugin has architecture-specific assembler modules that set
up the entry points for FFI calls. The assembly module for powerpc is
platforms/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S

- The ppc-sysv-asm.S module uses one or more instructions ('lfd', possibly
others) that are not available on  the powerpcspe processor, and the the
module cannot be compiled on powerpcspe.

- The solution for the Debian build is to not build the FFI plugin when
compiling for powerpcspe. This is done by passing the --without-SqueakFFIPrims
option to the cmake configure when building on powerpcspe.

- The configuration is done in a file called debian/rules, and the provided
squeak-vm.patch is a patch for that rules file. This file is not part of
the Squeak VM platforms sources and is presumably maintained externally
by the Debian folks.

- The right way to fix the build problem in the platforms sources would be
to modify platforms/unix/plugins/SqueakFFIPrims/config.cmake to disable
the FFI plugin for powerpcspe at configure time. This is probably easy to
do, although I do not have a way to try it myself.

- Extra credit: If someone wanted FFI to work on powerpcspe, the way to make
this happen would be to write a variation of ppc-sysv-asm.S for powerpcspe
and add it to config.cmake.

Dave


On Mon, Nov 19, 2012 at 06:38:10PM +0100, Bert Freudenberg wrote:

>  
> Begin forwarded message:
>
> > Resent-From: Roland Stigge <[hidden email]>
> > From: Roland Stigge <[hidden email]>
> > Subject: Bug#693633: squeak-vm: FTBFS on powerpcspe (asm stfd/lfd)
> > Date: 18. November 2012 21:10:04 MEZ
> > Resent-To: [hidden email]
> > To: Debian Bug Tracking System <[hidden email]>
> > Resent-Cc: Debian Squeak Team <[hidden email]>
> > Reply-To: Roland Stigge <[hidden email]>, [hidden email]
> >
> > Package: squeak-vm
> > Version: 1:4.4.7.2357-1.1
> > Severity: wishlist
> > Tags: sid patch
> > User: [hidden email]
> > Usertags: powerpcspe
> >
> > Hi,
> >
> > squeak-vm FTBFS on powerpcspe [1] like this:
> >
> > [ 82%] Building ASM object SqueakFFIPrims/CMakeFiles/SqueakFFIPrims.dir/<C2><AB>PKGBUILDDIR<C2><BB>/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S.o
> > /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S: Assembler messages:
> > /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S:109: Error: Unrecognized opcode: `lfd'
> > [...]
> >
> > There are some asm statements that only work on powerpc but not on powerpcspe.
> >
> > Attaching a patch that fixes it by disabling the SqueakFFIPrims plugin on
> > powerpcspe.
> >
> > Thanks,
> >
> > Roland
> >
> >
> > [1] http://wiki.debian.org/PowerPCSPEPort
> >
> > -- System Information:
> > Debian Release: wheezy/sid
> >  APT prefers unstable
> >  APT policy: (500, 'unstable'), (1, 'experimental')
> > Architecture: amd64 (x86_64)
> >
> > Kernel: Linux 3.5.0 (SMP w/4 CPU cores)
> > Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_GB.UTF-8)
> > Shell: /bin/sh linked to /bin/dash


> >
>

Reply | Threaded
Open this post in threaded view
|

Re: [unix] Unrecognized opcode in FFI on PowerPC SPE

David T. Lewis
 
On Sun, Nov 25, 2012 at 05:25:03PM +0100, Roland Stigge wrote:

>
> On 25/11/12 17:03, David T. Lewis wrote:
> > To summarize my understanding of this issue (see below for background):
> > [...]
> > - The right way to fix the build problem in the platforms sources would be
> > to modify platforms/unix/plugins/SqueakFFIPrims/config.cmake to disable
> > the FFI plugin for powerpcspe at configure time. This is probably easy to
> > do, although I do not have a way to try it myself.
>
> If you have a proposal, feel free to contact me so I can test.

Hi Roland,

If you have access to a powerpcspe platform, could you please run the
unix/cmake/config.guess script and let us know the exact output when running
on powerpcspe? This information is used to enable or disable the various FFI
sources according to platform. I doubt that any of the Squeak VM developers
have access to a powerpcspe box, but we can probably figure out what to do
based on the config.guess output.

You may also be able to make a patch directly in the cmake configuration
file unix/plugins/SqueakFFIPrims/config.cmake based on whatever you find
from the config.guess output. The config.cmake file is written in cmake
script, but it is fairly readable even if you don't know cmake. If you
come up with something that works, please send a copy of the config.cmake.

Thanks a lot,

Dave

Reply | Threaded
Open this post in threaded view
|

Re: [unix] Unrecognized opcode in FFI on PowerPC SPE

Bert Freudenberg
In reply to this post by David T. Lewis


On 2012-11-25, at 17:03, "David T. Lewis" <[hidden email]> wrote:

>
> To summarize my understanding of this issue (see below for background):
>
> - powerpcspe is variant of powerpc that lacks certain parts of the powerpc
> instruction set, as explained here: http://wiki.debian.org/PowerPCSPEPort
>
> - The FFI plugin has architecture-specific assembler modules that set
> up the entry points for FFI calls. The assembly module for powerpc is
> platforms/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S
>
> - The ppc-sysv-asm.S module uses one or more instructions ('lfd', possibly
> others) that are not available on  the powerpcspe processor, and the the
> module cannot be compiled on powerpcspe.
>
> - The solution for the Debian build is to not build the FFI plugin when
> compiling for powerpcspe. This is done by passing the --without-SqueakFFIPrims
> option to the cmake configure when building on powerpcspe.
>
> - The configuration is done in a file called debian/rules, and the provided
> squeak-vm.patch is a patch for that rules file. This file is not part of
> the Squeak VM platforms sources and is presumably maintained externally
> by the Debian folks.
>
> - The right way to fix the build problem in the platforms sources would be
> to modify platforms/unix/plugins/SqueakFFIPrims/config.cmake to disable
> the FFI plugin for powerpcspe at configure time. This is probably easy to
> do, although I do not have a way to try it myself.
>
> - Extra credit: If someone wanted FFI to work on powerpcspe, the way to make
> this happen would be to write a variation of ppc-sysv-asm.S for powerpcspe
> and add it to config.cmake.
>
> Dave

Instead of disabling FFI it might be possible to fall back to libffi, as is done for some other architectures (e.g. ARM).

- Bert -



>
> On Mon, Nov 19, 2012 at 06:38:10PM +0100, Bert Freudenberg wrote:
>>
>> Begin forwarded message:
>>
>>> Resent-From: Roland Stigge <[hidden email]>
>>> From: Roland Stigge <[hidden email]>
>>> Subject: Bug#693633: squeak-vm: FTBFS on powerpcspe (asm stfd/lfd)
>>> Date: 18. November 2012 21:10:04 MEZ
>>> Resent-To: [hidden email]
>>> To: Debian Bug Tracking System <[hidden email]>
>>> Resent-Cc: Debian Squeak Team <[hidden email]>
>>> Reply-To: Roland Stigge <[hidden email]>, [hidden email]
>>>
>>> Package: squeak-vm
>>> Version: 1:4.4.7.2357-1.1
>>> Severity: wishlist
>>> Tags: sid patch
>>> User: [hidden email]
>>> Usertags: powerpcspe
>>>
>>> Hi,
>>>
>>> squeak-vm FTBFS on powerpcspe [1] like this:
>>>
>>> [ 82%] Building ASM object SqueakFFIPrims/CMakeFiles/SqueakFFIPrims.dir/<C2><AB>PKGBUILDDIR<C2><BB>/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S.o
>>> /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S: Assembler messages:
>>> /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S:109: Error: Unrecognized opcode: `lfd'
>>> [...]
>>>
>>> There are some asm statements that only work on powerpc but not on powerpcspe.
>>>
>>> Attaching a patch that fixes it by disabling the SqueakFFIPrims plugin on
>>> powerpcspe.
>>>
>>> Thanks,
>>>
>>> Roland
>>>
>>>
>>> [1] http://wiki.debian.org/PowerPCSPEPort
>>>
>>> -- System Information:
>>> Debian Release: wheezy/sid
>>> APT prefers unstable
>>> APT policy: (500, 'unstable'), (1, 'experimental')
>>> Architecture: amd64 (x86_64)
>>>
>>> Kernel: Linux 3.5.0 (SMP w/4 CPU cores)
>>> Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_GB.UTF-8)
>>> Shell: /bin/sh linked to /bin/dash
>
>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: [unix] Unrecognized opcode in FFI on PowerPC SPE

Eliot Miranda-2
 
Bert,


On Mon, Nov 26, 2012 at 5:16 AM, Bert Freudenberg <[hidden email]> wrote:


On 2012-11-25, at 17:03, "David T. Lewis" <[hidden email]> wrote:

>
> To summarize my understanding of this issue (see below for background):
>
> - powerpcspe is variant of powerpc that lacks certain parts of the powerpc
> instruction set, as explained here: http://wiki.debian.org/PowerPCSPEPort
>
> - The FFI plugin has architecture-specific assembler modules that set
> up the entry points for FFI calls. The assembly module for powerpc is
> platforms/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S
>
> - The ppc-sysv-asm.S module uses one or more instructions ('lfd', possibly
> others) that are not available on  the powerpcspe processor, and the the
> module cannot be compiled on powerpcspe.
>
> - The solution for the Debian build is to not build the FFI plugin when
> compiling for powerpcspe. This is done by passing the --without-SqueakFFIPrims
> option to the cmake configure when building on powerpcspe.
>
> - The configuration is done in a file called debian/rules, and the provided
> squeak-vm.patch is a patch for that rules file. This file is not part of
> the Squeak VM platforms sources and is presumably maintained externally
> by the Debian folks.
>
> - The right way to fix the build problem in the platforms sources would be
> to modify platforms/unix/plugins/SqueakFFIPrims/config.cmake to disable
> the FFI plugin for powerpcspe at configure time. This is probably easy to
> do, although I do not have a way to try it myself.
>
> - Extra credit: If someone wanted FFI to work on powerpcspe, the way to make
> this happen would be to write a variation of ppc-sysv-asm.S for powerpcspe
> and add it to config.cmake.
>
> Dave

Instead of disabling FFI it might be possible to fall back to libffi, as is done for some other architectures (e.g. ARM).

IMO, much better would be to add PPC support to ThreadedFFIPlugin.  This is a framework for cross-platform FFI, currently instantiated for x86, but it has all the hooks one needs to write a PPC interface.  This uses minimal assembler, essentially only the occasional asm statement, e.g. to set the flag that indicates a call has active floating-point parameters, or to adjust the stack pointer after an alloca.  Being written in terms of the C library's alloca stack allocator to create the outgoing argument frame it is a) more efficient since arguments are not copied from a marshalling space to the outgoing stack frame as occurs in the old FFI, and b) reentrant, since there is no static area used for marshalling.

I've written support for PPC for VisualWorks in the same way so I do know this approach does work and would be happy to help anyone with a PPC mahcine who was interested in biting the bullet.  The tricky issues are the need to pass register arguments alongside the stacked arguments, and the need to avoid overwriting the marshalling area of the alloca'ed argument frame when calling functions involved in marshalling arguments.  The first issue is solved by always calling the external function as if it had 8 register arguments, and passing 8 arguments, hence loading the argument registers.  The second issue is solved by over allocating and cutting back the stack with an asm statement just before the call.

You'll find that the framework was written with this in mind even if the support for PPC and ARM (and SPARC and AXP and MIPS, all of which I wrote for the VisualWorks VM) isn't complete yet.

cheers
Eliot

- Bert -



>
> On Mon, Nov 19, 2012 at 06:38:10PM +0100, Bert Freudenberg wrote:
>>
>> Begin forwarded message:
>>
>>> Resent-From: Roland Stigge <[hidden email]>
>>> From: Roland Stigge <[hidden email]>
>>> Subject: Bug#693633: squeak-vm: FTBFS on powerpcspe (asm stfd/lfd)
>>> Date: 18. November 2012 21:10:04 MEZ
>>> Resent-To: [hidden email]
>>> To: Debian Bug Tracking System <[hidden email]>
>>> Resent-Cc: Debian Squeak Team <[hidden email]>
>>> Reply-To: Roland Stigge <[hidden email]>, [hidden email]
>>>
>>> Package: squeak-vm
>>> Version: 1:4.4.7.2357-1.1
>>> Severity: wishlist
>>> Tags: sid patch
>>> User: [hidden email]
>>> Usertags: powerpcspe
>>>
>>> Hi,
>>>
>>> squeak-vm FTBFS on powerpcspe [1] like this:
>>>
>>> [ 82%] Building ASM object SqueakFFIPrims/CMakeFiles/SqueakFFIPrims.dir/<C2><AB>PKGBUILDDIR<C2><BB>/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S.o
>>> /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S: Assembler messages:
>>> /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S:109: Error: Unrecognized opcode: `lfd'
>>> [...]
>>>
>>> There are some asm statements that only work on powerpc but not on powerpcspe.
>>>
>>> Attaching a patch that fixes it by disabling the SqueakFFIPrims plugin on
>>> powerpcspe.
>>>
>>> Thanks,
>>>
>>> Roland
>>>
>>>
>>> [1] http://wiki.debian.org/PowerPCSPEPort
>>>
>>> -- System Information:
>>> Debian Release: wheezy/sid
>>> APT prefers unstable
>>> APT policy: (500, 'unstable'), (1, 'experimental')
>>> Architecture: amd64 (x86_64)
>>>
>>> Kernel: Linux 3.5.0 (SMP w/4 CPU cores)
>>> Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_GB.UTF-8)
>>> Shell: /bin/sh linked to /bin/dash
>
>
>>>
>>
>




--
best,
Eliot