Hi all,
I'm fairly out of my depth here, trying to compile Gambit such that it will cross-compile (on OS X) and produce executables that will run on my old m68k-based Palm (err, actually ARM-based, but with some weird caveats that make it easier to use 68k). There doesn't seem to be any documentation on how to do such a thing, but grepping in the latest source release implies that it can be done via the "--host" configure option.
With the following configure command: ./configure --prefix=/Users/oisin/code/palm/scheme/gambit/ --host=m68k-palmos --enable-ansi-c --enable-char-size=2 --enable-single-host (the enable-ansi-c and char-size=2 options were just a stab in the dark and neither help nor hinder)
and the following make line (for wchar.h): C_INCLUDE_PATH=/Users/oisin/.wine/drive_c/PalmOSCygwin/usr/include/ make
...I get hundreds of thousands of errors like this, before the build gives up: /var/folders/ra/raN9YbS9GOKB9pULa-Z47E+++TI/-Tmp-/cc7yLvmh.s:193444: Error: Value of 716162 too large for field of 2 bytes at 0x81dfa /var/folders/ra/raN9YbS9GOKB9pULa-Z47E+++TI/-Tmp-/cc7yLvmh.s:193444: Error: Signed .word overflow; switch may be too large; 716162 at 0x81dfa ..... make[1]: *** [_io.o] Error 1 make: *** [all-recursive] Error 1
Maybe this is because the 68k only has a 16-bit word size. Does it mean that Gambit C can't be build to compile for the 68k, or is there a way to do it?
thanks, Oisín
Afficher les réponses par date
On 13-Dec-08, at 11:08 PM, Oisín Mac Fhearaí wrote:
Hi all,
I'm fairly out of my depth here, trying to compile Gambit such that it will cross-compile (on OS X) and produce executables that will run on my old m68k-based Palm (err, actually ARM-based, but with some weird caveats that make it easier to use 68k). There doesn't seem to be any documentation on how to do such a thing, but grepping in the latest source release implies that it can be done via the "--host" configure option.
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++).
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.
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
Marc
2008/12/14 Marc Feeley feeley@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?
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.
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
Thanks for this, it sounds like it might be close to what I want, given the fairly painful size constraints on the Palm. :)
Oisín
On 14-Dec-08, at 5:16 PM, Oisín Mac Fhearaí wrote:
2008/12/14 Marc Feeley feeley@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
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