From ecee3c07c7b6de84f1546a0233daff347a1720c9 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Wed, 12 Mar 2025 16:09:21 +0100 Subject: [PATCH 1/3] [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 Date: Wed, 12 Mar 2025 16:21:08 +0100 Subject: [PATCH 2/3] 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() From 7bca4574bbb35a19400f3761beb27247dfe09aaa Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Wed, 12 Mar 2025 16:31:21 +0100 Subject: [PATCH 3/3] Add 'why' comment --- llvm/runtimes/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt index bde3f6c9455f1..136099dc48ab8 100644 --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -251,6 +251,8 @@ function(runtime_default_target) endif() endforeach() if ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES) + # The target libomp-mod is a dependee of check-flang needed to run its + # OpenMP tests list(APPEND extra_targets "libomp-mod") endif ()