-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Support C++20 modules #4005
Comments
Hi Andreas, |
Interesting. |
Yeah you are right, the implementation does deal with providers and actions, but all that logic is already in bazel and ready to be used. What is missing is a bunch of features (and maybe action_configs, I'm not sure) in the CROSSTOOL to pass the right flags for the right actions. Names of the features are hardcoded in bazel, so they need to match. |
So in other words, it's all there, just not very well documented. |
Like all else about CC toolchains you mean ;) Thanks. I am trying to get a custom hermetic Clang toolchain running anyways. Perhaps will then try this out a bit. |
Exactly :) I hope I'll see you next week on the crosstool breakout session during bazel conference? :) Btw, just wrote this yesterday, I really hope I'm not one day late: https://github.com/bazelbuild/bazel/wiki/Yet-Another-CROSSTOOL-Writing-Tutorial Anyway, don't hesitate to ask if you get stuck on the way. I'm also grateful for any input/comments/suggestions. |
Since I do have problems with the include paths for libc (https://stackoverflow.com/questions/47078520/clang-toolchain-fails-for-system-libc-files), how does Especially since I cannot seem to be able to glob system files. |
Now that C++20 Modules are nearing standardization, could we get some updates on the status of properly supporting them within Bazel? I was fortunate to attend CppCon this year and was excited to see that many build systems were making progress on supporting modules. Unfortunately, myself and other Bazel users that I spoke to were concerned that there was no Bazel-specific information on the topic. |
We don't plan to work on C++ modules in 2019. We are discussing working on them in 2020 mostly in the context of objc and swift rules. We'll update this issue once we have more precise plans. |
Thanks @hlopko, I'm sure that much of the C++ Bazel community will very much value support for them. Looking forward to hearing more. |
Any update here? :D |
@hlopko Is there anyone that we could ping regarding the timeline for supporting C++20 modules? |
@oquenchil and @c-mita are authorities there. |
@oquenchil @c-mita Bump on the above? :) |
It might be that this gathers steam at the beginning of next year but I can't promise anything. In any case, it would be clang modules, not C++20 modules. Whoever is interested in clang modules, definitely thumbs up the original issue above and that might help with prioritization. |
Should we create a separate issue for C++20 modules then? I'm only interested in those as I'm using MSVC on Windows. |
Yes, you can create a separate issue for tracking C++20 module support. Be aware though that as it looks right now it will be a long time before we work on it, probably not next year. |
Can you rename this issue to "Support Clang modules"? |
@oquenchil - By "Clang modules", do you mean Clang's non-standard module system that pre-dates C++20 modules? Why target that instead of C++20 modules? Clang supports a lot of the standard module spec already (blog post) -- I expect enough that people could start using it. |
Thanks for the missing features @oquenchil! I will note the following line from the
The string |
Shouldn't all those |
So I took the new module's configuration you posted for a spin, but I am still running into the same problem as I was previously. It's not clear what to do about module maps for libc/libc++. You can merge them into the module_map artifact for the toolchain, but it will never be compiled by bazel. You must compile module maps which contain any non textual headers so I am not sure how to make this work. Is it possible there is some internal Google secret sauce that is missing before anyone else can use this? Maybe related to |
Yeah, there are a couple of things happening in the snippet @oquenchil shared.
I guess the point I'm trying to make is that there is still a lot of work to be done to make Clang modules work in Bazel in general, and the snippet helps a bit, but do not assume that what you need is within a hand's reach. For context, there's a toolchain that Carbon folks use to build Carbon, and it doesn't support Clang modules, even though it is created by the group of engineers who helped to implement the support for Clang modules in Bazel internally. |
We just added highly experimental support for standard C++ modules in rules_ll (not the Clang variant with module maps). Considering how experimental C++ modules are currently in Clang/LLVM, things work quite well so far 😅 Build files look like this: ll_library(
name = "mymodule",
srcs = ["m.cpp"] # Module implementation unit
transitive_interfaces = {"m.cppm": "m"}, # Mapping module interface unit to module name
)
ll_binary(
name = "main",
srcs = ["main.cpp"],
deps = [":mymodule"],
) Docs with examples and on how things work under the hood: |
@aaronmondal - with your rules is there any way for module libraries to depend on regular cc_library's? I see this in the docs:
|
@rnburn We have some logic to reuse already-built cc_libraries from the llvm-project overlay, and at a glance I think putting a Note that |
There seems to be some progress on the Clang side: https://releases.llvm.org/15.0.0/tools/clang/docs/StandardCPlusPlusModules.html Any corresponding changes on Bazel's side? |
@HappyCerberus This is the one we implemented in Currently, BMIs contain absolute paths to their sources at the time of precompilation. This means that sandboxed precompilations are hard to implement and BMIs are currently not reproducible. We have not yet managed to get rid of these sandbox paths, so we work around this by disabling sandboxing for precompilations. This is not ideal and would not be viable in the native rules. We didn't try with So for C++ modules to be viable in native rules, distributions will need to distribute |
C++23 is here... any progress on this? I can't find anything definitive from Google. |
A few issues remain which I could imagine to be fairly hard blockers for
We'll probably need distros to actually ship Clang 17 with the Then again C++23 is basically Rust already. Seems like that's also where all the Bazel engineering power is being redirected to. I wouldn't find it too surprising if the recommendation for the future is to just not write new C++ and use |
That’s a shame. I was hoping to use Bazel for a large project we are migrating. C++20 modules are more important to me than Bazels many advantages, and rules_ll is a non-starter because I need to support macOS and Windows. Maybe next year things will be better. |
Do we have any update on this? |
I'm also quite interested in contributing this featuer. Is there any guidance on this for me to do so? |
I would help with such an effort too. |
See #4005 (comment) |
It sounds like that is basically saying nothing is done and some one wanting good support should start from scratch. |
Note also that post was referring to clang modules and not c++20 modules; this issue got hijacked from clang module support to c++ 20 at some point in the history of this issue. |
Dear all, the support for C++20 Modules is here. |
This issue is track it on https://arewemodulesyet.org/tools/ |
This adds support for record serialization. Work towards bazelbuild#4005
This adds support for record serialization. Work towards bazelbuild#4005
This adds support for record serialization. Work towards bazelbuild#4005
Description of the problem / feature request / question:
Starting to look into C++ Modules. While it will earliest officially arrive in 2020, would be good to have support for that soonish.
Heard there is some Module support inside of Google. Can/Will that be opensourced?
The text was updated successfully, but these errors were encountered: