Closed
Description
I am trying to use functions from an external module and importing them like that:
#[link(wasm_import_module = "sqlite")]
extern "C" {
#[link_name="allocate"]
pub fn allocate_external(size: usize) -> i32;
#[link_name="deallocate"]
pub fn deallocate_external(ptr: i32, size: usize);
}
But if I have exported functions with the same names in my own module, there will be linked with these local functions (in these case these functions won't be in the import section of a compiled module). Is it possible to link with functions in external module having functions with the same name in your own?
POC can be found here.
Btw, in C it could be done in this way:
#define __MODULE_IMPORT(module_name, function_name) \
__attribute__((__import_module__(#module_name), __import_name__(#function_name)))
char *allocate_extern(int size) __MODULE_IMPORT(sqlite, allocate);
void deallocate_extern(char *ptr) __MODULE_IMPORT(sqlite, deallocate);
and works perfectly.