Skip to content
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

[WIP] [5/5] support C++20 Modules, support two phase compilation #22555

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

PikachuHyA
Copy link
Contributor

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    │
                                              └──────────┘

Note: To make the code review convenient, I keep only one commit. Due to patch dependencies, it may build and test failed.
I will update the patch after all the prerequisite patches have been merged. At that time, I will then troubleshoot the build and test failures.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants