mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Try using C for the wasm test platform
This commit is contained in:
parent
b8f40011b9
commit
5d4518c8d1
2 changed files with 24 additions and 1 deletions
|
@ -122,7 +122,7 @@ pub fn helper_wasm<'a, T: Wasm32TestResult>(
|
|||
);
|
||||
|
||||
// We can either generate the test platform or write an external source file, whatever works
|
||||
generate_test_platform(&mut wasm_module, arena);
|
||||
// generate_test_platform(&mut wasm_module, arena);
|
||||
|
||||
let mut module_bytes = std::vec::Vec::with_capacity(4096);
|
||||
wasm_module.serialize_mut(&mut module_bytes);
|
||||
|
|
23
compiler/test_gen/src/helpers/wasm_test_platform.c
Normal file
23
compiler/test_gen/src/helpers/wasm_test_platform.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <stdlib.h>
|
||||
extern void* test_wrapper();
|
||||
|
||||
void* roc_alloc(size_t size, unsigned int alignment) {
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void* roc_realloc(void* ptr, size_t old_size, size_t new_size, unsigned int alignment) {
|
||||
return realloc(ptr, new_size);
|
||||
}
|
||||
|
||||
void roc_dealloc(void* ptr, unsigned int alignment) {
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
// Having a main function seems to make it easier to convince tools
|
||||
// to include everything in the output binary.
|
||||
// Using C as the source language makes it easier to convince them
|
||||
// to include libc for wasm target, not host.
|
||||
// The returned int is the memory address of the test result
|
||||
int main(void) {
|
||||
return test_wrapper();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue