[Stackless] cross compile stackless from x86 to mipsel

Luca Dionisi luca.dionisi at gmail.com
Tue Feb 8 10:27:59 CET 2011

On Tue, Feb 8, 2011 at 2:15 AM, Richard Tew <richard.m.tew at gmail.com> wrote:
> On Tue, Feb 8, 2011 at 5:10 AM, Luca Dionisi <luca.dionisi at gmail.com> wrote:
>> I am trying, without success at the moment, to cross compile stackless
>> (version 2.6.2) from a x86 host (linux) to a mips architecture.
>> I gathered some info on various sites:
>> http://www.cloudinto.com:8080/showItem/showDetail/7962913.html
>> http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html
>> http://www.ailis.de/~k/archives/19-ARM-cross-compiling-howto.html#python
>> I am using a OpenWRT buildroot as cross-compiler tools.
>> What I get is a MIPS executable (and libs) that runs on my router (a
>> Omnima ADM5120) but when I execute stackless.run() with some tasklet
>> then it immediately does a segmentation fault.
>> What could possibly have gone wrong?
> Hi Luca,
> I could only speculate about what went wrong.  Most likely it has to do with
> the custom assembler used on each platform to do the stack switching.
>  Perhaps it compiled in the wrong one (like the x86 assembler routine rather
> than the ARM one), although I expect that to be unlikely.  More likely might
> be that the custom assembler is not compatible with your compiler or target
> environment.

My router has a mipsel architecture, I think that it is compatible
with the custom assembler that is on the code.
But I have difficulties with finding the code that is indeed going
into the executables.
I am not so keen on debugging with linux tools, even more with
assembly. So I tried to use preprocessor directives to find out
(#warning 'blah blah')
I found that __GNUC__, __linux__ and __mips__ are defined.
But, *if* I use correctly the #warning directives, they seem to tell
that the assembly code is not being used.

E.g. I find in the file Stackless/core/slp_transfer.c the code:
    /* This define is no longer needed now? */
    #define SLP_EVAL
    #include "platf/slp_platformselect.h"
and the comment is not clear.
Is the file platf/slp_platformselect.h being included and is the
variable SLP_EVAL being tested?

Also, in this mail from the mailing list
I found that makefiles were patched with flags like these:
   CC=   @CC@ -pthread
   BASECFLAGS=   -fno-strict-aliasing @BASECFLAGS@
   LIBS=     -lpthread -ldl  -lutil # @LIBS@
Do you have an idea why this has been advised? Are they useful for
cross compilation purposes?

By the way, is Wilhelm Shen still listening?

> Keep in mind that when assembler is used to context switch, the state of
> registers which need to be preserved are saved before the switch is made and
> that state is restored when whatever is being switched from is switched back
> to.  If I were you, what I would do is to work out what routine is being
> used when you cross-compile and what registers need to be saved.  You can do
> this in a variety of ways, from reading source code of other switching
> systems (like thread switching) to debugging the code on the target host and
> seeing what bad register value it actually chokes on.
> I have successfully cross-compiled Stackless for ARM before, although I had
> to write my own switching routine.  But it was not with OpenWRT.

ARM? Interesting. By reading this file:
I thought that ARM was not supported yet. There is no line with 'arm'.

I conclude that I am not looking at the right files.
Where do I look to understand which platforms are supported?


More information about the Stackless mailing list