Skip to main content

Module embed

Module embed 

Source
Expand description

Running a Cove program that a native executable carries inside itself.

cove build writes a small Rust crate whose main hands the package’s sources, its [run.<name>] table, and the backend it was built for to Embedded::main. That crate links this one, so the executable it produces embeds a backend rather than compiling Cove to machine code; see ADR 0009, and ADR 0022 for which backend that now is.

§Why the binary lowers, and why cove build lowers too

The IR is not a serialization format, so a built binary cannot carry one: it carries its sources, resolves them, and lowers them when it starts. That is a few hundred microseconds against a run that lasts as long as the program does.

What it must not do is discover at that moment that it cannot run. So cove build lowers the same entry at build time and refuses to write a binary it would refuse to start – because the person who can act on the refusal is the one holding the source, and they are not the one holding the binary. ADR 0034 makes such a refusal a bug in the lowering rather than a construct the backend declines, which is why what comes back is a diagnostic and not a named construct.

register_hosts is the one place the host implementations a run gets are chosen. cove run and a built binary both call it, so a built binary cannot drift into registering a different boundary than the run it was built from.

Structs§

Embedded
A whole program: the sources a built binary carries, the run it carries them for, and the backend it runs them on.
EmbeddedRun
The [run.<name>] table a built binary carries.
EmbeddedSource
One .cove file a built binary carries.
HostSetup
The hosts a run is given, and the directories they are confined to.

Enums§

EmbeddedBackend
Which backend a built binary runs its program on.

Functions§

register_hosts
Registers every host implementation a run may reach, granting exactly setup.grants.