[flang-commits] [flang] [flang] Clip circular dependence between implementation modules (PR #85309)
via flang-commits
flang-commits at lists.llvm.org
Thu Mar 14 13:50:02 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
flang/module/__fortran_type_info.mod uses __fortran_builtins.mod, but it is also implicitly used when compiling __fortran_builtins.f90 (or anything else). If __fortran_type_info.mod finds an old __fortran_builtins.mod file, compilation can fail while building the new one.
Break the dependence by *not* generating runtime derived type information for __fortran_builtins.f90.
---
Full diff: https://github.com/llvm/llvm-project/pull/85309.diff
1 Files Affected:
- (modified) flang/lib/Semantics/runtime-type-info.cpp (+10)
``````````diff
diff --git a/flang/lib/Semantics/runtime-type-info.cpp b/flang/lib/Semantics/runtime-type-info.cpp
index 9845a190bc756c..15ea34c66dba52 100644
--- a/flang/lib/Semantics/runtime-type-info.cpp
+++ b/flang/lib/Semantics/runtime-type-info.cpp
@@ -1239,6 +1239,16 @@ void RuntimeTableBuilder::IncorporateDefinedIoGenericInterfaces(
RuntimeDerivedTypeTables BuildRuntimeDerivedTypeTables(
SemanticsContext &context) {
RuntimeDerivedTypeTables result;
+ // Do not attempt to read __fortran_type_info.mod when compiling
+ // the module on which it depends.
+ const auto &allSources{context.allCookedSources().allSources()};
+ if (auto firstProv{allSources.GetFirstFileProvenance()}) {
+ if (const auto *srcFile{allSources.GetSourceFile(firstProv->start())}) {
+ if (srcFile->path().find("__fortran_builtins.f90") != std::string::npos) {
+ return result;
+ }
+ }
+ }
result.schemata = context.GetBuiltinModule(typeInfoBuiltinModule);
if (result.schemata) {
RuntimeTableBuilder builder{context, result};
``````````
</details>
https://github.com/llvm/llvm-project/pull/85309
More information about the flang-commits
mailing list