[libc-commits] [libc] [libc] Remove CUDA Toolkit dependency for NVPTX build (PR #208497)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Thu Jul 9 09:24:48 PDT 2026
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/208497
Summary:
This was problemtatic because these CMake headers were never intended to
be used from a GPu target. We had to hack around this to suppress
threads, but all this is used for is getting the default CUDA path, so
just do this directly.
>From 6c77399a243d91dbe56678bf964d3ad06eca3821 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Thu, 9 Jul 2026 11:15:39 -0500
Subject: [PATCH] [libc] Remove CUDA Toolkit dependency for NVPTX build
Summary:
This was problemtatic because these CMake headers were never intended to
be used from a GPu target. We had to hack around this to suppress
threads, but all this is used for is getting the default CUDA path, so
just do this directly.
---
.../modules/prepare_libc_gpu_build.cmake | 20 ++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/libc/cmake/modules/prepare_libc_gpu_build.cmake b/libc/cmake/modules/prepare_libc_gpu_build.cmake
index 36ab321e4994c..aba4d11bf41a1 100644
--- a/libc/cmake/modules/prepare_libc_gpu_build.cmake
+++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake
@@ -73,12 +73,18 @@ set(LIBC_GPU_TARGET_ARCHITECTURE "${gpu_test_architecture}")
set(LIBC_GPU_CODE_OBJECT_VERSION "6" CACHE STRING "AMDGPU Code object ABI to use")
if(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
- # FIXME: This is a hack required to keep the CUDA package from trying to find
- # pthreads. We only link the CUDA driver, so this is unneeded.
- add_library(CUDA::cudart_static_deps IMPORTED INTERFACE)
-
- find_package(CUDAToolkit QUIET)
- if(CUDAToolkit_FOUND)
- get_filename_component(LIBC_CUDA_ROOT "${CUDAToolkit_BIN_DIR}" DIRECTORY ABSOLUTE)
+ # Respect the standard CUDAToolkit_ROOT override if the user provided one,
+ # otherwise ask the compiler which CUDA installation it detected.
+ if(CUDAToolkit_ROOT)
+ set(LIBC_CUDA_ROOT "${CUDAToolkit_ROOT}")
+ else()
+ execute_process(
+ COMMAND ${CMAKE_CXX_COMPILER} -v --print-resource-dir
+ OUTPUT_QUIET ERROR_VARIABLE cuda_search_output)
+ string(REGEX MATCH "Found CUDA installation: ([^,]+), version"
+ cuda_search_match "${cuda_search_output}")
+ if(CMAKE_MATCH_1)
+ set(LIBC_CUDA_ROOT "${CMAKE_MATCH_1}")
+ endif()
endif()
endif()
More information about the libc-commits
mailing list