[llvm] [runtimes][cmake] Probe Fortran intrinsic modules for the target triple (PR #211137)
Spencer Bryngelson via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 23 07:19:26 PDT 2026
sbryngelson wrote:
Follow-up, because my previous comment answered the version question but not your "should only be needed for gfortran" point. It is not gfortran-only. The `try_compile` branch is the one flang's runtimes build actually takes.
>From an unpatched `LLVM_RUNTIME_TARGETS=amdgcn-amd-amdhsa` build here, the sub-build's cache:
```
//Test FORTRAN_HAS_ISO_C_BINDING_MOD
FORTRAN_HAS_ISO_C_BINDING_MOD:INTERNAL=1
```
The `//Test ...` help string is the one `check_fortran_source_compiles` writes; the `execute_process` branch writes `Existence result of ...`. `CMAKE_Fortran_COMPILER_ID` is `LLVMFlang` and `CMAKE_Fortran_COMPILER_FORCED` is unset, so the `else()` branch runs. `CMAKE_Fortran_COMPILER_FORCED` is not set anywhere in the LLVM tree; it only comes from a toolchain file, so for a plain runtimes build with flang the `execute_process` path is not reached at all.
The result above is also wrong: it reports `iso_c_binding` as available for `amdgcn-amd-amdhsa` because the probe compiled for the host.
Re-running the same sub-build configure with only the `CMAKE_REQUIRED_FLAGS` hunk applied, on CMake 3.25.2:
```
-- Performing Test FORTRAN_HAS_ISO_C_BINDING_MOD
-- Performing Test FORTRAN_HAS_ISO_C_BINDING_MOD - Failed
-- Fortran support disabled: Not passing smoke check
```
`FORTRAN_HAS_ISO_C_BINDING_MOD` becomes empty, which is the correct answer for that target.
So on CMake < 3.28 that hunk is what actually fixes the reported bug for flang, and the `execute_process` hunk covers the toolchain-forced case. Both look needed to me. Same offer as before: I can wrap it in `if (CMAKE_VERSION VERSION_LESS 3.28)` so it drops out with your other cleanups.
https://github.com/llvm/llvm-project/pull/211137
More information about the llvm-commits
mailing list