diff options
author | Joseph Huber <huberjn@outlook.com> | 2024-06-03 13:08:05 -0500 |
---|---|---|
committer | Joseph Huber <huberjn@outlook.com> | 2024-06-03 13:08:51 -0500 |
commit | 2ee7f49addb60f100929d10ad24ebf1743943b0d (patch) | |
tree | 8cf76fcff4312c17682ae89e024bb3a0c444db6d /libc | |
parent | 2bc098b8aba089fe8328b3b8a8b6b6816cd5a908 (diff) | |
download | llvm-2ee7f49addb60f100929d10ad24ebf1743943b0d.zip llvm-2ee7f49addb60f100929d10ad24ebf1743943b0d.tar.gz llvm-2ee7f49addb60f100929d10ad24ebf1743943b0d.tar.bz2 |
[libc] Correctly find LLVM binaries when built in projects mode for GPU
Summary:
You can build the GPU libc support in projects mode. There were some
issues with it not finding the correct binaries. This patch fixes that.
Diffstat (limited to 'libc')
-rw-r--r-- | libc/cmake/modules/prepare_libc_gpu_build.cmake | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/libc/cmake/modules/prepare_libc_gpu_build.cmake b/libc/cmake/modules/prepare_libc_gpu_build.cmake index 88538ca..dc8beb1 100644 --- a/libc/cmake/modules/prepare_libc_gpu_build.cmake +++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake @@ -18,20 +18,28 @@ 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 ${compiler_path}) -if(NOT LIBC_CLANG_OFFLOAD_PACKAGER) - message(FATAL_ERROR "Cannot find the 'clang-offload-packager' for the GPU " - "build") +if(TARGET clang-offload-packager) + get_target_property(LIBC_CLANG_OFFLOAD_PACKAGER clang-offload-packager LOCATION) +else() + find_program(LIBC_CLANG_OFFLOAD_PACKAGER + NAMES clang-offload-packager NO_DEFAULT_PATH + 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") + endif() endif() # Identify llvm-link program so we can merge the output IR into a single blob. -find_program(LIBC_LLVM_LINK - NAMES llvm-link NO_DEFAULT_PATH - PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path}) -if(NOT LIBC_LLVM_LINK) - message(FATAL_ERROR "Cannot find 'llvm-link' for the GPU build") +if(TARGET llvm-link) + get_target_property(LIBC_LLVM_LINK llvm-link LOCATION) +else() + find_program(LIBC_LLVM_LINK + NAMES llvm-link NO_DEFAULT_PATH + PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path}) + if(NOT LIBC_LLVM_LINK) + message(FATAL_ERROR "Cannot find 'llvm-link' for the GPU build") + endif() endif() # Optionally set up a job pool to limit the number of GPU tests run in parallel. @@ -48,10 +56,14 @@ endif() set(LIBC_GPU_TEST_ARCHITECTURE "" CACHE STRING "Architecture for the GPU tests") if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU) - # Identify any locally installed NVIDIA GPUs on the system using 'nvptx-arch'. - find_program(LIBC_AMDGPU_ARCH - NAMES amdgpu-arch NO_DEFAULT_PATH - PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path}) + # Identify any locally installed AMD GPUs on the system using 'amdgpu-arch'. + if(TARGET amdgpu-arch) + get_target_property(LIBC_AMDGPU_ARCH amdgpu-arch LOCATION) + else() + find_program(LIBC_AMDGPU_ARCH + NAMES amdgpu-arch NO_DEFAULT_PATH + PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path}) + endif() if(LIBC_AMDGPU_ARCH) execute_process(COMMAND ${LIBC_AMDGPU_ARCH} OUTPUT_VARIABLE arch_tool_output @@ -62,9 +74,13 @@ if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU) endif() elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX) # Identify any locally installed NVIDIA GPUs on the system using 'nvptx-arch'. - find_program(LIBC_NVPTX_ARCH - NAMES nvptx-arch NO_DEFAULT_PATH - PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path}) + if(TARGET nvptx-arch) + get_target_property(LIBC_NVPTX_ARCH nvptx-arch LOCATION) + else() + find_program(LIBC_NVPTX_ARCH + NAMES nvptx-arch NO_DEFAULT_PATH + PATHS ${LLVM_BINARY_DIR}/bin ${compiler_path}) + endif() if(LIBC_NVPTX_ARCH) execute_process(COMMAND ${LIBC_NVPTX_ARCH} OUTPUT_VARIABLE arch_tool_output |