[flang-commits] [flang] dc55c44 - [flang] Clip circular dependence between implementation modules (#85309)

via flang-commits flang-commits at lists.llvm.org
Thu Mar 14 15:29:09 PDT 2024


Author: Peter Klausler
Date: 2024-03-14T15:29:06-07:00
New Revision: dc55c4435d796f6ec316de0698df9b8649816068

URL: https://github.com/llvm/llvm-project/commit/dc55c4435d796f6ec316de0698df9b8649816068
DIFF: https://github.com/llvm/llvm-project/commit/dc55c4435d796f6ec316de0698df9b8649816068.diff

LOG: [flang] Clip circular dependence between implementation modules (#85309)

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.

Added: 
    

Modified: 
    flang/lib/Semantics/runtime-type-info.cpp

Removed: 
    


################################################################################
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};


        


More information about the flang-commits mailing list