emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.79k stars 3.31k forks source link

Unexpected error in system/lib/libcxx/include/__utility/no_destroy.h #22259

Open SaraBaradaran opened 3 months ago

SaraBaradaran commented 3 months ago

I faced the following error when compiling cpputest (https://github.com/cpputest/cpputest) using Emscripten. It seems there is a bug in LLVM's libc++ header system/lib/libcxx/include/__utility/no_destroy.h.

version: 3.1.63 (latest)

[ 95%] Building CXX object examples/AllTests/CMakeFiles/ExampleTests.dir/EventDispatcherTest.cpp.o
In file included from /home/sara/test2/cpputest/examples/AllTests/EventDispatcherTest.cpp:30:
In file included from /home/sara/test2/cpputest/examples/ApplicationLib/./EventDispatcher.h:31:
In file included from /home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/list:1757:
In file included from /home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/functional:526:
In file included from /home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__functional/boyer_moore_searcher.h:27:
In file included from /home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/vector:325:
In file included from /home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_bool.h:20:
In file included from /home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:35:
In file included from /home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/locale:202:
In file included from /home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__locale:18:
/home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__utility/no_destroy.h:47:10: error: type name requires a specifier or qualifier
   47 |     new (&__obj_) _Tp(std::forward<_Args>(__args)...);
      |          ^
/home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__utility/no_destroy.h:47:11: error: expected ')'
   47 |     new (&__obj_) _Tp(std::forward<_Args>(__args)...);
      |           ^
/home/sara/test2/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__utility/no_destroy.h:47:9: note: to match this '('
   47 |     new (&__obj_) _Tp(std::forward<_Args>(__args)...);
      |         ^

You can reproduce the error using the following commands:

$ git clone https://github.com/cpputest/cpputest
$ cd cpputest/build
$ emcmake cmake ..
$ emmake cmake --build .
sbc100 commented 3 months ago

If this is a bug in libc++ then perhaps its best to file it upstream? Are you able to reproduce on your desktop system, linking against libc++? For example, using clang++ -stdlib=libc++?