[all-commits] [llvm/llvm-project] 1674a1: [runtimes][cmake] Probe Fortran intrinsic modules ...

Spencer Bryngelson via All-commits all-commits at lists.llvm.org
Mon Aug 3 03:47:56 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1674a1c6da083c2fdfe7e3539b8bf647989066b5
      https://github.com/llvm/llvm-project/commit/1674a1c6da083c2fdfe7e3539b8bf647989066b5
  Author: Spencer Bryngelson <sbryngelson at gmail.com>
  Date:   2026-08-03 (Mon, 03 Aug 2026)

  Changed paths:
    M runtimes/cmake/config-Fortran.cmake

  Log Message:
  -----------
  [runtimes][cmake] Probe Fortran intrinsic modules for the target triple (#211137)

Fixes #211134.

`check_fortran_builtins_available()` probes for Fortran intrinsic
modules without passing the target triple, in both branches: the
`-print-file-name=iso_c_binding.mod` query runs the driver with no
`--target`, and the `check_fortran_source_compiles()` fallback uses
`try_compile()`, which does not inherit `CMAKE_Fortran_COMPILER_TARGET`.

Flang's intrinsic modules are built per-target by flang-rt. When a
runtime is configured for a GPU target without flang-rt in its runtime
list, both probes test the host and succeed, so
`RUNTIMES_FORTRAN_MODULES` is enabled for a target that cannot support
it. `LIBOMP_FORTRAN_MODULES` inherits that and the failure is deferred
to a cascade of BIND(C) diagnostics compiling `omp_lib.F90`, all
stemming from one missing-module error.

Pass the triple to both probes so the existing graceful-degradation path
is reached instead.

Uses `CMAKE_Fortran_COMPILE_OPTIONS_TARGET` rather than a hard-coded
`--target=`. This file is also used with non-Flang compilers (`:229`,
and `openmp/module/CMakeLists.txt:25` special-cases GNU), and the
`check_fortran_source_compiles` branch is the live path for every
compiler on CMake >= 3.24. gfortran rejects `--target=` outright, so
hard-coding it would silently disable Fortran modules for gfortran users
who get them today. `CMAKE_Fortran_COMPILE_OPTIONS_TARGET` is
`--target=` for Flang and empty for GNU.

Tested:

| compiler | target | result |
|---|---|---|
| gfortran | `x86_64-unknown-linux-gnu` | modules ON, unchanged |
| flang | `x86_64-unknown-linux-gnu` | modules ON, unchanged |
| flang | `amdgcn-amd-amdhsa` | modules OFF, correctly disabled |
| flang | `amdgpu-amd-amdhsa` | modules OFF, correctly disabled |

Also built four full configurations: amdgcn with `openmp` unpatched
fails as described; patched, it builds clean and produces
`libompdevice.a` with no workaround; amdgcn with `openmp;flang-rt` (the
`FlangOffload.cmake` recipe) still builds `omp_lib.mod` for the GPU
triple, so the intentional GPU module support is preserved; and the
x86_64 host build is unchanged.

No test: neither `runtimes/` nor `openmp/` has CMake-configuration test
infrastructure, and this is configure-time logic with no lit surface.

This affects performance-critical applications on large AMD GPU
supercomputers, including [MFC](https://github.com/MFlowCode/MFC).

All numbers above come from the validated reproducers included with this
report and are independently reproducible; they stand on their own.

This was found and root-caused with the assistance of AI tools.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list