[libc-commits] [libc] [libc] Search the compiler's path for GPU utility tools (PR #82712)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Thu Feb 22 16:22:15 PST 2024
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/82712
Summary:
We need some extra tools for the GPU build. Normally we search for these
from the build itself, but in the case of a `LLVM_PROJECTS_BUILD` or
some other kind of external build, this directory will not be populated.
However, the GPU build already requires that the compiler is an
up-to-date clang, which should always have these present next to the
binary. Simply add this as a fallback search path. Generally we want it
to be the second, because it would pick up someone install and then
become stale.
>From 9255825f1ff6baf9daadc85cc96b37785eed5c0d Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Thu, 22 Feb 2024 18:20:14 -0600
Subject: [PATCH] [libc] Search the compiler's path for GPU utility tools
Summary:
We need some extra tools for the GPU build. Normally we search for these
from the build itself, but in the case of a `LLVM_PROJECTS_BUILD` or
some other kind of external build, this directory will not be populated.
However, the GPU build already requires that the compiler is an
up-to-date clang, which should always have these present next to the
binary. Simply add this as a fallback search path. Generally we want it
to be the second, because it would pick up someone install and then
become stale.
---
libc/cmake/modules/prepare_libc_gpu_build.cmake | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libc/cmake/modules/prepare_libc_gpu_build.cmake b/libc/cmake/modules/prepare_libc_gpu_build.cmake
index 75beef86760c8d..804023a5229d87 100644
--- a/libc/cmake/modules/prepare_libc_gpu_build.cmake
+++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake
@@ -16,10 +16,12 @@ if(NOT LLVM_LIBC_FULL_BUILD)
"GPU.")
endif()
+
# Identify the program used to package multiple images into a single binary.
+get_filename_component(compiler_path ${CMAKE_CXX_COMPILER} DIRECTORY)
find_program(LIBC_CLANG_OFFLOAD_PACKAGER
NAMES clang-offload-packager NO_DEFAULT_PATH
- PATHS ${LLVM_BINARY_DIR}/bin)
+ PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path})
if(NOT LIBC_CLANG_OFFLOAD_PACKAGER)
message(FATAL_ERROR "Cannot find the 'clang-offload-packager' for the GPU "
"build")
@@ -45,7 +47,7 @@ elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
# Using 'check_cxx_compiler_flag' does not work currently due to the link job.
find_program(LIBC_NVPTX_ARCH
NAMES nvptx-arch NO_DEFAULT_PATH
- PATHS ${LLVM_BINARY_DIR}/bin)
+ PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path})
if(LIBC_NVPTX_ARCH)
execute_process(COMMAND ${LIBC_NVPTX_ARCH}
OUTPUT_VARIABLE arch_tool_output
More information about the libc-commits
mailing list