This commit is a slight refactoring of the `Module` trait and backend in `cranelift-object`. The goal is to enable parallelization of compilation when using `cranelift-object`. Currently this is difficult because `ObjectModule::define_function` requires `&mut self`. This instead soups up the `define_function_bytes` interface to handle relocations so compilation can happen externally before defining it in a `Module`. This also means that `define_function` is now a convenience wrapper around `define_function_bytes`.
This crate provides module-level functionality, which allow multiple functions and data to be emitted with Cranelift and then linked together.
This crate is structured as an optional layer on top of cranelift-codegen. It provides additional functionality, such as linking, however users that require greater flexibility don't need to use it.
A module is a collection of functions and data objects that are linked
together. The Module trait that defines a common interface for various kinds
of modules. Most users will use one of the following Module implementations:
SimpleJITModule, provided by cranelift-simplejit, which JITs code to memory for direct execution.ObjectModule, provided by cranelift-object, which emits native object files.