When making module from static artifact, it is currently required to include C header made using gen-c-header subcommand. This header includes implementation of generate_serialized_data_{prefix} function. It makes loading static artifacts more complicated, especially from Rust.
generate_serialized_data_{prefix} is actually simple: it accepts no parameters and concatenates WASMER_METADATA_{prefix} with some function pointers. Every invocation of generate_serialized_data_{prefix} returns same data.
Proposed solution
The idea is to append these function pointers to WASMER_METADATA_{prefix} and add WASMER_METADATA_{prefix}_SIZE, so static artifact can be loaded without including generated C header. This solution should not break loading static artifact using generated C header.
Alternatives
It is theoretically possible to move generate_serialized_data_{prefix} to object generated using create-exe and create-obj subcommand, but it seems to be too complicated and not reasonable.
Additional context
Example code loading static artifact. No C code is used.
Motivation
When making module from static artifact, it is currently required to include C header made using
gen-c-header
subcommand. This header includes implementation ofgenerate_serialized_data_{prefix}
function. It makes loading static artifacts more complicated, especially from Rust.generate_serialized_data_{prefix}
is actually simple: it accepts no parameters and concatenatesWASMER_METADATA_{prefix}
with some function pointers. Every invocation ofgenerate_serialized_data_{prefix}
returns same data.Proposed solution
The idea is to append these function pointers to
WASMER_METADATA_{prefix}
and addWASMER_METADATA_{prefix}_SIZE
, so static artifact can be loaded without including generated C header. This solution should not break loading static artifact using generated C header.Alternatives
It is theoretically possible to move
generate_serialized_data_{prefix}
to object generated usingcreate-exe
andcreate-obj
subcommand, but it seems to be too complicated and not reasonable.Additional context
Example code loading static artifact. No C code is used.
Here is a draft implementation of this feature. I am not very experienced in rust, so it is not likely that I will make a PR.