Hi,

I've cross-compiled Gambit Scheme using devkitPPC for a Wii.
I have used the example Wii 'template' program as the basis for my initial efforts.

My goal is to attempt to produce a Wii executable that has SLIME/EMACS capability and also has all of the good libraries linked in with FFI wrappers eg GRRLIB etc. This means that I should be able to run the Gambit version from the Homebrew Browser and then connect and develop remotely, ultimately using 'gsc' to produce the final stand-a-lone executable once the hacking is over.

I've followed the efforts of James Long and managed to incorporate Gambit into some of my iPhone applications (none for sale yet!) so I know that it does cross-compile and does work, but for now, I am having great difficulties in getting *anything* except register dumps when I call  a function defined with (c-define).

I remember having similar issues on the iPhone but it was because on James' site, he hadn't fully described what he-d done but a few PM-s got that sorted just fine. Thanks James!

First of all, here is how I built the gsc/gsi tools with devkitPPC,

./configure --prefix=/usr/local/Gambit-C/wii --enable-single-host=yes --host=powerpc-eabi

That produces for me /usr/local/Gambit-C/wii/lib/libgambc.a and presumably it is PPC correct with respect to architecture.
I then wrote a small test file called scode.scm in the same folder as the template.c program:

(c-define (wii_blast ) () void "wii_blast" "extern"
  ;; stub
  42)

and use gsc -link scode.scm to produce the scode.c and scode_.c files which the Makefile picks up and uses.

In the template.c file I declare it as...

extern void wii_blast();

Every time I call it I get a register dump and I don't know why! I have reduced the function to void/void so as to remove any possibilities of stack corruption caused by incorrect push/pops due to a misinterpreted function signature etc, I cut my teeth 25 years ago with assembler and you never forget the basics! LOL.

I have included the full template,c at the end of this mail along with the modified makefile incase anybody could tell me what is wrong. I am assuming that the build of 'libgambc.a' is fine because my program does call ___setup() and ___close() with no problems but they would appear to be native C functions and I am assuming that the wii_blast() function is maybe a byte-code thing happening or is it truly C code at this time? That is my ignorance of the internals of GambitC showing now.

My next step is to try to produce a link map and a disassembly of the wii_blast function and then code a function foo:

void foo(void)
{
}

and compare the pre-call and post-call operations to see what is going on... in the  meantime, if anybody cares to point out what I may/am doing wrong I would be most grateful as I really want to be able to build an interactive Wii development toolkit based on scheme, that wraps GRRLIB and libogc in the first instance.

My *real* problem started from that fact that I wanted to be able to use the 'gsc -exe' route to build a complete Wii application in one pass i.e. have a main SCM file that pulls in everything else and then the --cc-options and --ld-options flags would do the rest.... the problem I had is that I couldn't work out how to tell the native gsc to use the target compilers in /opt/devkitpro/devkitPPC/bin !! Is it just setting 'CC' or GAMBC_CC_COMMAND etc etc?

Either way, so far I am pleased with my progress but I am a little stuck right now! Marc Feely, if you are out there dude, got any tips? :)

Thanks,
Sean Charles.