Export all functions with alpha numeric names from entrypoint module #1425
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is part of the implementation for #1419
This PR adds
__attribute__((export_name(<name>))
declarations to every type signature corresponding to every symbol in the entry point module that has an alpha numeric name (so that it can safely be present in the output C file). This is an intermediate step to adding the export information to thejuvix.yaml
file as described in #1419.This causes these functions to be present in the export table of the resulting WASM module.
To test this we need to be able to invoke the exported functions using the WASM module. This raises the issue of how we will execute these functions in the Anoma VM and (possibly) in the browser. For this use case it is not appropriate to use the WASM-WASI runtime as these IO functions (providing
fd_write
,fd_read
,proc_exit
etc.) are not available in the Anoma VM or in the browser.So this PR also adds a new standalone runtime for the compiler, in addition to the WASI standalone and the WASI libc runtimes. This runtime is appropriate for compiling WASM libraries which export functions that can be invoked without the WASI imports (and that do not, for example, have a main entry point). This is the runtime we'll use for compiling validity predicates for example.
To try this runtime out:
cd tests/positive/MiniC/ExportName juvix compile --runtime standalone Input.juvix
Then use wasmer to inspect the output WASM file, see it exports all the functions in scope in the module:
We can then invoke the
fun
function for example: