Add support for C++23 std modules#27065
Conversation
sbc100
left a comment
There was a problem hiding this comment.
Nice!
To be clear are these files taken from the emscripten-libs-21 branch?
We normally use the system/lib/update_libcxx.py script to update these files. Perhaps you could try using that (maybe it needs modifying to include the modules directory somehow?)
Also made copy_tree conditionally exclude files because we need the CMakeLists.txt for the modules
sbc100
left a comment
There was a problem hiding this comment.
lgtm!
But maybe we could add a test for this ?
Might need to get Clang-CXX-CXXImportStd working if the test environment doesn't support cmake 4.2 for CMAKE_CXX_STDLIB_MODULES_JSON . In this case we'd need to patch emcc.py to allow using a relative search path for -print-file-name with CMAKE_CXX_COMPILER_ID_ARG1 |
This is explicitly used by CMake's Clang-CXX-CXXImportStd.cmake
If we can get cmake 4.2 installed on at least one of the CI machines would that address the issue? I would be fine landing this change standalone and following up with a test too. |
…o CMAKE_INSTALL_PREFIX
This reverts commit 8b5827f.
needed for out of tree builds i.e. tests
Also adjust the toolchain file to use those Q: Shouldn't these rather be installed when building libc++ ?
This creates 2 separate test: - test_cxx_import_std23 - test_cxx_import_std26
sbc100
left a comment
There was a problem hiding this comment.
lgtm! (with one last nit)
Thanks for working on this
|
Pleasure. Hope I can get clangd for this :D . Differing versions still have trouble reading the .pcm files. |
|
I think you need to rebase or merge to fix the chrome tests. |
| endif() | ||
| endif() | ||
|
|
||
| set_property(SOURCE |
There was a problem hiding this comment.
Does it make sense to keep this outside of the above condition?
There was a problem hiding this comment.
Because cmake caches CMAKE_CXX_STDLIB_MODULES_JSON the above condition would not run on subsequent configuration runs and remove the flags
| if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.3.0) | ||
| set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD 451f2fe2-a8a2-47c3-bc32-94786d8fc91b) | ||
| else() | ||
| set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD d0edc3af-4c50-42ea-a356-e2862fe7a444) |
There was a problem hiding this comment.
Are normal end users executed to write lines like this?
There was a problem hiding this comment.
For now yes. This is still an Opt-in feature and users might also not have the backported values and would look that up for their installation.
Ref: https://cmake.org/cmake/help/latest/manual/cmake-cxxmodules.7.html#import-std-support
Note
This support is provided only when experimental support for import std has been enabled by the CMAKE_EXPERIMENTAL_CXX_IMPORT_STD gate.
Removes the dependency on python3-packaging in test_other.py which was introduced in #27065
|
What version of LLVM was this taken from? We normally sync library updates in specific LLVM version and it's confusing to mix different versions within the same library. The last update was 21.1.8 (#26058). |
|
I'm pretty sure it was taking from the @Diyou maybe you could confirm and also update the PR description to mention this branch name. |
|
Yes I changed it to the These should stay in sync with the changes in |
This adds the
libcxx/modulesfolder from https://github.com/emscripten-core/llvm-project/tree/emscripten-libs-21 with its generated files insystem/lib/libcxx/modules/prebuiltsysrootviaupdate_libcxx.py+install_system_headerscmake/Modules/Emscripten.cmakefor CMake > 3.30Resolves #21143
Additional Note:
To use the
stdorstd.compatmodules without CMake one would need to precompile the module interface like:And then compile the source files with: