You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Boost.Predef should provide a way to detect WASM #131
wasm32 and wasm64 are architectures. The correct macros should be BOOST_ARCH_WASM32 and BOOST_ARCH_WASM64.
Emscripten is analogous to mingw: an emulation layer that emulates POSIX on a different platform (a web browser and Windows respectively), plus a compiler that targets that emulation layer. Since mingw is treated as a platform, so should Emscripten be. So the correct macro would be BOOST_PLAT_EMSCRIPTEN. Emscripten is based on clang, so BOOST_COMP_CLANG should also be detected.
Architecture and platform are orthogonal here: non-Emscripten clang can target the wasm architecture, and Emscripten can (or could) output Javascript instead of wasm.
If we're running in a web browser is the third not-quite-orthogonal concern, analogous to the OS. Emscripten can target node.js and standalone wasm runtimes in addition to targeting web browsers. However, this may not be possible to detect at compile time, because the same wasm files can run both in web browsers and standalone.
Reacted by René Ferdinand Rivera Morell and sleeptightAnsiC
@rainerdeyke although.. wondering if there's a difference between WASM32 and WASM64 that isn't covered by WASM, BOOST_ARCH_WORD_BITS_32, and BOOST_ARCH_WORD_BITS_64?
Activity
jcelerier commentedon Aug 10, 2023
Also it's already detected in some way by boost.config: https://www.boost.org/doc/libs/1_82_0/boost/config/detail/select_platform_config.hpp
sleeptightAnsiC commentedon Feb 3, 2025
sleeptightAnsiC commentedon Feb 3, 2025
rainerdeyke commentedon Apr 23, 2026
Can somebody make an executive decision here?
My opinion, FWIW:
wasm32 and wasm64 are architectures. The correct macros should be BOOST_ARCH_WASM32 and BOOST_ARCH_WASM64.
Emscripten is analogous to mingw: an emulation layer that emulates POSIX on a different platform (a web browser and Windows respectively), plus a compiler that targets that emulation layer. Since mingw is treated as a platform, so should Emscripten be. So the correct macro would be BOOST_PLAT_EMSCRIPTEN. Emscripten is based on clang, so BOOST_COMP_CLANG should also be detected.
Architecture and platform are orthogonal here: non-Emscripten clang can target the wasm architecture, and Emscripten can (or could) output Javascript instead of wasm.
If we're running in a web browser is the third not-quite-orthogonal concern, analogous to the OS. Emscripten can target node.js and standalone wasm runtimes in addition to targeting web browsers. However, this may not be possible to detect at compile time, because the same wasm files can run both in web browsers and standalone.
grafikrobot commentedon Apr 23, 2026
@rainerdeyke I like that suggestion.
grafikrobot commentedon Apr 23, 2026
@rainerdeyke although.. wondering if there's a difference between WASM32 and WASM64 that isn't covered by WASM, BOOST_ARCH_WORD_BITS_32, and BOOST_ARCH_WORD_BITS_64?
rainerdeyke commentedon Apr 24, 2026
I'm mostly going by the precedent of having both BOOST_ARCH_X86_32 and BOOST_ARCH_X86_64. That said, there doesn't seem to be a clear policy here.
So this could go either way.