[feature] Emscripten os.threads setting
Emscripten binaries are incompatible if they were build with some flags that don't match. For instance -s USE_PTHREADS=1 is incompatible with libraries without it. Mismatching libraries will fail with the following:
wasm-ld: error: --shared-memory is disallowed by spdlog.cpp.o because it was not compiled with 'atomics' or 'bulk-memory' features.
I'm considering implementing os.threads=True that should correctly set the flags. To implement this, we would need to add a new entry in settings.yml and append -s USE_PTHREADS=1/0 depending on the value of os.threads.
I'm not 100% sure how to proceed with the handling of the flags. I have a working hack that allows setting it for CMake by appending the flag to CONAN_C/CXX_FLAGS in cmake_flags.py, by checking the platform and threads setting. This obviously will only work for CMake, but a similar patch is required for autoconf and other supported toolchains.
I'm unsure what the policy is on adding C/CXX flags, since it's very rarely done in Conan, if there's another better path to take for this, please let me know. Any help and guidelines on how to proceed with implementing this would be greatly appreciated.
- [x] I've read the CONTRIBUTING guide.
Hello, did this end up being implemented?
I don't think so, but Conan also got new conf items like tools.build:cxxflags = [ ] that allows injecting flags to all build system integrations, including CMake, Autotools, etc, so maybe this can be done by flags injection without custom settings.
Greetings,
I am excited to announce that we have introduced native support for the emcc compiler. These changes are currently available in the develop2 branch and are expected to be released in version 2.18 later this week. If you would like to try it out, you can easily do so by cloning the Conan repository and using the development environment.
The modeled emcc compiler configuration will be as follows as soon as #18520 gets merged:
emcc:
# From https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md
# There is no ABI compatibility guarantee between versions
version: [ANY]
libcxx: [null, libstdc++, libstdc++11, libc++]
threads: [null, posix, wasm_workers]
cppstd: [null, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23, 26, gnu26]
cstd: [null, 99, gnu99, 11, gnu11, 17, gnu17, 23, gnu23]
Thank you very much for your feature requests, as we didn't consider this thread subsetting until this issue was addressed.
For more details about these new features, please refer to the pull request: https://github.com/conan-io/conan/pull/18432.
Additionally, we will soon launch a new repository called conan-toolchains (https://github.com/conan-io/conan-toolchains), where we will be adding and transitioning existing toolchains from CCI. One of these toolchains is emsdk (see https://github.com/conan-io/conan-toolchains/pull/4), which is a refactor of the existing CCI recipe that we plan to deprecate.
We have also implemented proper support for the older asmjs architecture and tested all wasm architectures across different Conan generators, fixing some old bugs.
Please note that in the new conan-toolchains repository, we have added a conan_config folder that can be easily installed using the conan config install command. In this folder, we provide pre-built profiles for the respective toolchains.
Currently, we have the following profiles available:
-
emsdk/asmjs -
emsdk/wasm32 -
emsdk/wasm64
These profiles can be used alongside emsdk/native, which allows users to utilize their native emsdk installation instead of the Conan-packaged version.
I hope this meets your needs. Thank you!
This has been implmented in #18520, adding threads: [null, posix, wasm_workers]. It will be in next Conan 2.18 release, thanks!