[gambit-list] Gambit's Linking Model
Christian Jaeger
christian at pflanze.mine.nu
Thu Jun 14 05:04:32 EDT 2007
>From the point of view of reloading, there does not seem to be any
difference between statically linked objects and .oX object files! You
can link everything into one executable file and still "patch" that
binary exactly as if you had loaded all objects as .oX files. No need
for set! hackery. You can "have your cake and eat it too".
The rules which identifyers are fixed at compiletime through block
mode are still the same, regardless of linking mode. If you use the
same "block" granularity in building your .oX 'patch' files as you
have used to build your exe, there should be no problem.
$ cat test-load.scm
(declare
(block)
(standard-bindings)
(extended-bindings))
(define (print-world)
(display (list "Hello " world "\n")))
(print-world)
(##repl)
$ cat test-load-one.scm
(declare
(block)
(standard-bindings)
(extended-bindings))
(define world "World")
(define (remote-print-world)
(display (list "Hello " world "\n")))
$ gsc -link test-load-one test-load
test-load-one:
test-load:
$ gcc -O3 -fomit-frame-pointer -mpreferred-stack-boundary=2 test-load.c test-load-one.c test-load_.c -I/usr/local/Gambit-C/current/include -L/usr/local/Gambit-C/current/lib -lgambc -lm -lutil -ldl -o test-load
$ ./test-load
Hello World
> (remote-print-world)
Hello World
change world in test-load-one.scm to "new World", from another shell issue
$ gsc test-load-one
then in the old running instance:
> (load "test-load-one")
"/home/chris/schemedevelopment/gambit/work/test-load-one.o1"
> (remote-print-world)
Hello new World
;; ^- this is because remote-print-world has been recompiled and
;; reloaded as well.
> (print-world)
Hello new World
>
$ l
-rw-rw-r-- 1 chris chris 304 2007-06-14 10:45 test-load.scm
-rw-rw-r-- 1 chris chris 4679 2007-06-14 10:51 test-load.c
-rw-rw-r-- 1 chris chris 389741 2007-06-14 10:51 test-load_.c
-rwxrwxr-x 1 chris chris 17323 2007-06-14 10:51 test-load
-rw-rw-r-- 1 chris chris 179 2007-06-14 10:51 test-load-one.scm
-rwxrwxr-x 1 chris chris 7906 2007-06-14 10:52 test-load-one.o1
More information about the Gambit-list
mailing list