Skip to content

Conversation

@PikachuHyA
Copy link
Contributor

@PikachuHyA PikachuHyA commented May 27, 2024

I split the XXL PR #19940 into several small patches.
This is the fifth patch of Support C++20 Modules, I construct the build graph of compile with C++20 Modules.

Firstly, all files are scanned to generate .ddi files. All the .ddi files are then aggregated to create a .CXXModules.json file. Subsequently, based on the .CXXModules.json file and their respective .ddi files, .modmap files are generated. Finally, the compilation begins. The two-phase compilation is employed here.

              ┌────────┐                  ┌────────┐                  ┌────────┐
              │foo.cppm│                  │bar.cppm│                  │main.cc │
              └────┬───┘                  └────┬───┘                  └────┬───┘
c++20-deps-scanning│                           │                           │
                   │                           │                           │
              ┌────▼───┐                  ┌────▼───┐                  ┌────▼───┐
              │foo.ddi │                  │bar.ddi │                  │main.ddi│
              └────┬───┘                  └────┬───┘                  └────┬───┘
                   │                           │                           │
                   └───────────────────────────┼───────────────────────────┘
                                               │Cpp20ModulesInfoAction
                                      ┌────────▼───────────┐
                                      │demo.CXXModules.json│
                                      └────────────────────┘
                                              ┌────────────────────┐
                                              │demo.CXXModules.json│
                                              └─────┬──────────────┘
                                                    │
                                                    │
                                  ┌───────┐         │          ┌───────────┐
                               ┌─►│foo.ddi├─────────┤          │ bar.cppm  │
                               │  └───────┘         │          └─────┬─────┘
                               │                    │                │
                               │                    │                │
                               │                    │                │
                               │                    │                │
┌────────┐ c++20-deps-scanning │  ┌───────┐   ┌─────▼────┐      ┌────▼─────┐
│foo.cppm├─────────────────────┴─►│foo.d  │   │foo.modmap│      │ bar.pcm  │
└───┬────┘                        └──┬────┘   └────┬─────┘      └────┬─────┘
    │c++20-module-compile            │             │                 │
┌───▼───┐                            │             │                 │
│foo.pcm├────────────────────────────┴─────────────┼─────────────────┘
└───────┘                                          │c++20-module-codegen
                                              ┌────▼─────┐
                                              │ foo.o    │
                                              └──────────┘

@PikachuHyA PikachuHyA requested a review from lberki as a code owner May 27, 2024 10:09
@github-actions github-actions bot added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels May 27, 2024
@PikachuHyA
Copy link
Contributor Author

as #19940 (comment) mentioned, I will remove remove the reuse of the .d file.

@PikachuHyA PikachuHyA changed the title support C++20 Modules, construct build graph [WIP] [5/5] support C++20 Modules, construct build graph May 27, 2024
@sgowroji sgowroji added awaiting-user-response Awaiting a response from the author and removed awaiting-review PR is awaiting review from an assigned reviewer labels May 28, 2024
@PikachuHyA PikachuHyA force-pushed the cxx20-modules-support-patch-5 branch from 8974044 to 29eb2f2 Compare June 14, 2024 10:03
@PikachuHyA PikachuHyA requested review from a team and oquenchil as code owners June 14, 2024 10:03
@PikachuHyA PikachuHyA requested review from aranguyen and removed request for a team June 14, 2024 10:03
@PikachuHyA PikachuHyA changed the title [WIP] [5/5] support C++20 Modules, construct build graph [WIP] [5/5] support C++20 Modules, support two phase compilation Jun 14, 2024
@oquenchil oquenchil removed their request for review June 17, 2024 19:18
@satyanandak
Copy link

@PikachuHyA Could you please take a look at the failing checks?

@PikachuHyA
Copy link
Contributor Author

@PikachuHyA Could you please take a look at the failing checks?

This patch is dependent on the changes in #22553. I will update this patch once that pull request has been merged.

@PikachuHyA PikachuHyA closed this Nov 12, 2025
@PikachuHyA PikachuHyA force-pushed the cxx20-modules-support-patch-5 branch from 29eb2f2 to b1630ee Compare November 12, 2025 07:14
@PikachuHyA PikachuHyA reopened this Nov 12, 2025
@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Nov 12, 2025
@PikachuHyA PikachuHyA changed the title [WIP] [5/5] support C++20 Modules, support two phase compilation [5/5] support C++20 Modules, support two phase compilation Nov 12, 2025
@PikachuHyA
Copy link
Contributor Author

@comius @trybka @fmeum I updated this PR (two phase compilation support). Could you take a look?

Copy link
Collaborator

@fmeum fmeum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a disabled test that passes once the Starlark changes have been mirrored to rules_cc and the version used by Bazel has been updated?

+ " support in the future. Consider those risks when using it.")
public boolean experimentalCppModules;
@Option(
name = "experimental_cpp_modules_with_two_phase_compilation",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a feature instead of an option? That would make it more flexible and also require less non-Starlark code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update it to use the cpp_modules_with_two_phase_compilation feature.

@PikachuHyA PikachuHyA force-pushed the cxx20-modules-support-patch-5 branch from fe4af30 to b438279 Compare November 24, 2025 10:03
ihpos added a commit to ihpos/vulkan-thing that referenced this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer awaiting-user-response Awaiting a response from the author team-Rules-CPP Issues for C++ rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants