[Mlir-commits] [mlir] fix CUDAToolkit_LIBRARY_ROOT DEFINED check (PR #146472)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jun 30 23:07:42 PDT 2025


https://github.com/x12301450 created https://github.com/llvm/llvm-project/pull/146472

This PR fixes #146344  by remove the brace of `CUDAToolkit_LIBRARY_ROOT`.

In mlir/lib/Target/LLVM/CMakeLists.txt, the variable `CUDAToolkit_LIBRARY_ROOT` is used in the following way in Line 66:

`set(MLIR_CUDAToolkit_ROOT ${CUDAToolkit_LIBRARY_ROOT})`

and like this in Line 135:

```
find_file(MLIR_NVVM_LIBDEVICE_PATH libdevice.10.bc
                PATHS ${CUDAToolkit_LIBRARY_ROOT}
                PATH_SUFFIXES "nvvm/libdevice" NO_DEFAULT_PATH REQUIRED)
```

However, when checking whether the variable is defined, it is done in the following way in Line 62:

`if(NOT DEFINED ${CUDAToolkit_LIBRARY_ROOT})`

This `if` command doesn't take effect when `CUDAToolkit_LIBRARY_ROOT` simply represent a path. I think the correct way to write it should be:

`if(NOT DEFINED CUDAToolkit_LIBRARY_ROOT)`

Looking forward to your feedback!

>From 6baef84855465e10437e9b0b65bbfdd851fd418a Mon Sep 17 00:00:00 2001
From: x12301450 <x12301450 at 163.com>
Date: Tue, 1 Jul 2025 14:01:24 +0800
Subject: [PATCH] fix CUDAToolkit_LIBRARY_ROOT DEFINED check

---
 mlir/lib/Target/LLVM/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/Target/LLVM/CMakeLists.txt b/mlir/lib/Target/LLVM/CMakeLists.txt
index 83fbf7a5fe5f3..7c6fc37c40a83 100644
--- a/mlir/lib/Target/LLVM/CMakeLists.txt
+++ b/mlir/lib/Target/LLVM/CMakeLists.txt
@@ -59,7 +59,7 @@ if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
     # See: https://gitlab.kitware.com/cmake/cmake/-/issues/24858
     # TODO: Bump the MLIR CMake version to 3.26.4 and switch to
     # ${CUDAToolkit_LIBRARY_ROOT}
-    if(NOT DEFINED ${CUDAToolkit_LIBRARY_ROOT})
+    if(NOT DEFINED CUDAToolkit_LIBRARY_ROOT)
       get_filename_component(MLIR_CUDAToolkit_ROOT ${CUDAToolkit_BIN_DIR}
                              DIRECTORY ABSOLUTE)
     else()



More information about the Mlir-commits mailing list