[clang][GSoC 2025] Support simple C++20 modules use from the Clang driver without a build system

Description: Currently there is no easy way to take a collection of source files using C++20 modules and build an executable from them. This makes it hard to create simple tests or tiny programs using C++20 modules without first setting up a build system. This project’s goal is to extend the extremely simple build system in Clang’s driver to handle these cases.

This can be done by using Clang’s existing support for scanning for C++20 modules to discover the dependencies between the source files that have been passed in, and then build them in that order, passing in the right PCM files where needed. This may also be extended to support explicitly building Clang modules discovered via module map files too.

Expected outcomes: Invoking clang similarly to clang -o program -std=c++20 main.cpp A.cppm B.cppm should compile successfully where each translation-unit only imports modules defined in other source files on the command line, or the standard library. This should add no overhead to cases where modules are not used.

Confirmed mentors and their contacts:
Michael Spencer

Required skills: Intermediate knowledge of C++; familiarity with how C++ code is built. Familiarity with C++20 modules is an asset, but not required.

Size of project: Medium

Difficulty rating: Medium

3 Likes

Hi @Bigcheese ,
I’m interested in this project. Could you please suggest a good first issue related to it so that I can become more familiar with the idea and the codebase?

Hey, I think the best way to become familiar with this project is to look at clang-scan-deps in the Clang repo and associated tests. These show how scanning and the command lines generated from that work together to support using modules. clang/test/ClangScanDeps/P1689.cppm is a good starting point.

clang-scan-deps uses clang/include/clang/Tooling/DependencyScanning/*.h internally, which is what the Clang driver would end up using too.

2 Likes

Thanks! I’ll look into that.

I would also suggest to look at Standard C++ Modules — Clang 21.0.0git documentation. It contains information regarding clang-scan-deps and how to build modules from the command line.

2 Likes

Hi @Bigcheese ,
I’m interested in this project and i recently opened a pull request " Remove redundant assertion & fix ClearStatName error" #130667 ,

some updates in clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h

small changes, im trying to understand codebase
Thankyou

Hey, thanks for the interest in the project. I’ll take a look.

Sir, one more thing — since I’m just starting and have become somewhat familiar with the codebase, should I focus more on optimizing the existing code or begin preparing my approach for the project?

I suggest focusing most on preparing a proposal. Feel free to send me a draft and I can help review it. For the proposal it’s best if you understand the existing relevant code at a high level so you can come up with a good plan for how the project should go.

Thank you for your response, sir

I will prepare my first draft within 2-3 days. Currently, I’m exploring LLVM through the Kaleidoscope tutorial to strengthen my understanding of the codebase. I would be grateful if you could suggest any additional resources.

I’m also reviewing the contributor guidelines to avoid formatting errors, as my latest PR was flagged for that despite passing other checks

Thank you

Greetings sir
I have shared draft of my project proposal on your email mentioned in your Github profile or you want me to send it somewhere else?

I got it, I’ll take a look and give feedback today or tomorrow.

1 Like

Hi sir, just a quick reminder to review my proposal and check my PR #132294 ,when you get a chance
Thanks!

Updated to #132638

Hello Sir @Bigcheese,
I have a doubt, Could we connect on IRC or Discord, or should I ask here itself?

Discord is fine. Although it may take me a bit to respond for the next few days.

1 Like

Hi Michael Sir,
I hope you’re doing well. I recently came across the project focused on enhancing Clang’s driver to support building simple C++20 module-based programs without requiring a full build system, and I wanted to express my interest—though I realize I’m reaching out quite late, and I’m sorry for that.
I have a solid understanding of C++ and am currently working on data structures and algorithms in it. While I’m still getting familiar with C++20 modules, the idea of simplifying the module build process directly through Clang really caught my attention. I’d love to be involved in any way I can—whether through contributing, testing, or even just learning from the work being done.
I completely understand if it’s too late to participate officially, but I’d be grateful for any chance to engage with the project or follow its progress.
Thanks for your time, and I appreciate the effort you’re putting into this exciting area of C++ tooling!
Mukul Sharma