[clang] [clang][modules-driver] Precompile std modules independently of -o and final phase (PR #199289)

Naveen Seth Hanig via cfe-commits cfe-commits at lists.llvm.org
Wed May 27 12:09:28 PDT 2026


================
@@ -5471,6 +5478,13 @@ void Driver::BuildJobs(Compilation &C) const {
           A->getKind() == clang::driver::Action::BinaryTranslatorJobClass)
         continue;
 
+      if (isa<PrecompileJobAction>(A) && !A->getInputs().empty()) {
+        const Action *FirstAction = A->getInputs().front();
+        if (FirstAction->getType() == types::TY_CXXStdModule ||
+            FirstAction->getType() == types::TY_PP_CXXStdModule)
+          continue;
+      }
----------------
naveen-seth wrote:

I've added a comment and simplified it a little.

We want to determine whether a `PrecompileJobAction` is for a Standard Library module input. Since `PrecompileJobAction::getType()` always returns `TY_ModuleFile`, we need to check using the `InputAction` which caused this this `PrecompileJobAction` to be generated instead.

The large context of this section of code is that the number of inputs is counted and an error is thrown if `-o` is used with > 1 input.
We still want something like `clang -fmodules-driver main.cpp -o main` to work. The implicitly generated `-cc1` jobs for Standard Library modules should therefore not be counted in that check.

https://github.com/llvm/llvm-project/pull/199289


More information about the cfe-commits mailing list