Skip to content

Commit 7a5c01d

Browse files
authored
[libc] Search the compiler's path for GPU utility tools (llvm#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.
1 parent 9e84a22 commit 7a5c01d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libc/cmake/modules/prepare_libc_gpu_build.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ if(NOT LLVM_LIBC_FULL_BUILD)
1717
endif()
1818

1919
# Identify the program used to package multiple images into a single binary.
20+
get_filename_component(compiler_path ${CMAKE_CXX_COMPILER} DIRECTORY)
2021
find_program(LIBC_CLANG_OFFLOAD_PACKAGER
2122
NAMES clang-offload-packager NO_DEFAULT_PATH
22-
PATHS ${LLVM_BINARY_DIR}/bin)
23+
PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path})
2324
if(NOT LIBC_CLANG_OFFLOAD_PACKAGER)
2425
message(FATAL_ERROR "Cannot find the 'clang-offload-packager' for the GPU "
2526
"build")
@@ -45,7 +46,7 @@ elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
4546
# Using 'check_cxx_compiler_flag' does not work currently due to the link job.
4647
find_program(LIBC_NVPTX_ARCH
4748
NAMES nvptx-arch NO_DEFAULT_PATH
48-
PATHS ${LLVM_BINARY_DIR}/bin)
49+
PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path})
4950
if(LIBC_NVPTX_ARCH)
5051
execute_process(COMMAND ${LIBC_NVPTX_ARCH}
5152
OUTPUT_VARIABLE arch_tool_output

0 commit comments

Comments
 (0)