guile-devel
[Top][All Lists]
Advanced

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

Re: On the deprecated auto-loading of compiled-code modules


From: Marius Vollmer
Subject: Re: On the deprecated auto-loading of compiled-code modules
Date: 01 May 2001 20:38:37 +0200
User-agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7

Matthias Koeppe <address@hidden> writes:

> I embed Guile statically into a program.  Currently I am using
> scm_register_module_xxx to register modules implemented in C with
> Guile, before starting the interpreter.  In the current CVS Guile, I
> get the misleading warning:
> 
> ;;; Autoloading of compiled code modules is deprecated.
> ;;; Write a Scheme file instead that uses `dynamic-link' directly.
> ;;; (You just tried to autoload module (gywopt primitives augm).)
> 
> 1) This warning should also mention the case of statically linked
>    modules registered via scm_register_modules_xxx.

Hmm, yes.  Do you have a specific message that you would like to see?

> 2) What is the "correct" way to register modules in the static case? I
>    somehow need to expose the C-level initialization function to the
>    yet-to-be-started interpreter; this is what
>    scm_register_modules_xxx was for.

Ideally, I would like you to still use `dynamic-call' and
`dynamic-link', even when doing static linking.  Guile is using
libltdl for doing the actual linking, and libltdl has support for
statically linking dynamic libtool libraries.  I didn't try this out
myself, yet.  Could you try?

In effect, I want Guile to hand over almost all dynamic linking
issures to libtool, including the handling of libraries that are not
really dynamically linked.


If oyu don't want to go this untrodden route just now, there are two
options I can see:

- Write a Scheme file for your module (like you would for dynamic
  linking without explicit support), but don't use `dynamic-call' in
  it.  Call the initialization procedure directly.  Like so:

  In C:

    init_module_bindings ()
    {
      #include "foo.x"
    }

    init_module_initializer ()
    {
      scm_make_gsubr ("init-my-module", 0, 0, 0,
                      (SCM (*)())init_module_bindings);
    }

  In Scheme:

    (define-module (my module))
    
    (init-my-module)


- Explicitely create and select your module in the initialization routine

  In C:

    SCM_SYMBOL (sym_my, "my");
    SCM_SYMBOL (sym_modules, "modules");

    init_module_bindings ()
    {
      SCM my_module = scm_make_module (SCM_LIST2 (sym_my, sym_module));
      /* If you want to have Scheme code in the module as well: */
      scm_ensure_user_module (my_module);

      SCM old = scm_set_current_module (my_module);

      #include "foo.x"
      
      scm_set_current_module (old);
    }

  There would be no Scheme file.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]