Skip to content

Commit

Permalink
[flang] Clip circular dependence between implementation modules (#85309)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
klausler committed Mar 14, 2024
1 parent 49b8a99 commit dc55c44
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions flang/lib/Semantics/runtime-type-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit dc55c44

Please sign in to comment.