Open
Description
I am building the following code with em++
and despite not using canvas
or webgl
and specifying MINIMAL_RUNTIME
, for some reason the resulting wasm file wants to import the functions: emscripten_set_canvas_element_size
and emscripten_webgl_create_context
. Why are these functions being requested in code that makes no use of these features (especially when requesting a minimal runtime)?
Code
#include <thread>
#include <future>
#include <mutex>
#include <iostream>
#include <vector>
int main() {
int a = 3; int b = 5;
std::mutex m;
int total = 0;
std::vector<std::future<void> > vec_futures;
/* add a */
vec_futures.emplace_back(std::async(std::launch::async, [&m, &total, a] {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
m.lock();
total += a;
m.unlock();
}));
/* add b */
vec_futures.emplace_back(std::async(std::launch::async, [&m, &total, b] {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
m.lock();
total += b;
m.unlock();
}));
for(auto& future: vec_futures) {
future.wait();
}
std::cout << total << std::endl;
return 0;
}
Command line
em++ -pthread -fwasm-exceptions -s PTHREAD_POOL_SIZE=4 -s MINIMAL_RUNTIME=1 --minify 0 node.cpp -o node.html
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.0.1 (5ebe1d421445fa9a4a02c1efc6d42bde3ac90da2)
clang version 14.0.0 (https://github.com/llvm/llvm-project d98dfb2baabb647a6ac4c4f4399999cfc44433db)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: path/to/emsdk/upstream/bin
Metadata
Metadata
Assignees
Labels
No labels