From 43d90f3056f91198169505eb2c8ccf47f384b877 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Wed, 5 Apr 2023 15:30:48 -0500 Subject: [PATCH] [libc] Only add extra runtime dependencies if the target exists 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 | 1 - llvm/runtimes/CMakeLists.txt | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libc/cmake/modules/prepare_libc_gpu_build.cmake b/libc/cmake/modules/prepare_libc_gpu_build.cmake index 9e0ce79..2185128 100644 --- a/libc/cmake/modules/prepare_libc_gpu_build.cmake +++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake @@ -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() diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt index d47a2d5..8cf4365 100644 --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -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) -- 2.7.4