-
Notifications
You must be signed in to change notification settings - Fork 143
WIP: support std module #522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.