Just downloaded and built the latest version. Verbiage in make indicated it was 4.6.6. However, when I fired up gsi and gsc, they both said 4.2.8.
I am running on an x64 Linux system.
Steve
Afficher les réponses par date
I got some errors when I tried to compile a file:
root@mepis1:/opt/gambit# cat test.scm (define (block))
(define (f x) (+ (* x x) (- x 1)))
(define (g y) (f (f y)))
(pp 123)
root@mepis1:/opt/gambit# gsc test.scm *** ERROR IN "/opt/gambit/test.scm"@1.1 -- Ill-formed special form: define root@mepis1:/opt/gambit# gsc -e '(set! c#targ-tree-shake? #t)' test.scm *** ERROR IN (string)@1.1 -- Unbound variable: c#targ-tree-shake?
Any ideas?
Thanks, Steve
________________________________ From: Steve Graham jsgrahamus@yahoo.com To: Gambit List Gambit-list@iro.umontreal.ca Sent: Thursday, June 7, 2012 10:23 AM Subject: [gambit-list] 4.6.6 or 4.2.8
Just downloaded and built the latest version. Verbiage in make indicated it was 4.6.6. However, when I fired up gsi and gsc, they both said 4.2.8.
I am running on an x64 Linux system.
Steve
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
steve@mepis1:~/Desktop$ ls -al test* -rw-r--r-- 1 steve users 97 Jun 7 11:10 test2.scm -rw-r--r-- 1 root root 97 Jun 7 11:03 test.scm steve@mepis1:~/Desktop$ gsc -exe test.scm steve@mepis1:~/Desktop$ ls -al test* -rwxr-xr-x 1 steve users 5449050 Jun 7 11:18 test -rw-r--r-- 1 steve users 97 Jun 7 11:10 test2.scm -rw-r--r-- 1 root root 97 Jun 7 11:03 test.scm steve@mepis1:~/Desktop$ gsc -exe -e '(set! c#targ-tree-shake? #t)' test2.scm steve@mepis1:~/Desktop$ ls -al test* -rwxr-xr-x 1 steve users 5449050 Jun 7 11:18 test -rwxr-xr-x 1 steve users 5449057 Jun 7 11:19 test2 -rw-r--r-- 1 steve users 97 Jun 7 11:10 test2.scm -rw-r--r-- 1 root root 97 Jun 7 11:03 test.scm steve@mepis1:~/Desktop$ ./test 123 steve@mepis1:~/Desktop$ ./test2 123 steve@mepis1:~/Desktop$
So, they both execute, but the tree shaking didn't seem to do much.
Any thoughts?
Thanks, Steve
________________________________ From: Steve Graham jsgrahamus@yahoo.com To: Gambit List Gambit-list@iro.umontreal.ca Sent: Thursday, June 7, 2012 10:31 AM Subject: Re: [gambit-list] 4.6.6 or 4.2.8
I got some errors when I tried to compile a file:
root@mepis1:/opt/gambit# cat test.scm (define (block))
(define (f x) (+ (* x x) (- x 1)))
(define (g y) (f (f y)))
(pp 123)
root@mepis1:/opt/gambit# gsc test.scm *** ERROR IN "/opt/gambit/test.scm"@1.1 -- Ill-formed special form: define root@mepis1:/opt/gambit# gsc -e '(set! c#targ-tree-shake? #t)' test.scm *** ERROR IN (string)@1.1 -- Unbound variable: c#targ-tree-shake?
Any ideas?
Thanks, Steve
________________________________ From: Steve Graham jsgrahamus@yahoo.com To: Gambit List Gambit-list@iro.umontreal.ca Sent: Thursday, June 7, 2012 10:23 AM Subject: [gambit-list] 4.6.6 or 4.2.8
Just downloaded and built the latest version. Verbiage in make indicated it was 4.6.6. However, when I fired up gsi and gsc, they both said 4.2.8.
I am running on an x64 Linux system.
Steve
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Hallo,
On Thu, Jun 7, 2012 at 7:22 PM, Steve Graham jsgrahamus@yahoo.com wrote:
So, they both execute, but the tree shaking didn't seem to do much.
Any thoughts?
The tree shaker seems to work during compilation, not linking. It doesn't avoid bringing all of Gambit-C into your executable.
I remember an ML post where Marc said that, presuming you don't use eval, Gambit's Scheme codebase can be tree-shaked too.
Well just removing unneeded parts of Gambit's core ought to be straightforward enough too; afaik actually *all* of the runtime can be removed and you still have a running system, though I suppose such a system would be of little use.
2012/6/8 Alex Queiroz asandroq@gmail.com
Hallo,
On Thu, Jun 7, 2012 at 7:22 PM, Steve Graham jsgrahamus@yahoo.com wrote:
So, they both execute, but the tree shaking didn't seem to do much.
Any thoughts?
The tree shaker seems to work during compilation, not linking. It doesn't avoid bringing all of Gambit-C into your executable.
-- -alex http://www.artisancoder.com/ _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On 2012-06-08, at 5:50 AM, Mikael wrote:
I remember an ML post where Marc said that, presuming you don't use eval, Gambit's Scheme codebase can be tree-shaked too.
Well just removing unneeded parts of Gambit's core ought to be straightforward enough too; afaik actually *all* of the runtime can be removed and you still have a running system, though I suppose such a system would be of little use.
Tree shaking is done at compile time, and on a single module basis. If you want to tree-shake the whole program including the Scheme libraries, then concatenate all the Scheme library files and your program files into a single source file which you can compile using the tree-shaking flag. With the current Gambit runtime this will give very disapointing results because of the many interdependencies of the runtime system. For example, the default runtime system calls "load" (to load ~~lib/gambcext if it exists), and "load" calls "eval", and "eval" needs all the global variables. So the tree shaker will not be able to eliminate much code.
The tree shaker will be more useful for custom runtime libraries with few interdependencies. A custom runtime library is fairly straightforward to implement (but the coding effort will depend on how much functionality you want). The only required parts of the Gambit runtime library is the file _kernel.scm (which contains low-level functionality expressed in Scheme), and all of the .c files not prefixed by "_" in the lib directory.
As an example, here is how to write a minimal runtime library which implements procedures for doing stdio-like output with putchar and puts. The file minilib.scm contains the definitions of these procedures:
-------------------------------------------------------------------------------------- ;; File: "minilib.scm"
(include "header.scm")
;; Implement a minimal stdio emulation
;; The procedures ##os-device-stream-open-predefined and ;; ##os-device-stream-write, which are defined in _kernel.scm, ;; actually call the C functions ___os_device_stream_open_predefined ;; and ___os_device_stream_write which are implemented in lib/os_io.c .
;; The other "##" procedures are inlined by the Scheme compiler, so ;; there is no need for a Scheme "define" of these procedures and you ;; won't find them in _kernel.scm .
(define stdout (##os-device-stream-open-predefined 1 ;; stdout is 1 (##fx+ (##fx* (macro-direction-shift) (macro-direction-out)) (##fx* (macro-append-shift) (macro-default-append)) (##fx* (macro-truncate-shift) (macro-default-truncate)))))
(define (putchar c) (let ((buf (##u8vector (##fx<-char c)))) (##os-device-stream-write stdout buf 0 1)))
(define (puts str) (let loop ((i 0)) (if (##fx< i (##string-length str)) (begin (putchar (##string-ref str i)) (loop (##fx+ i 1)))))) --------------------------------------------------------------------------------------
and the file miniapp.scm contains the application which uses that runtime system:
-------------------------------------------------------------------------------------- ;; File: "miniapp.scm"
(puts "hello\n") (puts "world\n") --------------------------------------------------------------------------------------
To build the minimal runtime library and application, copy this shell script and the above files to the lib subdirectory and run the shell script:
-------------------------------------------------------------------------------------- #! /bin/sh
CC="gcc"
CLIB="main.o setup.o mem.o c_intf.o os.o os_base.o os_time.o os_shell.o os_files.o os_dyn.o os_tty.o os_io.o"
# create miniature library ../gsc-boot -:=.. -c minilib.scm ../gsc-boot -:=.. -link -flat -o minilib_.c _kernel.c minilib.c $CC -c -I../include -D___SINGLE_HOST -D___LIBRARY -o minilib.o minilib.c $CC -c -I../include -D___SINGLE_HOST -D___LIBRARY -o minilib_.o minilib_.c
# create app linked with the miniature library ../gsc-boot -:=.. -c miniapp.scm ../gsc-boot -:=.. -l minilib_.c -link -o miniapp_.c miniapp.c $CC -c -I../include -D___SINGLE_HOST -o miniapp.o miniapp.c $CC -c -I../include -D___SINGLE_HOST -o miniapp_.o miniapp_.c
$CC -o miniapp $CLIB _kernel.o minilib.o minilib_.o miniapp.o miniapp_.o
strip miniapp ls -l miniapp
./miniapp
echo $? --------------------------------------------------------------------------------------
On Mac OS X Lion, the miniapp executable is 350K when linked with the minimal runtime library, which is quite a bit less than the 3.5M obtained when linking with Gambit's standard runtime library.
Note however that this approach is *bare bones*... None of the standard Scheme procedures are available. You have to implement them if you want them. For examples, if you want the procedure "cons", then you need to add to minilib.scm the following definition which calls ##cons (which is inlined by the compiler):
(define (cons x y) (##cons x y))
If you want the procedure "car" (and you want it to be type safe) then you need something like:
(define (car x) (if (##pair? x) (##car x) (##exit 1)))
If you want better error handling you might want to add an "error" procedure:
(define (error msg) (puts "*** ERROR -- ") (puts msg) (puts "\n") (##exit 1))
(define (car x) (if (##pair? x) (##car x) (error "car expects a PAIR")))
You get the idea...
This gives you a lot of control, and a lot of responsibility.
This is a great way to implement a Scheme system without having to spend time designing a garbage-collector, object representation, operating-system interface, etc. etc. I'm pretty sure a simple interpreter for Scheme (or another language) could be written in Scheme to obtain an executable below one megabyte.
Marc
On 2012-06-07, at 12:31 PM, Steve Graham wrote:
I got some errors when I tried to compile a file:
root@mepis1:/opt/gambit# cat test.scm (define (block))
(define (f x) (+ (* x x) (- x 1)))
(define (g y) (f (f y)))
(pp 123)
root@mepis1:/opt/gambit# gsc test.scm *** ERROR IN "/opt/gambit/test.scm"@1.1 -- Ill-formed special form: define root@mepis1:/opt/gambit# gsc -e '(set! c#targ-tree-shake? #t)' test.scm *** ERROR IN (string)@1.1 -- Unbound variable: c#targ-tree-shake?
Any ideas?
Thanks, Steve
From reading a more recent message of yours, I guess you have discovered that your first line should have been
(declare (block))
Marc