[flang-commits] [flang] [llvm] [Flang] Fix runtime module file dependency on tests (PR #200417)

Joseph Huber via flang-commits flang-commits at lists.llvm.org
Fri May 29 07:17:18 PDT 2026


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/200417

Summary:
Ever since https://github.com/llvm/llvm-project/pull/171515 we now build
the moduel files in the runtime step. This is problematic because pretty
much all of the tests depend on them. The current dependency chain
doesn't work correctly because the dependencies are set much later.

This fix just adds a global property so that we can set these
out-of-order and sets that property to depend on all the runtime tests.

Flang now becomes the only test suite who depends on the runtimes like
this, every other project's test suite is hermetic. However, moving
pretty much every flang test to flang-rt isn't ideal. We can investigate
this in depth later but for now this fixes the build.


>From 7d86ca757965ea2fd86a2c7bf087694ec93a365e Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 29 May 2026 09:14:09 -0500
Subject: [PATCH] [Flang] Fix runtime module file dependency on tests

Summary:
Ever since https://github.com/llvm/llvm-project/pull/171515 we now build
the moduel files in the runtime step. This is problematic because pretty
much all of the tests depend on them. The current dependency chain
doesn't work correctly because the dependencies are set much later.

This fix just adds a global property so that we can set these
out-of-order and sets that property to depend on all the runtime tests.

Flang now becomes the only test suite who depends on the runtimes like
this, every other project's test suite is hermetic. However, moving
pretty much every flang test to flang-rt isn't ideal. We can investigate
this in depth later but for now this fixes the build.
---
 flang/test/CMakeLists.txt | 9 ++-------
 llvm/CMakeLists.txt       | 8 ++++++++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index f1b492ee6cdc0..daded413cd654 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -121,13 +121,8 @@ if (LLVM_INCLUDE_EXAMPLES)
 endif ()
 
 if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT FLANG_STANDALONE_BUILD)
-  # For intrinsic module files (in flang-rt/)
-  list(APPEND FLANG_TEST_DEPENDS "flang-rt-mod")
-
-  if ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
-    # For omplib.mod and omplib_kinds.mod (in openmp/)
-    list(APPEND FLANG_TEST_DEPENDS "libomp-mod")
-  endif ()
+  # Flang tests need runtimes module files (flang-rt-mod, libomp-mod, etc.).
+  set_property(GLOBAL APPEND PROPERTY LLVM_TEST_DEPENDS_ON_RUNTIMES check-flang)
 endif ()
 
 add_custom_target(flang-test-depends DEPENDS ${FLANG_TEST_DEPENDS})
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 4509fbaba1d25..58b8e56c8555b 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1465,6 +1465,14 @@ if( LLVM_INCLUDE_TESTS )
   endif()
   set_target_properties(test-depends PROPERTIES FOLDER "LLVM/Tests")
   add_dependencies(check-all test-depends)
+
+  # Projects that need runtimes for their tests (e.g. flang needs flang-rt).
+  get_property(runtimes_test_consumers GLOBAL PROPERTY LLVM_TEST_DEPENDS_ON_RUNTIMES)
+  foreach(target ${runtimes_test_consumers})
+    if (TARGET ${target})
+      add_dependencies(${target} test-depends)
+    endif()
+  endforeach()
 endif()
 
 if (LLVM_INCLUDE_DOCS)



More information about the flang-commits mailing list