Building Simple C++20 Modules Without
a Build System
                             Mentor: Michael Spencer
                               Ayush Pareek
      In progress B.Tech. in Data Science And Artificial Intelligence
          (Indian Institute of Information Technology Dharwad)
GitHub: https://github.com/AyushPareek
Email: ayushpareek1980@gmail.com, 22bds011@iiitdwd.ac.in
Leetcode Profile: https://leetcode.com/AyushPareek
Resume: Resume Link
About me
I am a third-year B.Tech student in Data Science and AI at IIIT Dharwad, India, with
a strong interest in compiler development and low-level programming. I have experience
in C++ and CUDA programming and am currently working and learning LLVM IR for
compiler-related tasks. I previously worked as a Machine Learning intern, where I con-
tributed to reducing RTO rates and developed an end-to-end pipeline. Additionally, I
have been involved in two research projects — one at Vanderbilt University, focusing on a
review paper analyzing student behavior in a learning environment, and another at IIIT
Dharwad, where I designed an architecture for generating MRI videos from synthesized
sound, both of which are nearing completion. I have been following the ”Kaleidoscope”
compiler development tutorial to deepen my understanding of compilation mechanisms
and am also studying the ”LLVM IR Quick Reference” book to strengthen my grasp of
the LLVM infrastructure.
    My GitHub portfolio reflects my passion for low-level programming, with projects
primarily in C++, C, CUDA, and LLVM. For instance, while learning LLVM and famil-
iarizing myself with its syntax, I implemented various commonly used data structures
and built the Kaleidoscope compiler from scratch, including AST construction, parsing,
IR generation, optimization, and JIT compilation. Additionally, I developed a Face Un-
lock mechanism for Windows folders using ACL and OpenCV compiled with CUDA and
cuDNN in C++.
    I have made a total of three pull requests in offical llvm-project Repository. One was
closed, the second (#132638) has passed all test cases and is awaiting merging, and the
third (#132640) is currently failing on both Windows and Linux builds.
                                            1
Synopsis
The goal is to enable C++20 modules support without relying on a build system. C++20
modules offer a new way of organizing code and managing dependencies, which can dras-
tically improve compilation times and reduce complexity. By leveraging Clang’s existing
module dependency scanning mechanism, the project will efficiently detect dependencies
between source files and build them in the correct order while passing the appropriate
PCM and Object files. Additionally, the approach will be optimized to handle complex
dependency graphs. This can also be extended to support Clang modules discovered
via module map files, ensuring a more streamlined and efficient build process for small
programs and tests using C++20 modules
Benefits to Community
This project simplifies C++20 module and dependency management by eliminating the
need for a build system, making compilation and testing easier. It enhances workflow
efficiency, improves the development experience for low-level programmers, and promotes
the adoption of C++20 modules. Additionally, using precompiled modules without build
system overhead boosts performance and maintainability.
Why This Project Matters to Me ?
As I mentioned earlier, I enjoy working with low-level languages, and I was recently ex-
ploring C++20 modules. I became fascinated by the concept of precompiled and direct
usage of modules, which led me to dive deeper into c++20 and LLVM. When I saw this
project announced under GSoC, I realized it perfectly aligns with my interests. By con-
tributing to this project, I can push my limits while experiencing the joy of learning and
working on something I am passionate about.
   My long-term career goal is to become a C++/compiler developer and work with
low-level systems. This is precisely why I chose this project, as it allows me to deepen
my understanding of compiler technologies and enhance my expertise in C++.
Approach Overview
The process starts with a dependency scan of the main .cpp file to generate a JSON file,
which helps build a dependency graph. This allows the compiler to figure out which mod-
ules need compilation and which are already compiled or are system-provided, avoiding
unnecessary work. Next, the required modules are precompiled into .pcm files and then
compiled into object (.o) files. Using ‘-fprebuilt-module-path=‘, we specify where pre-
compiled ‘.pcm‘ files are stored, ensuring the compiler correctly resolves and uses them
for dependent files. Once all modules are ready, the main .cpp file is compiled with these
.pcm files and linked against the module object files to generate the final executable.
This structured approach improves efficiency by reducing redundant compilation and
eliminating the need for a traditional build system like Make. Instead, it leverages P1689
                                            2
(a standard for module dependency discovery) and a build graph to automatically track
dependencies, ensuring accurate and efficient compilation without manual intervention.
Timeline and Deliverables
    Timeline      Phase              Tasks                       Deliverables
    & Dura-
    tion
    Before 8th    Pre-Phase          Understand Clang codebase   Personal notes
    May (15       Codebase           Explore module scanning     Initial
    Hours)        Familiarization    mechanism                   community
                                     Identify key components     discussions
    8th May -     Phase 1            Engage with the             Community
    2nd June      Community          community                   feedback
    (30 Hours)    Bonding and        Continue codebase           Refined project
                  Research           exploration                 strategy
                                     Analyze PCM handling
    3rd June -    Phase 2            Integrate module scanning   Working
    18th June     Dependency         Develop build order         prototype
    (40 Hours)    Scanning and       prototype                   Test cases for
                  Analysis           Handle standard library     module imports
                                     imports
    19th June     Phase 3 PCM        Integrate PCM file          Functional build
    - 16th July   File               management , Passing        process
    (35 Hours)    Management         correct and required PCM    Performance
                  and Build          files                       benchmarks
                  Process            Ensure compatibility with
                                     Clang workflows
    17th July -   Phase 4            Support Clang modules via   Extended
    6th           Extended           module map                  module support
    August        Support and        Add robust error handling   Comprehensive
    (30 Hours)    Error Handling     Ensure no overhead for      error handling
                                     non-modular builds
    7th           Phase 5 Testing,   Extensive testing           Complete
    August -      Documentation,     Write documentation         codebase
    1st           and Final          Code review and             Documentation
    September     Review             performance evaluation      and final report
    (25 Hours)
                                             3
Commitments
            Commitment                            Duration           Weekly Hours
      1. Semester VI in Progress             Now - April 10th         15 - 20 hours
 2. Lab Exams + End Semester Exams         April 7th - April 24th        0 hours
             3. Vacation                   April 26th - August 1st    40 - 50 hours
      4. Semester VII in Progress            August 1st - End         10 - 15 hours
Why Me as a Contributor?
I am a highly motivated student with experience in C++. My continuous collaboration
with different teams and individuals reflects my flexibility and adaptability in diverse
environments. I have been consistently working on core software engineering skills, such
as problem-solving, logic building, and performance optimization, which is evident from
my project portfolio.
   One of my key strengths is honesty with my work. I am well aware of my limitations
and know when to seek help. Whenever I face something beyond my current knowledge, I
prefer referring to official documentation, Stack Overflow, or reaching out to experienced
developers rather than fully relying on LLMs for quick solutions. This approach allows
me to deeply understand the underlying concepts and build sustainable solutions.
Expectations from This Project
I aim to gain experience in efficiently managing a large-scale project by breaking it down
into smaller tasks and tracking progress. Through continuous feedback and guidance from
mentors, I hope to enhance my skills in compiler development and c++ programming.
This project will also allow me to make the most of my summer break by contributing
meaningfully to the C++ community.