[gambit-list] cross-compilation for dummies

Marc Feeley feeley at iro.umontreal.ca
Sun Dec 14 18:24:14 EST 2008


On 14-Dec-08, at 5:16 PM, Oisín Mac Fhearaí wrote:

> 2008/12/14 Marc Feeley <feeley at iro.umontreal.ca>:
>> Interesting project!  Gambit-C is highly portable because the  
>> Gambit-C
>> compiler generates portable C code.  In principle, and very often in
>> practice, the C code generated can be compiled without modification  
>> on any
>> target platform with a "decent" C compiler.  By "decent" I mean  
>> that it must
>> support all of the ANSI C standard and it must be able to compile  
>> large
>> files without taking too much memory and time.
>>
>> So if you install the prebuilt Gambit on Mac OS X then you can run
>>
>>  gsc -c module.scm
>>
>> to get module.c which you can then compile with the m68k C cross- 
>> compiler.
>> You also need to compile all the files in the lib/ directory.  The  
>> script
>> misc/vctoolkit.bat will give you the basic idea of the files that  
>> need to be
>> compiled and linked (for MS Visual C++).
>
> Hi Marc,
>
> However, I need to link the Gambit runtime with -lgambc - and this has
> to be compiled with the host system compiler along with gsi and gsc,
> right?

All the C file (including those in the runtime system and your  
program) must be compiled with the m68k C compiler.

>
>
> Otherwise:
> ;;;;
> Lyrebird:scheme oisin$ m68k-palmos-gcc test.c test_.c
> -I/Library/Gambit-C/current/include
> -I/Users/oisin/.wine/drive_c/PalmOSCygwin/usr/include/
> test.c:122: warning: overflow in implicit constant conversion
> test_.c:8303: warning: overflow in implicit constant conversion
> /usr/local/m68k-palmos/lib/crt0.o(.text+0x64): In function `start':
> crt0.c:69: undefined reference to `PilotMain'
> /var/folders/ra/raN9YbS9GOKB9pULa-Z47E+++TI/-Tmp-/ccnusdxU.o(.text 
> +0x5a):test.c:
> undefined reference to `___gstate'
> /var/folders/ra/raN9YbS9GOKB9pULa-Z47E+++TI/-Tmp-/ccnusdxU.o(.text 
> +0x110):test.c:
> undefined reference to `___gstate'
> /var/folders/ra/raN9YbS9GOKB9pULa-Z47E+++TI/-Tmp-/ccuO85n7.o(.text 
> +0x34):test_.c:
> undefined reference to `___main_char'
> /var/folders/ra/raN9YbS9GOKB9pULa-Z47E+++TI/-Tmp-/ccuO85n7.o(.data 
> +0x0):test_.c:
> undefined reference to `____20___gambc'
> collect2: ld returned 1 exit status
> ;;;;
>
>> Note that Gambit expects words to be 32 or 64 bits wide.  You claim  
>> that the
>> m68k has 16 bit words, but as I recall it has 32 bit words.
>
> I think on m68k, 8-bit = byte, 16-bit = word, 32-bit = longword. I
> should qualify that I mean specifically the 68000; I think 68020 and
> higher might be fully 32-bit, but the 68000 has 32-bit registers and
> only a 16-bit data bus.

The data bus size has no importance.  What matters is that the  
processor has a complete set of operations on 32 bit values (including  
address space, and load/store).

>
>
>> Also, if you want a native code compiler, the first version of  
>> Gambit (up to
>> version 2.2) generated very tight code for m68k.  So perhaps you  
>> can also
>> try to get it to work with the Palm.  See
>>
>> http://www.iro.umontreal.ca/~gambit/.dl/gamb68k.tar.Z
>
> Thanks for this, it sounds like it might be close to what I want,
> given the fairly painful size constraints on the Palm. :)

If I recall, the interpreter of v2.2 was about 300 kbytes.

Marc




More information about the Gambit-list mailing list