Guile Mailing List Archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hobbit problems



On Fri, 13 Nov 1998, Bernard URBAN wrote:

> A good example of how to use modules is hobbit itself...
> Have a look at how hobbit4d/libhob.scm is compiled as a module.
> The safe way to use modules with hobbit is to mimic this process.
> 
> This may solve the problem you have with cdr.
> If not, could you post a short and COMPLETE exemple showing this
> problem ?

I have a really minimal example:

----------------- test.scm: begin ----------------
(define my_car car)
------------------ test.scm: end -----------------

I performed the following commands:

hob -v -c test.scm                            #  the log is given below
guile
guile> (use-modules (hobbit4d link))
guile> (hobbit-load-from-path "test")
guile> car
ERROR: In expression car:
ERROR: Unbound variable: car
ABORT: (misc-error)

Type "(backtrace)" to get more information.
guile> cdr
#<primitive-procedure cdr>
guile> 


This example shows that the problem occurs if a function is given a
new name. As you can see, no module stuff is used (at least not by me).
Only those functions that are given a new name are influenced, since 'cdr'
is still defined.

I still can't tell the reason, since the generated C code (which I
enclose at the bottom) makes sense to me (although I haven't looked very
deeply into how interned symbols work).

Best regards, 
Dirk Herrmann





----------------- test.h: begin ----------------
#include <guilehob.h>


/* *to-do-fun-list* */
static SCM H_top_actions_test();
SCM scm_init_test();
/* *constant-list-var*  *global-vars-list* */
static SCM *protect_constants_test;
static SCM *H_car;
static SCM *H_my_car;
/* *interpreter-funname-table* */
/* *symbol-and-fun-list* */
/* *lifted-trivial-closure-names* */
/* *lifted-closure-names* */
/* *symbol-constant-table* */
/* *new-constant-list* */
/* *stable-vector-names* */
/* *fast-vars-list* */
------------------ test.h: end -----------------
----------------- test.c: begin ----------------
#include "test.h"

static SCM H_top_actions_test()
{
  {
    GLOBAL(H_my_car) = GLOBAL(H_car);
#ifdef HOBBIT_MODULE
    scm_variable_set_x(scm_eval_0str("(let ((v (module-variable (current-module) 'my_car )))""  (if v v (module-make-local-var! (current-module) 'my_car )))"),GLOBAL(H_my_car));
#endif
  }
  return SCM_UNSPECIFIED;
}

SCM scm_init_test()
{
  H_car = &SCM_CDR(intern("car",3));
  H_my_car = &SCM_CDR(intern("my_car",6));
  protect_constants_test = &SCM_CDR(intern("protect_constants_test",22));
  {
    GLOBAL(protect_constants_test) = SCM_EOL;
#ifdef HOBBIT_MODULE
    scm_variable_set_x(scm_eval_0str("(let ((v (module-variable (current-module) 'protect_constants_test )))""  (if v v (module-make-local-var! (current-module) 'protect_constants_test )))"),GLOBAL(protect_constants_test));
#endif
  }
  H_top_actions_test();
}
------------------ test.c: end -----------------



------- output of 'hob -v -c test.scm': --------
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/link.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/defs.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/guile-hobbit.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/lib-hobbit
;;; static loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/libhob.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/slib/defmacroexpand.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/slib/defmacex.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/slib/pprint-file.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/slib/ppfile.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/slib/pretty-print.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/slib/pp.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/slib/generic-write.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/slib/genwrite.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/genc.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/rename.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/pass2.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/pass1.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/quasiquote.scm
;;; loading /automatix/home/dirk/pub/guile-19981109/share/guile/site/hobbit4d/normalize.scm

Starting to read test.scm

Bounded integer (fast) arithmetic assumed.

** Pass 1 completed **
** Pass 2 completed **
** Pass 3 completed **
** Pass 4 completed **
** Pass 5 completed **
** Pass 6 completed **

C source file test.c is built.
C header file test.h is built.


libtool --mode=compile gcc -g -O2 -c -I. -I/automatix/home/dirk/pub/guile-19981109/include -I/automatix/home/dirk/pub/guile-19981109/include/guile test.c
gcc -g -O2 -c -I. -I/automatix/home/dirk/pub/guile-19981109/include -I/automatix/home/dirk/pub/guile-19981109/include/guile -fPIC -DPIC test.c
mv -f test.o test.lo
gcc -g -O2 -c -I. -I/automatix/home/dirk/pub/guile-19981109/include -I/automatix/home/dirk/pub/guile-19981109/include/guile test.c >/dev/null 2>&1
libtool --mode=link gcc -g -O2  -o libtest.la -rpath /automatix/home/dirk/temp/hobbit-bug-reports test.lo
mkdir .libs
gcc -shared -Wl,-soname -Wl,libtest.so.0 -o .libs/libtest.so.0.0.0 test.lo
(cd .libs && ln -s libtest.so.0.0.0 libtest.so.0)
(cd .libs && ln -s libtest.so.0.0.0 libtest.so)
ar cru .libs/libtest.a test.o
ranlib .libs/libtest.a
creating libtest.la
(cd .libs && ln -s ../libtest.la libtest.la)
libtool --mode=install /automatix/home/dirk/pub/guile/bin/hob-install -c libtest.la /automatix/home/dirk/temp/hobbit-bug-reports/libtest.la
/automatix/home/dirk/pub/guile/bin/hob-install -c .libs/libtest.so.0.0.0 /automatix/home/dirk/temp/hobbit-bug-reports/libtest.so.0.0.0
rm -f /automatix/home/dirk/temp/hobbit-bug-reports/libtest.so.0 /automatix/home/dirk/temp/hobbit-bug-reports/libtest.so
(cd /automatix/home/dirk/temp/hobbit-bug-reports && ln -s libtest.so.0.0.0 libtest.so.0)
(cd /automatix/home/dirk/temp/hobbit-bug-reports && ln -s libtest.so.0.0.0 libtest.so)
chmod +x /automatix/home/dirk/temp/hobbit-bug-reports/libtest.so.0.0.0
/automatix/home/dirk/pub/guile/bin/hob-install -c libtest.la /automatix/home/dirk/temp/hobbit-bug-reports/libtest.la
/automatix/home/dirk/pub/guile/bin/hob-install -c .libs/libtest.a /automatix/home/dirk/temp/hobbit-bug-reports/libtest.a
ranlib /automatix/home/dirk/temp/hobbit-bug-reports/libtest.a
chmod 644 /automatix/home/dirk/temp/hobbit-bug-reports/libtest.a
----------------------------------------------------------------------
Libraries have been installed in:
   /automatix/home/dirk/temp/hobbit-bug-reports

To link against installed libraries in a given directory, LIBDIR,
you must use the `-LLIBDIR' flag during linking.

 You will also need to do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
libtool --mode=uninstall rm -rf .libs test.lo
rm -rf .libs
rm -rf test.lo ./test.o


Guile Home | Main Index | Thread Index