emscripten-core / emscripten-core/emscripten

ERROR_ON_UNDEFINED_SYMBOLS not useful in standalone mode

Open
#17,912 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I compiled the following program that explicitly uses a WASI import to get randomness:

```c
#include
#include
#include

__attribute__((import_module("wasi_snapshot_preview1"),
import_name("random_get")))
int random_get(uint8_t* buffer, uint32_t length);

int getentropy(void* buffer, size_t length) {
return random_get(buffer, length);
}

int main() {
int fd = open("/dev/urandom", O_RDONLY);
assert(fd != -1);

uint8_t buffer[1024] = {};
int nread = read(fd, buffer, 1024);
assert(nread == 1024);

return *(unsigned int*)buffer % 126;
}
```

Compiling with `./emcc test.c -o test.wasm -sWASMFS -sSTANDALONE_WASM` gives the following error:

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.