-
-
Notifications
You must be signed in to change notification settings - Fork 185
Description
Environment
toml++ version and/or commit hash: v2.2.0
Compiler: em++ 1.39.8
C++ standard mode (e.g. 17, 20, 'latest'): Tried with c++17 and -std=c++2a
Target arch (e.g. x64): WebAssembly
Tried with:
TOML_UNRELEASED_FEATURES 1in a test case which is one of the examples copied verbatim.TOML_EXCEPTIONS 0in the application in which I actually wanted to use TOML.
Relevant compilation flags: None that I know of
Describe the bug
I get a linking error when compiling an application to WebAssembly:
error: undefined symbol: _ZNSt3__26__itoa8__u32toaEjPc
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
error: undefined symbol: _ZNSt3__26__itoa8__u64toaEyPc
The symbol, according to c++filt is std::__2::__itoa::__u64toa(unsigned long long, char*).
Steps to reproduce (or a small repro code sample)
I've followed the instructions here: https://emscripten.org/docs/getting_started/downloads.html
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
This will get the WebAssembly compiler downloaded and in the PATH variable for easy access. I'm not a fan of this kind of installation methods, but this seems clean and safe enough. It should not leave files scattered outside the place where you cloned the repository.
Then I made a test case using the simple_parser.cpp file from tomlplusplus' examples directory, and copied the utf8_console.h file as well. I made a build using qmake, because that's what I'm familiar with (and what I'm using for the actual application where I wanted tomlplusplus), but the compiler invocation is simple enough to copy paste and reproduce the issue.
em++ -c -pipe -O2 -std=gnu++2a -s ALLOW_MEMORY_GROWTH=1 -Wall -Wextra -I. -o main.o simple_parser.cpp
em++ -s WASM=1 -s FULL_ES2=1 -s FULL_ES3=1 -s USE_WEBGL2=1 -s EXIT_RUNTIME=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=["UTF16ToString","stringToUTF16"] --bind -s FETCH=1 -O2 -s ALLOW_MEMORY_GROWTH=1 -o toml-wasm-test-case.js main.o
Additional information
First things first: thanks for this library!
I know that WebAssembly is fairly new. I personally don't have much experience with it. But from what I see, there is no reason why most library code like TOML++ should not work out of the box on WebAssembly. The compiler (if I understood correctly) is a sort of LLVM/Clang branch, so if it works in one, it should work on the other. For my application I needed to do minimal changes to account for the use of threads or files.
Since the missing symbol is in the standard library, it might be an issue in emsdk itself, so feel free to point me there if you are confident that this is the problem. But I would be very grateful if you could point me where in TOML++ this symbol might be used directly or indirectly, as I'm quite lost in the code. :) I suppose it comes from some stream that tries to convert an unsigned long long to text. But I tried making a simpler test case fail, and I can't (it links well in that case).
Thank you again!