Bert,<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Nov 26, 2012 at 5:16 AM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
<br>
On 2012-11-25, at 17:03, &quot;David T. Lewis&quot; &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt; wrote:<br>
<br>
&gt;<br>
&gt; To summarize my understanding of this issue (see below for background):<br>
&gt;<br>
&gt; - powerpcspe is variant of powerpc that lacks certain parts of the powerpc<br>
&gt; instruction set, as explained here: <a href="http://wiki.debian.org/PowerPCSPEPort" target="_blank">http://wiki.debian.org/PowerPCSPEPort</a><br>
&gt;<br>
&gt; - The FFI plugin has architecture-specific assembler modules that set<br>
&gt; up the entry points for FFI calls. The assembly module for powerpc is<br>
&gt; platforms/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S<br>
&gt;<br>
&gt; - The ppc-sysv-asm.S module uses one or more instructions (&#39;lfd&#39;, possibly<br>
&gt; others) that are not available on  the powerpcspe processor, and the the<br>
&gt; module cannot be compiled on powerpcspe.<br>
&gt;<br>
&gt; - The solution for the Debian build is to not build the FFI plugin when<br>
&gt; compiling for powerpcspe. This is done by passing the --without-SqueakFFIPrims<br>
&gt; option to the cmake configure when building on powerpcspe.<br>
&gt;<br>
&gt; - The configuration is done in a file called debian/rules, and the provided<br>
&gt; squeak-vm.patch is a patch for that rules file. This file is not part of<br>
&gt; the Squeak VM platforms sources and is presumably maintained externally<br>
&gt; by the Debian folks.<br>
&gt;<br>
&gt; - The right way to fix the build problem in the platforms sources would be<br>
&gt; to modify platforms/unix/plugins/SqueakFFIPrims/config.cmake to disable<br>
&gt; the FFI plugin for powerpcspe at configure time. This is probably easy to<br>
&gt; do, although I do not have a way to try it myself.<br>
&gt;<br>
&gt; - Extra credit: If someone wanted FFI to work on powerpcspe, the way to make<br>
&gt; this happen would be to write a variation of ppc-sysv-asm.S for powerpcspe<br>
&gt; and add it to config.cmake.<br>
&gt;<br>
&gt; Dave<br>
<br>
</div></div>Instead of disabling FFI it might be possible to fall back to libffi, as is done for some other architectures (e.g. ARM).<br></blockquote><div><br></div><div>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&#39;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.</div>
<div><br></div><div>I&#39;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&#39;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.</div>
<div><br></div><div>You&#39;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&#39;t complete yet.</div>
<div><br></div><div>cheers</div><div>Eliot</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
- Bert -<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
&gt;<br>
&gt; On Mon, Nov 19, 2012 at 06:38:10PM +0100, Bert Freudenberg wrote:<br>
&gt;&gt;<br>
&gt;&gt; Begin forwarded message:<br>
&gt;&gt;<br>
&gt;&gt;&gt; Resent-From: Roland Stigge &lt;<a href="mailto:stigge@antcom.de">stigge@antcom.de</a>&gt;<br>
&gt;&gt;&gt; From: Roland Stigge &lt;<a href="mailto:stigge@antcom.de">stigge@antcom.de</a>&gt;<br>
&gt;&gt;&gt; Subject: Bug#693633: squeak-vm: FTBFS on powerpcspe (asm stfd/lfd)<br>
&gt;&gt;&gt; Date: 18. November 2012 21:10:04 MEZ<br>
&gt;&gt;&gt; Resent-To: <a href="mailto:debian-bugs-dist@lists.debian.org">debian-bugs-dist@lists.debian.org</a><br>
&gt;&gt;&gt; To: Debian Bug Tracking System &lt;<a href="mailto:submit@bugs.debian.org">submit@bugs.debian.org</a>&gt;<br>
&gt;&gt;&gt; Resent-Cc: Debian Squeak Team &lt;<a href="mailto:pkg-squeak-devel@lists.alioth.debian.org">pkg-squeak-devel@lists.alioth.debian.org</a>&gt;<br>
&gt;&gt;&gt; Reply-To: Roland Stigge &lt;<a href="mailto:stigge@antcom.de">stigge@antcom.de</a>&gt;, <a href="mailto:693633@bugs.debian.org">693633@bugs.debian.org</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Package: squeak-vm<br>
&gt;&gt;&gt; Version: 1:4.4.7.2357-1.1<br>
&gt;&gt;&gt; Severity: wishlist<br>
&gt;&gt;&gt; Tags: sid patch<br>
&gt;&gt;&gt; User: debian-powerpcspe@breakpoint.cc<br>
&gt;&gt;&gt; Usertags: powerpcspe<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; squeak-vm FTBFS on powerpcspe [1] like this:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; [ 82%] Building ASM object SqueakFFIPrims/CMakeFiles/SqueakFFIPrims.dir/&lt;C2&gt;&lt;AB&gt;PKGBUILDDIR&lt;C2&gt;&lt;BB&gt;/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S.o<br>
&gt;&gt;&gt; /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S: Assembler messages:<br>
&gt;&gt;&gt; /PKGBUILDDIR/unix/plugins/SqueakFFIPrims/ppc-sysv-asm.S:109: Error: Unrecognized opcode: `lfd&#39;<br>
&gt;&gt;&gt; [...]<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; There are some asm statements that only work on powerpc but not on powerpcspe.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Attaching a patch that fixes it by disabling the SqueakFFIPrims plugin on<br>
&gt;&gt;&gt; powerpcspe.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thanks,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Roland<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; [1] <a href="http://wiki.debian.org/PowerPCSPEPort" target="_blank">http://wiki.debian.org/PowerPCSPEPort</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; -- System Information:<br>
&gt;&gt;&gt; Debian Release: wheezy/sid<br>
&gt;&gt;&gt; APT prefers unstable<br>
&gt;&gt;&gt; APT policy: (500, &#39;unstable&#39;), (1, &#39;experimental&#39;)<br>
&gt;&gt;&gt; Architecture: amd64 (x86_64)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Kernel: Linux 3.5.0 (SMP w/4 CPU cores)<br>
&gt;&gt;&gt; Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_GB.UTF-8)<br>
&gt;&gt;&gt; Shell: /bin/sh linked to /bin/dash<br>
&gt;<br>
&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
</div>