[PATCH] D113880: [clang][modules] Infer framework modules in explicit builds
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 15 03:46:36 PST 2021
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, vsapsai.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
When the dependency scanner discovers dependency on an inferred module, it correctly reports the original modulemap path (instead of the virtual `__inferred_module.map` file) as the input file for building the module.
However, during explicit build, `-fimplicit-module-maps` is necessary to successfully build such module. Without the flag, the module is not inferred:
// HeaderSearch.cpp:1681
case LMM_InvalidModuleMap:
// Try to infer a module map from the framework directory.
if (HSOpts->ImplicitModuleMaps)
ModMap.inferFrameworkModule(Dir, IsSystem, /*Parent=*/nullptr);
break;
... and the build fails with "unknown module" error.
To support explicit builds of inferred modules, D102495 <https://reviews.llvm.org/D102495> stopped removing the `-fimplicit-module-maps` from the command lines produced by dependency scanner.
While this works, implicit module maps don't seem like a good fit for explicit modules: since the module map necessary to build a module is already known, we don't need to discover `.modulemap` files in search paths.
Besides the possibility of performing unnecessary filesystem operations, `-fimplicit-module-maps` can uncover different semantics between explicit and implicit modules: D113775 <https://reviews.llvm.org/D113775>.
This patch tries attempts to infer modules even in explicit builds if possible, which also enables the dependency scanner to always disable the implicit module maps feature.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113880
Files:
clang/include/clang/Lex/ModuleMap.h
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/modules-full.cpp
clang/test/ClangScanDeps/modules-inferred.m
clang/test/ClangScanDeps/modules-pch.c
clang/test/Modules/explicit-build-inferred.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113880.387197.patch
Type: text/x-patch
Size: 6816 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211115/e6a4a47e/attachment-0001.bin>
More information about the cfe-commits
mailing list