emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

Discrepancy between CMake toolchain file and emcmake

Open mmarczell-graphisoft opened this issue 3 years ago • 3 comments

Why is the --experimental-wasm-threads argument only set in emcmake and not in Emscripten.cmake?

https://github.com/emscripten-core/emscripten/blob/7df40381247896886e918b5e7086ec7fe6df3e5b/emcmake.py#L41 vs https://github.com/emscripten-core/emscripten/blob/7df40381247896886e918b5e7086ec7fe6df3e5b/cmake/Modules/Platform/Emscripten.cmake#L411

If it was set in the latter, it would make using emcmake and using just the toolchain file more equivalent. One usecase for this is VSCode based development, where the editor's CMake plugin runs the CMake 'configure' step automatically whenever CMake files change. A so called "kit" file (link) can specify a toolchain file, but not a wrapper executable.

mmarczell-graphisoft avatar Feb 24 '22 14:02 mmarczell-graphisoft

The changes was originally made here: https://github.com/emscripten-core/emscripten/pull/15590. I don't see any immediate reason why it should be in Emscripten.cmake instead.

I guess we want to avoid duplication we would need to find a way to set NODE_JS_EXECUTABLE from emcmake.py rather than CMAKE_CROSSCOMPILING_EMULATOR.

Feel free to propose a change

sbc100 avatar Feb 24 '22 16:02 sbc100

For posterity, an easy workaround is to put this in your CMakeLists.txt:

if (DEFINED NODE_JS_EXECUTABLE)
	set(CMAKE_CROSSCOMPILING_EMULATOR "${NODE_JS_EXECUTABLE};--experimental-wasm-threads")
endif()

mmarczell-graphisoft avatar Oct 07 '22 14:10 mmarczell-graphisoft

Now CMAKE_CROSSCOMPILING_EMULATOR seems to be defined in both emcmake.py and the toolchain file? Is this necessary?

david-fong avatar Jul 06 '24 23:07 david-fong