Skip to content

C++ 17 parallel algorithms #18476

Closed
Closed
@afraidofdark

Description

@afraidofdark

I have checked from the library support "C++17 library features / Parallel algorithms and execution policies" are not implemented for Clang libc++ but GCC libstdc++ has them. However addign "-stdlib=libstdc++" flag to the compiler yields more errors. This is what I want to ask, can we switch to gcc libstdc++ with emscripten ? Is there a work around that enables me to use parrallel algorithms ?

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.29 (4307484)
clang version 16.0.0 (https://github.com/llvm/llvm-project 947d529e4194e0567cfbbea99127066f76c87269)
Target: wasm32-unknown-emscripten
Thread model: posix

Failing command line in full:
C:\Users\afrai\Documents\ToolKit\Web>emcmake cmake -DTK_CXX_EXTRA:STRING="-O3 -g" -S .. -G Ninja && ninja & pause
configure: cmake "-DTK_CXX_EXTRA:STRING=-O3 -g" -S .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=C:\Users\afrai\OneDrive\Desktop\emscripten\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=C:/Users/afrai/OneDrive/Desktop/emscripten/emsdk/node/14.18.2_64bit/bin/node.exe;--experimental-wasm-bulk-memory;--experimental-wasm-threads
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/afrai/Documents/ToolKit/Web
[1/2] Building CXX object ToolKit/CMakeFiles/ToolKit.dir/MathUtil.cpp.o
FAILED: ToolKit/CMakeFiles/ToolKit.dir/MathUtil.cpp.o
C:\Users\afrai\OneDrive\Desktop\emscripten\emsdk\upstream\emscripten\em++.bat -IC:/Users/afrai/Documents/ToolKit/ToolKit -IC:/Users/afrai/Documents/ToolKit/Dependency -IC:/Users/afrai/Documents/ToolKit/Dependency/OpenAL/include -IC:/Users/afrai/Documents/ToolKit/Dependency/RapidXml -IC:/Users/afrai/Documents/ToolKit/Dependency/stb -IC:/Users/afrai/Documents/ToolKit/Dependency/zlib-1.2.12/dist/include -std=c++17 -O3 -g -include stdafx.h -MD -MT ToolKit/CMakeFiles/ToolKit.dir/MathUtil.cpp.o -MF ToolKit\CMakeFiles\ToolKit.dir\MathUtil.cpp.o.d -o ToolKit/CMakeFiles/ToolKit.dir/MathUtil.cpp.o -c C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:426:16: error: no member named 'execution' in namespace 'std'; did you mean 'exception'?
std::execution::par_unseq,
~~~~~^~~~~~~~~
exception
C:\Users\afrai\OneDrive\Desktop\emscripten\emsdk\upstream\emscripten\cache\sysroot/include/c++/v1\exception:100:29: note: 'exception' declared here
class _LIBCPP_EXCEPTION_ABI exception
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:426:27: error: no member named 'par_unseq' in 'std::exception'
std::execution::par_unseq,
~~~~~~~~~~~~~~~~^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:438:45: error: variable 'vertexIndx' cannot be implicitly captured in a lambda with no capture-default specified
for (uint32_t vertexIndx = 0; vertexIndx < 3; vertexIndx++)
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:438:29: note: 'vertexIndx' declared here
for (uint32_t vertexIndx = 0; vertexIndx < 3; vertexIndx++)
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'vertexIndx' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, vertexIndx
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'vertexIndx' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &vertexIndx
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:438:61: error: variable 'vertexIndx' cannot be implicitly captured in a lambda with no capture-default specified
for (uint32_t vertexIndx = 0; vertexIndx < 3; vertexIndx++)
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:438:29: note: 'vertexIndx' declared here
for (uint32_t vertexIndx = 0; vertexIndx < 3; vertexIndx++)
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'vertexIndx' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, vertexIndx
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'vertexIndx' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &vertexIndx
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:440:17: error: variable 'positions' cannot be implicitly captured in a lambda with no capture-default specified
positions[vertexIndx] =
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:432:18: note: 'positions' declared here
Vec3 positions[3] = {face.vertices[0]->pos,
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'positions' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, positions
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'positions' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &positions
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:440:27: error: variable 'vertexIndx' cannot be implicitly captured in a lambda with no capture-default specified
positions[vertexIndx] =
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:438:29: note: 'vertexIndx' declared here
for (uint32_t vertexIndx = 0; vertexIndx < 3; vertexIndx++)
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'vertexIndx' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, vertexIndx
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'vertexIndx' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &vertexIndx
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:441:61: error: variable 'vertexIndx' cannot be implicitly captured in a lambda with no capture-default specified
CPUSkinning((SkinVertex*) face.vertices[vertexIndx],
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:438:29: note: 'vertexIndx' declared here
for (uint32_t vertexIndx = 0; vertexIndx < 3; vertexIndx++)
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'vertexIndx' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, vertexIndx
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'vertexIndx' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &vertexIndx
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:442:33: error: variable 'skinMesh' cannot be implicitly captured in a lambda with no capture-default specified
skinMesh->m_skeleton.get(),
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:437:25: note: 'skinMesh' declared here
SkinMesh* skinMesh = (SkinMesh*) mesh;
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'skinMesh' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, skinMesh
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'skinMesh' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &skinMesh
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:448:41: error: variable 'positions' cannot be implicitly captured in a lambda with no capture-default specified
positions[0],
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:432:18: note: 'positions' declared here
Vec3 positions[3] = {face.vertices[0]->pos,
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'positions' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, positions
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'positions' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &positions
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:449:41: error: variable 'positions' cannot be implicitly captured in a lambda with no capture-default specified
positions[1],
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:432:18: note: 'positions' declared here
Vec3 positions[3] = {face.vertices[0]->pos,
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'positions' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, positions
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'positions' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &positions
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:450:41: error: variable 'positions' cannot be implicitly captured in a lambda with no capture-default specified
positions[2],
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:432:18: note: 'positions' declared here
Vec3 positions[3] = {face.vertices[0]->pos,
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'positions' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, positions
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'positions' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &positions
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:451:41: error: variable 'dist' cannot be implicitly captured in a lambda with no capture-default specified
dist))
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:446:19: note: 'dist' declared here
float dist = FLT_MAX;
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'dist' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, dist
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'dist' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &dist
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:454:19: error: variable 'dist' cannot be implicitly captured in a lambda with no capture-default specified
if (dist < closestPickedDistance && t >= 0.0f)
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:446:19: note: 'dist' declared here
float dist = FLT_MAX;
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'dist' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, dist
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'dist' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &dist
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:456:41: error: variable 'dist' cannot be implicitly captured in a lambda with no capture-default specified
t = dist;
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:446:19: note: 'dist' declared here
float dist = FLT_MAX;
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'dist' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, dist
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'dist' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &dist
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:457:41: error: variable 'dist' cannot be implicitly captured in a lambda with no capture-default specified
closestPickedDistance = dist;
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:446:19: note: 'dist' declared here
float dist = FLT_MAX;
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:11: note: lambda expression begins here
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'dist' by value
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, dist
C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp:429:78: note: capture 'dist' by reference
[&updateHit, &t, &closestPickedDistance, &ray, &hit, skelComp, mesh](
^
, &dist
15 errors generated.
em++: error: 'C:/Users/afrai/OneDrive/Desktop/emscripten/emsdk/upstream/bin\clang++.exe -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -IC:\Users\afrai\OneDrive\Desktop\emscripten\emsdk\upstream\emscripten\cache\sysroot\include\SDL --sysroot=C:\Users\afrai\OneDrive\Desktop\emscripten\emsdk\upstream\emscripten\cache\sysroot -Xclang -iwithsysroot/include\compat -IC:/Users/afrai/Documents/ToolKit/ToolKit -IC:/Users/afrai/Documents/ToolKit/Dependency -IC:/Users/afrai/Documents/ToolKit/Dependency/OpenAL/include -IC:/Users/afrai/Documents/ToolKit/Dependency/RapidXml -IC:/Users/afrai/Documents/ToolKit/Dependency/stb -IC:/Users/afrai/Documents/ToolKit/Dependency/zlib-1.2.12/dist/include -std=c++17 -O3 -g3 -include stdafx.h -MD -MT ToolKit/CMakeFiles/ToolKit.dir/MathUtil.cpp.o -MF ToolKit\CMakeFiles\ToolKit.dir\MathUtil.cpp.o.d -c C:/Users/afrai/Documents/ToolKit/ToolKit/MathUtil.cpp -o ToolKit/CMakeFiles/ToolKit.dir/MathUtil.cpp.o' failed (returned 1)
ninja: build stopped: subcommand failed.

Full link command and output with -v appended:
Even for runtime issues it helps a lot if you can include the full link command.
Adding -v to the link command will show all of the sub-commands run which
can help us diagnose your issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions