[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 30 14:18:54 PST 2023


jhuber6 added a comment.

In D141861#4091961 <https://reviews.llvm.org/D141861#4091961>, @srj wrote:

> In D141861#4091949 <https://reviews.llvm.org/D141861#4091949>, @jhuber6 wrote:
>
>> In D141861#4091922 <https://reviews.llvm.org/D141861#4091922>, @srj wrote:
>>
>>> Crosscompiling to x86-32 on an x86-64 host doesn't strike me as particularly weird at all (especially on Windows), but apparently it is quite weird for LLVM at this point in time as we keep getting a lot of different things broken there :-)
>>
>> I'm not very familiar with this type of build. Are there any variables we could pick up to just disable this if it's not building for the host system? Something like `CMAKE_CROSSCOMPILING`?
>
> I'm not an expert on the LLVM build system, so I'm not entirely sure, but I'd start by examining the CMake setting `LLVM_BUILD_32_BITS` (which we set to ON in this case)

Can you let me know if adding this fixes it.

  diff --git a/clang/tools/nvptx-arch/CMakeLists.txt b/clang/tools/nvptx-arch/CMakeLists.txt
  index 95c25dc75847..ccdba5ed69a7 100644
  --- a/clang/tools/nvptx-arch/CMakeLists.txt
  +++ b/clang/tools/nvptx-arch/CMakeLists.txt
  @@ -12,7 +12,7 @@ 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)
  +if (CUDAToolkit_FOUND AND NOT CMAKE_CROSSCOMPILING)
     target_link_libraries(nvptx-arch PRIVATE CUDA::cuda_driver)
   else()
     target_compile_definitions(nvptx-arch PRIVATE "DYNAMIC_CUDA")


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141861/new/

https://reviews.llvm.org/D141861



More information about the cfe-commits mailing list