[llvm] [runtimes][CMake] Move Fortran support code from flang-rt (PR #171610)

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 23 02:08:53 PST 2026


================
@@ -85,6 +85,195 @@ include(CheckLibraryExists)
 include(LLVMCheckCompilerLinkerFlag)
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
+include(GetToolchainDirs)
+include(ExtendPath)
+
+# Check whether the Fortran compiler already access to builtin modules. Sets
+# HAVE_FORTRAN_INTRINSIC_MODS when returning.
+#
+# This must be wrapped in a function because
+# cmake_push_check_state/cmake_pop_check_state is insufficient to isolate
+# a compiler introspection environment, see
+# https://gitlab.kitware.com/cmake/cmake/-/issues/27419
+function (check_fortran_builtins_available)
+  if (CMAKE_Fortran_COMPILER_FORCED AND CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
+    # CMake's try_compile does not take a user-defined
+    # CMAKE_Fortran_PREPROCESS_SOURCE into account. Instead of test-compiling,
+    # ask Flang directly for the builtin module files.
----------------
petrhosek wrote:

It's been a while since our last CMake version bump, but doing so is going to take a while since we need to ensure that all bots have sufficiently new version so I don't think we should block this change on that.

https://github.com/llvm/llvm-project/pull/171610


More information about the llvm-commits mailing list