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

…paths

When `LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR` is set, the custom tool paths were 
not properly overriding the default tool paths set by `get_host_tool_path()`. 
This caused libclc to still depend on building in-tree tools even when custom 
tools were specified.

The issue was that `get_host_tool_path()` sets `${tool}_exe` and 
`${tool}_target` as `CACHE` variables with `FORCE`, but the custom tools block 
was using regular `set()` commands, which don't override cache variables.

Fix by using `CACHE STRING "" FORCE` when setting the custom tool paths, 
ensuring they properly override the cache variables set by 
`get_host_tool_path()`.

This allows users to specify external LLVM tools via 
`LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR` without triggering unnecessary builds of 
in-tree tools.

>From 1b68f5bf7eeeed2f2e37de5d8090439af10c0917 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <[email protected]>
Date: Fri, 19 Dec 2025 11:22:23 +0000
Subject: [PATCH] [libclc] Fix LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR not
 overriding tool paths
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR is set, the custom tool paths
were not properly overriding the default tool paths set by
get_host_tool_path(). This caused libclc to still depend on building
in-tree tools even when custom tools were specified.

The issue was that get_host_tool_path() sets ${tool}_exe and
${tool}_target as CACHE variables with FORCE, but the custom tools
block was using regular set() commands, which don't override cache
variables.

Fix by using "CACHE STRING "" FORCE" when setting the custom tool
paths, ensuring they properly override the cache variables set by
get_host_tool_path().

This allows users to specify external LLVM tools via
LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR without triggering unnecessary
builds of in-tree tools.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
---
 libclc/CMakeLists.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 1d29adb0f3995..b0d5fcd96590f 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -121,8 +121,9 @@ if( EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
   foreach( tool IN ITEMS clang llvm-as llvm-link opt )
     find_program( LLVM_CUSTOM_TOOL_${tool} ${tool}
       PATHS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
-    set( ${tool}_exe ${LLVM_CUSTOM_TOOL_${tool}} )
-    set( ${tool}_target )
+    # Use CACHE FORCE to override the cache variables set by get_host_tool_path
+    set( ${tool}_exe ${LLVM_CUSTOM_TOOL_${tool}} CACHE STRING "" FORCE )
+    set( ${tool}_target "" CACHE STRING "" FORCE )
   endforeach()
 endif()
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to