[flang] [llvm] [Flang] Adds omp_lib dependency to check-flang (PR #130975)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 12 08:21:28 PDT 2025


https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/130975

>From ecee3c07c7b6de84f1546a0233daff347a1720c9 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 12 Mar 2025 16:09:21 +0100
Subject: [PATCH 1/2] [Flang] Adds omp_lib dependency to check-flang

---
 flang/test/CMakeLists.txt      |  4 ++++
 flang/tools/f18/CMakeLists.txt | 12 ++++++++----
 llvm/runtimes/CMakeLists.txt   |  3 +++
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index 777cf5fc5433b..17a7f58902dca 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -100,6 +100,10 @@ if (LLVM_BUILD_EXAMPLES)
     )
 endif ()
 
+if ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT FLANG_STANDALONE_BUILD)
+  list(APPEND FLANG_TEST_DEPENDS "libomp-mod")
+endif ()
+
 add_custom_target(flang-test-depends DEPENDS ${FLANG_TEST_DEPENDS})
 set_target_properties(flang-test-depends PROPERTIES FOLDER "Flang/Meta")
 
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 5b5f23b5dc73c..119e96dc9ca02 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -142,7 +142,7 @@ if (NOT CMAKE_CROSSCOMPILING)
   # It also produces two module files: omp_lib.mod and omp_lib_kinds.mod.  Compile these
   # files only if OpenMP support has been configured.
   if (LLVM_TOOL_OPENMP_BUILD)
-    message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.mod")
+    message(STATUS "OpenMP runtime support enabled via LLVM_ENABLE_PROJECTS, building omp_lib.mod")
     set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
     add_custom_command(OUTPUT ${base}.mod ${base}_kinds.mod
       COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
@@ -158,8 +158,10 @@ if (NOT CMAKE_CROSSCOMPILING)
         COMMAND ${CMAKE_COMMAND} -E copy ${base}_kinds.mod ${base}_kinds.f18.mod)
     list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod)
     install(FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
+  elseif ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
+    message(STATUS "OpenMP runtime support enabled via LLVM_ENABLE_RUNTIMES, assuming omp_lib.mod is built there")
   else()
-    message(STATUS "Not building omp_lib.mod, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
+    message(WARNING "Not building omp_lib.mod, no OpenMP runtime in either LLVM_ENABLE_PROJECTS or LLVM_ENABLE_RUNTIMES")
   endif()
 endif()
 
@@ -169,9 +171,11 @@ set_target_properties(module_files PROPERTIES FOLDER "Flang/Resources")
 # TODO Move this to a more suitable location
 # Copy the generated omp_lib.h header file, if OpenMP support has been configured.
 if (LLVM_TOOL_OPENMP_BUILD)
-  message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.h")
+  message(STATUS "OpenMP runtime support enabled via LLVM_ENABLE_PROJECTS, building omp_lib.h")
   file(COPY ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
   install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
+elseif ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
+  message(STATUS "OpenMP runtime support enabled via LLVM_ENABLE_RUNTIMES, assuming omp_lib.h is built there")
 else()
-  message(STATUS "Not copying omp_lib.h, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
+  message(STATUS "Not copying omp_lib.h, no OpenMP runtime in LLVM_ENABLE_PROJECTS")
 endif()
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 77a82ed196cd9..bde3f6c9455f1 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -250,6 +250,9 @@ function(runtime_default_target)
       list(APPEND extra_targets install-${component} install-${component}-stripped)
     endif()
   endforeach()
+  if ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
+    list(APPEND extra_targets "libomp-mod")
+  endif ()
 
   if(LLVM_INCLUDE_TESTS)
     set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES "@${LLVM_BINARY_DIR}/runtimes/runtimes-bins/lit.tests")

>From 9a4604a250f8e89195f5112516c9622f1f25c7cb Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 12 Mar 2025 16:21:08 +0100
Subject: [PATCH 2/2] Also mention LLVM_ENABLE_RUNTIMES

---
 flang/tools/f18/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 119e96dc9ca02..a66c8e36b3326 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -177,5 +177,5 @@ if (LLVM_TOOL_OPENMP_BUILD)
 elseif ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
   message(STATUS "OpenMP runtime support enabled via LLVM_ENABLE_RUNTIMES, assuming omp_lib.h is built there")
 else()
-  message(STATUS "Not copying omp_lib.h, no OpenMP runtime in LLVM_ENABLE_PROJECTS")
+  message(STATUS "Not copying omp_lib.h, no OpenMP runtime in either LLVM_ENABLE_PROJECTS or LLVM_ENABLE_RUNTIMES")
 endif()



More information about the llvm-commits mailing list