WIP: support std module#522
Conversation
|
hi @comius @trybka @fmeum @ChuanqiXu9 I would like to invite you to review and discuss a prototype implementation for C++23 standard library module ( OverviewThis implementation enables Bazel projects to use C++23's standard library modules ( Implementation DetailsThe implementation consists of modifications to 1. Toolchain Template Changes (
|
| write_builtin_include_directory_paths(repository_ctx, cc, builtin_include_directories) | ||
| if is_clang: | ||
| libcxx_v1_dir = _get_share_libcxx_v1_dir(repository_ctx, cc) | ||
| files = repository_ctx.execute(["ls", libcxx_v1_dir]).stdout.strip().split("\n") |
There was a problem hiding this comment.
You can use repository_ctx.path(...).readdir() instead to list files within Starlark.
| ), | ||
| "%{std_module}": """ | ||
| cc_library( | ||
| name = "std_modules", |
There was a problem hiding this comment.
I think that the std module has to be passed into the cc_toolchain in some way so that users can get the module for their current toolchain, not the host toolchain. That's why exposing this target directly wouldn't work well.
If it's common for folks to import std, could we add this dependency automatically to all module_interfaces? Or should this be toggleable on the toolchain? Requiring an explicit dep on std could become tedious.
|
Build system should find the std module by -print-library-module-manifest-path or -print-file-name=libc++.modules.json or -print-file-name=libstdc++.modules.json . The model of cmake is, (and the model of SG15 in my mind), if the build system find any user's file import std (or std.compat), the build system will create the std module target implicitly (from the above mechanism) if the std module target haven't been created. Then the build system will append it to the dependent list of the target of that file. A tricky part is, given there are two targets, both of them import std, but one target is compiled with So it might be fine enough to provide a doc for users to tell them how to wrap a std module target by themselves. And bazel can provide a special value (maybe or This is not super wonderful. But it saves the work for build system guys and leave the flexity and complexity to users. |
No description provided.