Author: Joseph Huber Date: 2023-05-17T17:47:49-05:00 New Revision: 66da9ec073ff8dde54b70adcf3b62914769324bf
URL: https://github.com/llvm/llvm-project/commit/66da9ec073ff8dde54b70adcf3b62914769324bf DIFF: https://github.com/llvm/llvm-project/commit/66da9ec073ff8dde54b70adcf3b62914769324bf.diff LOG: [Clang] Remove direct linking of offloading runtimes from the arch tools The tools `amdgpu-arch` and `nvptx-arch` are used to query the supported GPUs on a system to implement features like `--offload-arch=native` as well as generally being useful for setting up tests. However, we currently directly link these if they are availible. This patch removes this because it causes many problems on the user not having the libaries present or misconfigured at build time. Since these are built unconditionally we shoudl keep the dependencies away from clang. Fixes https://github.com/llvm/llvm-project/issues/62784 Reviewed By: ye-luo Differential Revision: https://reviews.llvm.org/D150807 Added: Modified: clang/tools/amdgpu-arch/AMDGPUArch.cpp clang/tools/amdgpu-arch/CMakeLists.txt clang/tools/nvptx-arch/CMakeLists.txt clang/tools/nvptx-arch/NVPTXArch.cpp Removed: ################################################################################ diff --git a/clang/tools/amdgpu-arch/AMDGPUArch.cpp b/clang/tools/amdgpu-arch/AMDGPUArch.cpp index b63ff5cfe1759..17d188adc3b7d 100644 --- a/clang/tools/amdgpu-arch/AMDGPUArch.cpp +++ b/clang/tools/amdgpu-arch/AMDGPUArch.cpp @@ -30,7 +30,6 @@ static void PrintVersion(raw_ostream &OS) { OS << clang::getClangToolFullVersion("amdgpu-arch") << '\n'; } -#if DYNAMIC_HSA typedef enum { HSA_STATUS_SUCCESS = 0x0, } hsa_status_t; @@ -80,18 +79,6 @@ llvm::Error loadHSA() { #undef DYNAMIC_INIT return llvm::Error::success(); } -#else - -#if defined(__has_include) -#if __has_include("hsa/hsa.h") -#include "hsa/hsa.h" -#elif __has_include("hsa.h") -#include "hsa.h" -#endif -#endif - -llvm::Error loadHSA() { return llvm::Error::success(); } -#endif static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) { hsa_device_type_t DeviceType; diff --git a/clang/tools/amdgpu-arch/CMakeLists.txt b/clang/tools/amdgpu-arch/CMakeLists.txt index 4349fb9108a71..6363eda49abe0 100644 --- a/clang/tools/amdgpu-arch/CMakeLists.txt +++ b/clang/tools/amdgpu-arch/CMakeLists.txt @@ -10,12 +10,4 @@ set(LLVM_LINK_COMPONENTS Support) add_clang_tool(amdgpu-arch AMDGPUArch.cpp) -# If we find the HSA runtime we link with it directly. -find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm) -if(hsa-runtime64_FOUND AND NOT (LLVM_BUILD_32_BITS OR CMAKE_SIZEOF_VOID_P EQUAL 4)) - set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON) - target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64 clangBasic) -else() - target_compile_definitions(amdgpu-arch PRIVATE "DYNAMIC_HSA") - target_link_libraries(amdgpu-arch PRIVATE clangBasic) -endif() +target_link_libraries(amdgpu-arch PRIVATE clangBasic) diff --git a/clang/tools/nvptx-arch/CMakeLists.txt b/clang/tools/nvptx-arch/CMakeLists.txt index 3444cf5b70dfd..8f756be2c86d0 100644 --- a/clang/tools/nvptx-arch/CMakeLists.txt +++ b/clang/tools/nvptx-arch/CMakeLists.txt @@ -9,12 +9,4 @@ set(LLVM_LINK_COMPONENTS Support) add_clang_tool(nvptx-arch NVPTXArch.cpp) -find_package(CUDAToolkit QUIET) - -# If we found the CUDA library directly we just dynamically link against it. -if(CUDAToolkit_FOUND AND NOT (LLVM_BUILD_32_BITS OR CMAKE_SIZEOF_VOID_P EQUAL 4)) - target_link_libraries(nvptx-arch PRIVATE CUDA::cuda_driver clangBasic) -else() - target_compile_definitions(nvptx-arch PRIVATE "DYNAMIC_CUDA") - target_link_libraries(nvptx-arch PRIVATE clangBasic) -endif() +target_link_libraries(nvptx-arch PRIVATE clangBasic) diff --git a/clang/tools/nvptx-arch/NVPTXArch.cpp b/clang/tools/nvptx-arch/NVPTXArch.cpp index b053fcc6e0bdd..71a48657576e4 100644 --- a/clang/tools/nvptx-arch/NVPTXArch.cpp +++ b/clang/tools/nvptx-arch/NVPTXArch.cpp @@ -30,7 +30,6 @@ static void PrintVersion(raw_ostream &OS) { // and -help) will be hidden. static cl::OptionCategory NVPTXArchCategory("nvptx-arch options"); -#if DYNAMIC_CUDA typedef enum cudaError_enum { CUDA_SUCCESS = 0, CUDA_ERROR_NO_DEVICE = 100, @@ -75,12 +74,6 @@ llvm::Error loadCUDA() { #undef DYNAMIC_INIT return llvm::Error::success(); } -#else - -#include "cuda.h" -llvm::Error loadCUDA() { return llvm::Error::success(); } - -#endif static int handleError(CUresult Err) { const char *ErrStr = nullptr; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits