[llvm] [runtimes] Fix OpenMP dependencies (PR #85977)

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 10:42:29 PDT 2024


https://github.com/uweigand created https://github.com/llvm/llvm-project/pull/85977

When building the OpenMP runtime with libomptarget support, the runtimes configure step needs to have a dependency on various tools, in particular opt, so that cmake configure checks yield the correct results.

This did not work correctly, as the dependencies were only added if the OPENMP_ENABLE_LIBOMPTARGET was set - but that variable is only set by the openmp/CMakeLists.txt file, which isn't even parsed during the initial cmake run (in fact, it is only parsed when executing the runtimes configure step itself, but then it is too late).

Fixed by just adding those dependencies always.

In addition, the list of dependencies collected in ${extra_deps}, including those required for OpenMP, was only actually used when configuring runtimes for the default set of targets - when the user specifies a non-default LLVM_RUNTIME_TARGETS, those extra dependencies were ignored (with the exception of ${hdrgen_deps}).

Fixed by passing the full ${extra_deps} in this case as well.

Fixes: https://github.com/llvm/llvm-project/issues/85933

>From 7630959f89e764796bab8053ee2509f806501917 Mon Sep 17 00:00:00 2001
From: Ulrich Weigand <ulrich.weigand at de.ibm.com>
Date: Wed, 20 Mar 2024 18:34:52 +0100
Subject: [PATCH] [runtimes] Fix OpenMP dependencies

When building the OpenMP runtime with libomptarget support, the
runtimes configure step needs to have a dependency on various
tools, in particular opt, so that cmake configure checks yield
the correct results.

This did not work correctly, as the dependencies were only added
if the OPENMP_ENABLE_LIBOMPTARGET was set - but that variable is
only set by the openmp/CMakeLists.txt file, which isn't even
parsed during the initial cmake run (in fact, it is only parsed
when executing the runtimes configure step itself, but then it
is too late).

Fixed by just adding those dependencies always.

In addition, the list of dependencies collected in ${extra_deps},
including those required for OpenMP, was only actually used when
configuring runtimes for the default set of targets - when the
user specifies a non-default LLVM_RUNTIME_TARGETS, those extra
dependencies were ignored (with the exception of ${hdrgen_deps}).

Fixed by passing the full ${extra_deps} in this case as well.

Fixes: https://github.com/llvm/llvm-project/issues/85933
---
 llvm/runtimes/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 623c43d564cc82..8159d7f8a0a104 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -435,7 +435,7 @@ if(runtimes)
       list(APPEND extra_deps "flang-new")
     endif()
     foreach(dep opt llvm-link llvm-extract clang clang-offload-packager)
-      if(TARGET ${dep} AND OPENMP_ENABLE_LIBOMPTARGET)
+      if(TARGET ${dep})
         list(APPEND extra_deps ${dep})
       endif()
     endforeach()
@@ -531,7 +531,7 @@ if(runtimes)
       check_apple_target(${name} runtime)
 
       runtime_register_target(${name}
-        DEPENDS ${builtins_dep_name} ${hdrgen_deps}
+        DEPENDS ${builtins_dep_name} ${extra_deps}
         CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${libc_cmake_args}
         EXTRA_ARGS TARGET_TRIPLE ${name})
     endforeach()



More information about the llvm-commits mailing list