Skip to content

Commit

Permalink
Don't generate same-named imports in fact modules (#6783)
Browse files Browse the repository at this point in the history
Ensure that all imports have unique module/name combos to ensure that
the module can be instantiable in JS where separate functions need to be
provided for each import.
  • Loading branch information
alexcrichton authored Jul 28, 2023
1 parent 868f0c3 commit b84bf7a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/environ/src/fact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl<'a> Module<'a> {
let memory = memory.as_ref().map(|memory| {
self.import_memory(
"memory",
"",
&format!("m{}", self.imported_memories.len()),
MemoryType {
minimum: 0,
maximum: None,
Expand All @@ -279,7 +279,12 @@ impl<'a> Module<'a> {
ValType::I32
};
let ty = self.core_types.function(&[ptr, ptr, ptr, ptr], &[ptr]);
self.import_func("realloc", "", ty, func.clone())
self.import_func(
"realloc",
&format!("f{}", self.imported_funcs.len()),
ty,
func.clone(),
)
});

AdapterOptions {
Expand Down

0 comments on commit b84bf7a

Please sign in to comment.