[llvm] libclc: Pass LLVM_NATIVE_TOOL_DIR to runtime builds (PR #196498)

Konrad Kleine via llvm-commits llvm-commits at lists.llvm.org
Fri May 8 02:16:39 PDT 2026


https://github.com/kwk created https://github.com/llvm/llvm-project/pull/196498

This patch sets `LLVM_NATIVE_TOOL_DIR` in the runtime build configuration to point to the directory containing the just-built LLVM tools, allowing libclc to find them without requiring them to be installed on the host system.

Fixes build errors like:

```
  Error evaluating generator expression: $<TARGET_FILE:opt>
  No target "opt"
```

A few lines above this change, `extra_deps` list of dependencies for libclc is created. But those tools don't get build in the runtime build. We build libclc in the monolithic build and there we have all the tools which is why I've added the path to discover the tools.

>From e32f5a10faccd9d2dc86dc66e1ab0a828f540626 Mon Sep 17 00:00:00 2001
From: Fedora LLVM Team <llvm at fedoraproject.org>
Date: Fri, 24 Apr 2026 00:00:00 +0000
Subject: [PATCH] libclc: Pass LLVM_NATIVE_TOOL_DIR to runtime builds

When building libclc as a runtime for cross-compilation targets
(e.g., amdgcn-amd-amdhsa-llvm), the build configuration needs to
locate LLVM tools like opt and llvm-link. The get_host_tool_path()
function checks LLVM_NATIVE_TOOL_DIR first before falling back to
target references.

This patch sets LLVM_NATIVE_TOOL_DIR in the runtime build configuration
to point to the directory containing the just-built LLVM tools, allowing
libclc to find them without requiring them to be installed on the host
system.

Fixes build errors like:
  Error evaluating generator expression: $<TARGET_FILE:opt>
  No target "opt"
---
 llvm/runtimes/CMakeLists.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 1e074526d0f7c..9dc4c35ac02b7 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -582,6 +582,8 @@ if(build_runtimes)
         list(APPEND extra_deps ${dep})
       endif()
     endforeach()
+    # Pass the location of LLVM tools to the runtime build so libclc can find them
+    list(APPEND extra_cmake_args "-DLLVM_NATIVE_TOOL_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}")
   endif()
   # Tools needed by build_symbolizer.sh.
   if("compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES AND COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)



More information about the llvm-commits mailing list