A dynamic library handle.
Equations
Instances For
A reference to a symbol within a dynamic library.
Equations
- dynlib.Symbol = (Lean.Dynlib.SymbolImpl✝ dynlib).type
Instances For
Dynamically loads a shared library.
The path may also be used perform a system-dependent search for library.
To avoid this, use an absolute path (e.g., from IO.FS.realPath
).
Runs a module initializer function.
The symbol should have the signature (builtin : Bool) → IO Unit
(e.g., initialize_Foo(uint8_t builtin, obj_arg)
).
This function is unsafe because there is no guarantee the symbol has the
expected signature. An invalid symbol can thus produce undefined behavior.
Furthermore, if the initializer introduces pointers (e.g., function closures)
from the dynamic library into the global state, future garbage collection of
the library will produce undefined behavior. In such cases, garbage collection
of the dynamic library can be prevented via Runtime.markPersistent
or
Runtime.forget
.
Dynamically loads a shared library so that its symbols can be used by
the Lean interpreter (e.g., for interpreting @[extern]
declarations).
Equivalent to passing --load-dynlib=path
to lean
.
Lean never unloads libraries. Attempting to load a library that defines symbols shared with a previously loaded library (including itself) will error. If multiple libraries share common symbols, those symbols should be linked and loaded as separate libraries.
Equations
- Lean.loadDynlib path = do let dynlib ← Lean.Dynlib.load path let __discr ← liftM (Lean.loadDynlib.unsafe_impl_1 dynlib) let x : Lean.Dynlib := __discr pure PUnit.unit
Instances For
Loads a Lean plugin and runs its initializers.
A Lean plugin is a shared library built from a Lean module.
This means it has an initialize_<module-name>
symbol that runs the
module's initializers (including its imports' initializers). Initializers
are declared with the initialize
or builtin_initialize
commands.
This is similar to passing --plugin=path
to lean
.
Lean environment initializers, such as definitions calling
registerEnvExtension
, also require Lean.initializing
to be true
.
To enable them, use loadPlugin
within a withImporting
block. This will
set Lean.initializing
(but not IO.initializing
).
Lean never unloads plugins. Attempting to load a plugin that defines symbols shared with a previously loaded plugin (including itself) will error. If multiple plugins share common symbols (e.g., imports), those symbols should be linked and loaded separately.
Equations
- One or more equations did not get rendered due to their size.