[libc] Only add extra runtime dependencies if the target exists
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 5 Apr 2023 20:30:48 +0000 (15:30 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 5 Apr 2023 20:31:38 +0000 (15:31 -0500)
Summary:
If the target for these tools doesn't exist we should simply assume that
they will be provided externally. This allows building `libc` standalone
with an external installation of `clang`.

libc/cmake/modules/prepare_libc_gpu_build.cmake
llvm/runtimes/CMakeLists.txt

index 9e0ce79..2185128 100644 (file)
@@ -103,6 +103,5 @@ if(LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
   find_package(CUDAToolkit QUIET)
   if(CUDAToolkit_FOUND)
     get_filename_component(LIBC_CUDA_ROOT "${CUDAToolkit_BIN_DIR}" DIRECTORY ABSOLUTE)
-    message(WARNING ${LIBC_CUDA_ROOT})
   endif()
 endif()
index d47a2d5..8cf4365 100644 (file)
@@ -382,7 +382,11 @@ if(runtimes)
       message(FATAL_ERROR "libc-hdrgen target missing unexpectedly")
     endif()
     if(LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES)
-      list(APPEND extra_deps clang-offload-packager nvptx-arch amdgpu-arch)
+      foreach(dep clang-offload-packager nvptx-arch amdgpu-arch)
+        if(TARGET ${dep})
+          list(APPEND extra_deps ${dep})
+        endif()
+      endforeach()
     endif()
   endif()
   if(NOT LLVM_RUNTIME_TARGETS)