emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.96k stars 676 forks source link

c++17 is not supported by em++ in docker #1289

Closed vpenyazkov closed 10 months ago

vpenyazkov commented 10 months ago

I'm trying to compile following code example:

#include<map>

int main() {
    const std::map<std::string, std::any> my_map = {};
    return 0;
}

Even though clang 16+ has c++ 17 enabled by default, I'm not able to compile the provided example, the following error occurs:

$ em++ test.cpp
test.cpp:4:38: error: no member named 'any' in namespace 'std'
    4 |     const std::map<std::string, std::any> my_map = {};
      |                                 ~~~~~^
1 error generated.
em++: error: '/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN --sysroot=/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat test.cpp -c -o /tmp/emscripten_temp_zok0cbtc/test_0.o' failed (returned 1)

Adding c++17 explicitly does not help much:

$ em++ -stdlib=libc++ -std=c++17 test.cpp
test.cpp:4:38: error: no member named 'any' in namespace 'std'
    4 |     const std::map<std::string, std::any> my_map = {};
      |                                 ~~~~~^
1 error generated.
em++: error: '/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN --sysroot=/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -stdlib=libc++ -std=c++17 test.cpp -c -o /tmp/emscripten_temp_pn397c5c/test_0.o' failed (returned 1)

How can I enable c++17 support?

Used versions Docker image: `emscripten/emsdk:3.1.47` em++ version: ``` $ em++ -v emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.47 (431685f05c67f0424c11473cc16798b9587bb536) clang version 18.0.0 (https://github.com/llvm/llvm-project 21030b9ab4487d845e29792063f5666d8c4b8e09) Target: wasm32-unknown-emscripten Thread model: posix InstalledDir: /emsdk/upstream/bin ```
vpenyazkov commented 10 months ago

my bad, I lost #include <any>.