Skip to content

Support C++20 modules #4005

Closed
Closed

Description

@abergmeier

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?

Activity

  1. hlopko commented on Nov 3, 2017

    @hlopko
    Member

    Hi Andreas,
    everything regarding modules (only for clang) is open sourced already. The only missing piece is a CROSSTOOL that makes use of them and provides all necessary features. But I think it would be quite a challenge to write such CROSSTOOL without understanding the implementation. If I don't find a good movie on my flight to bazel conference I might take a look and hack something together. No promises though, since this would be a free time exercise, not something that is a priority for bazel right now.

  2. added
    P3We're not considering working on this, but happy to review a PR. (No assignee)
    and removed
    P2We'll consider working on this in future. (Assignee optional)
    on Nov 3, 2017
  3. abergmeier commented on Nov 3, 2017

    @abergmeier
    ContributorAuthor

    Interesting.
    @mhlopko Can you perhaps elaborate a bit, what parts of CROSSTOOL would interact with modules? Personally I thought it would be more in the realm of cc-providers and additional actions for module validity checks.

  4. hlopko commented on Nov 3, 2017

    @hlopko
    Member

    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.

  5. hlopko commented on Nov 3, 2017

    @hlopko
    Member

    So in other words, it's all there, just not very well documented.

  6. abergmeier commented on Nov 3, 2017

    @abergmeier
    ContributorAuthor

    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.

  7. hlopko commented on Nov 3, 2017

    @hlopko
    Member

    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.

  8. abergmeier commented on Nov 8, 2017

    @abergmeier
    ContributorAuthor

    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 libc_top (inputsForLibc) work?

    Especially since I cannot seem to be able to glob system files.

  9. 60 remaining items

  10. kelteseth commented on Apr 28, 2024

    @kelteseth

    This issue is track it on https://arewemodulesyet.org/tools/

  11. added a commit that references this issue on May 28, 2024
  12. self-assigned this
    on Aug 30, 2025
  13. PikachuHyA commented on Nov 4, 2025

    @PikachuHyA
    Contributor

    Dear all, the support for C++20 Modules is here. PR: #19940 design doc: bazelbuild/proposals#354 discussion: #19939 a demo built with C++20 Modules (about 10 kloc): https://github.com/PikachuHyA/async_simple extra tests: https://github.com/PikachuHyA/bazel_cxx20_module_test the new bazel is built by GitHub Action, see https://github.com/PikachuHyA/bazel/actions/runs/6638058320 you can download the prebuilt version and play with your code. Feedback is very welcome. please note, only Clang is supported now. and Clang 17 or higher is required.

    FYI: after #22553 was merged, I created a repo demonstrating C++20 Modules with Bazel: https://github.com/PikachuHyA/bazel_cxx20_modules_demo/.

    It currently contains a simple hello‑world example and a demo showing how to use a third‑party library (e.g., fmt) with C++20 Modules.

    Feel free to open issues or submit PRs to add more examples.

  14. PikachuHyA commented on Jan 20, 2026

    @PikachuHyA
    Contributor

    hi @comius , could you please reopen this issue?

    The current implementation for C++20 Modules support has significant limitations. We previously had a solution, but the patch was reverted #28190 due to performance concerns. We’re still actively working on improving C++20 Modules support and would like to keep this issue open to track progress.

  15. PikachuHyA commented on Sep 28, 2026

    @PikachuHyA
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2We'll consider working on this in future. (Assignee optional)team-Rules-CPPIssues for C++ rulestype: feature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions