<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/110425>110425</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang][regression] cannot build flang utilizing low number of cores after #109874
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          pawosm-arm
      </td>
    </tr>
</table>

<pre>
    It is fairly easy to build flang when doing `make -j 64`. However, I sometimes need to start a build or smaller machines where I need to build it doing `make -j 9`. A couple of days ago this became impossible due to this error:

```
ld.lld: error: undefined symbol: mlir::omp::OffloadModuleInterface::setIsTargetDevice(bool)
>>> referenced by CrossToolHelpers.h:180 (~/llvm-project/flang/include/flang/Tools/CrossToolHelpers.h:180)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(setOffloadModuleInterfaceAttributes(mlir::ModuleOp&, OffloadModuleOpts))

ld.lld: error: undefined symbol: mlir::omp::OffloadModuleInterface::setIsGPU(bool)
>>> referenced by CrossToolHelpers.h:181 (~/llvm-project/flang/include/flang/Tools/CrossToolHelpers.h:181)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(setOffloadModuleInterfaceAttributes(mlir::ModuleOp&, OffloadModuleOpts))

ld.lld: error: undefined symbol: mlir::omp::OffloadModuleInterface::setRequires(mlir::omp::ClauseRequires)
>>> referenced by CrossToolHelpers.h:183 (~/llvm-project/flang/include/flang/Tools/CrossToolHelpers.h:183)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(setOffloadModuleInterfaceAttributes(mlir::ModuleOp&, OffloadModuleOpts))

ld.lld: error: undefined symbol: mlir::omp::OffloadModuleInterface::setFlags(unsigned int, bool, bool, bool, bool, unsigned int, bool)
>>> referenced by CrossToolHelpers.h:186 (~/llvm-project/flang/include/flang/Tools/CrossToolHelpers.h:186)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(setOffloadModuleInterfaceAttributes(mlir::ModuleOp&, OffloadModuleOpts))

ld.lld: error: undefined symbol: mlir::omp::OffloadModuleInterface::setHostIRFilePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
>>> referenced by CrossToolHelpers.h:191 (~/llvm-project/flang/include/flang/Tools/CrossToolHelpers.h:191)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(setOffloadModuleInterfaceAttributes(mlir::ModuleOp&, OffloadModuleOpts))

ld.lld: error: undefined symbol: mlir::omp::OffloadModuleInterface::setTargetTriples(llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >)
>>> referenced by CrossToolHelpers.h:195 (~/llvm-project/flang/include/flang/Tools/CrossToolHelpers.h:195)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(setOffloadModuleInterfaceAttributes(mlir::ModuleOp&, OffloadModuleOpts))

ld.lld: error: undefined symbol: mlir::omp::VersionAttr::get(mlir::MLIRContext*, unsigned int)
>>> referenced by CrossToolHelpers.h:203 (~/llvm-project/flang/include/flang/Tools/CrossToolHelpers.h:203)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(setOpenMPVersionAttribute(mlir::ModuleOp&, long))

ld.lld: error: undefined symbol: mlir::omp::VersionAttr::getVersion() const
>>> referenced by CrossToolHelpers.h:209 (~/llvm-project/flang/include/flang/Tools/CrossToolHelpers.h:209)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(getOpenMPVersionAttribute(mlir::ModuleOp, long))

ld.lld: error: undefined symbol: mlir::detail::TypeIDResolver<mlir::omp::VersionAttr, void>::id
>>> referenced by OpenMPOpsAttributes.h.inc:388 (~/build-shared-llvm-project-debug/tools/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsAttributes.h.inc:388)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(mlir::detail::TypeIDResolver<mlir::omp::VersionAttr, void>::resolveTypeID())
>>> referenced by OpenMPOpsAttributes.h.inc:388 (~/build-shared-llvm-project-debug/tools/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsAttributes.h.inc:388)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(mlir::detail::TypeIDResolver<mlir::omp::VersionAttr, void>::resolveTypeID())

ld.lld: error: undefined symbol: llvm::Triple::normalize[abi:cxx11](llvm::StringRef)
>>> referenced by Triple.h:370 (~/llvm-project/llvm/include/llvm/TargetParser/Triple.h:370)
>>> CMakeFiles/flangPasses.dir/Pipelines.cpp.o:(llvm::Triple::normalize[abi:cxx11]() const)
collect2: error: ld returned 1 exit status
make[2]: *** [tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/build.make:194: lib/libflangPasses.so.20.0git] Error 1
```

I've tracked it down to the PR #109874 - after reverting it, the error message shown above stops appearing.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWE1v2zgQ_TX0ZRBBoizFOvjg2PXWwBYxstm9BpQ4ltlQopaknLiH_e0Lkv6I26RFU2cvG0CwJXL4OPPekBqRGSPqFnFMsiuSzQast2ulxx17UKa5YLoZlIpvxwsLwsCKCS23gMxswSooeyE5rCRra3hYYwtcibYGkscNu0e4-Az5kORxBB_VA25QEzqFBRjVoBUNGmgRucMxlmkLbIenNJiGSYkaGlatRYvGoWuExWFEsBT22xkLP-EEKtV3EkGtgLOtAVYrsGthoMSKNQii6ZQxopQIvEcH6XtRa6VJOiHxjMT73zzeXf5R8khKTtLJwRj6luNKtMjBbJtSSdfWSOGB0olqunBzvVpJxfgnxXuJi9aiXrEKQ59BuzC3TNdoZ7gRFRI6KpWShBY7L9IP4QKNK9TYVsih3MJUK2NulZIfUXaoTbQm6SQZxUDo6B9C51JumotOq89YWULnXixC56KtZM_xSYvDMITOXwJ8xpPpJ3aPcyHR7HGWzBg0ERea0PlSdCidfFHVdZFygdKRQfs8DxNrtSh768BGR_aC1XVHaO7S52TsdWeNc-v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