-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
I cannot compile the following file:
#include <thread>
#include <iostream>
#include <unicode/unistr.h>
int main () {
std::thread ([] {
std::string str = "Hello world from thread";
icu::UnicodeString ustr (str.c_str (), str.length (), "UTF-8");
std::cout << str << std::endl;
}).detach ();
}
because when I run em++ main.cpp -pthread -sUSE_ICU -o main.html
, it prints this error message:
wasm-ld: error: --shared-memory is disallowed by umutex.cpp.o because it was not compiled with 'atomics' or 'bulk-memory' features.
em++: error: '/Volumes/SSD/git/emsdk/upstream/bin/wasm-ld -o main.wasm /var/folders/4c/w1bj9h4d5_df436ckn8xxmqr0000gq/T/emscripten_temp_8ba852ps/main_0.o -L/Volumes/SSD/git/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten /Volumes/SSD/git/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libicu_i18n.a /Volumes/SSD/git/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libicu_stubdata.a /Volumes/SSD/git/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libicu_common.a /Volumes/SSD/git/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/crtbegin.o -lGL-mt -lal -lhtml5 -lc-mt -lcompiler_rt-mt -lc++-mt-noexcept -lc++abi-mt-noexcept -ldlmalloc-mt -lc_rt_wasm -lsockets-mt -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --import-memory --shared-memory --strip-debug --export main --export emscripten_stack_get_end --export emscripten_stack_get_free --export emscripten_stack_init --export stackSave --export stackRestore --export stackAlloc --export __wasm_call_ctors --export fflush --export __errno_location --export __emscripten_pthread_data_constructor --export __pthread_tsd_run_dtors --export _emscripten_call_on_thread --export _emscripten_do_dispatch_to_thread --export _emscripten_main_thread_futex --export _emscripten_thread_init --export emscripten_current_thread_process_queued_calls --export _emscripten_allow_main_runtime_queued_calls --export emscripten_futex_wake --export emscripten_get_global_libc --export emscripten_main_browser_thread_id --export emscripten_main_thread_process_queued_calls --export emscripten_register_main_browser_thread_id --export emscripten_run_in_main_runtime_thread_js --export emscripten_stack_set_limits --export emscripten_sync_run_in_main_thread_2 --export emscripten_sync_run_in_main_thread_4 --export emscripten_tls_init --export pthread_self --export memalign --export malloc --export free --export _get_tzname --export _get_daylight --export _get_timezone --export memset --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024' failed (returned 1)
If I comment out the line that constructs the ICU string, it builds and runs. If I remove the -pthread
option, it builds but does not run successfully.
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 2.0.24 (416685f)
clang version 13.0.0 (https://github.com/llvm/llvm-project 91f147792e815d401ae408989992f3c1530cc18a)
Target: wasm32-unknown-emscripten
Thread model: posix