Skip to content

Commit c354ee8

Browse files
authored
[libc][GPU] Fix dependencies for externally installed stub files (#66653)
Summary: The GPU build has a lot of magic around how we package the output. Generally, the GPU needs to exist as a secondary fatbinary image for offloading languages. This is because offloading languages pretend like offloading to an accelerator is a single file. This then needs to be put into a single file to make it mesh with the existing build infrastructure. To work with this, the `libc` makes an installed version of the library that simply embeds the GPU code into an empty stub file. This wasn't being updated correctly, which lead to the installed `libc` static library not being updated correctly when the underlying file was changed. The previous behaviour only updated when the entrypoint itself was modified, but not any of its headers. By adding a dependcy on the actual *object* file we should now capture the regular CMake semantics.
1 parent e2733a6 commit c354ee8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libc/cmake/modules/LLVMLibCObjectRules.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function(_build_gpu_objects fq_target_name internal_target_name)
210210
list(APPEND packager_images
211211
--image=file=${input_file},arch=${gpu_arch},triple=${gpu_target_triple})
212212
endif()
213-
list(APPEND gpu_target_names ${gpu_target_name})
213+
list(APPEND gpu_target_objects ${input_file})
214214
endforeach()
215215

216216
# After building the target for the desired GPUs we must package the output
@@ -222,7 +222,7 @@ function(_build_gpu_objects fq_target_name internal_target_name)
222222
add_custom_command(OUTPUT ${packaged_output_name}
223223
COMMAND ${LIBC_CLANG_OFFLOAD_PACKAGER}
224224
${packager_images} -o ${packaged_output_name}
225-
DEPENDS ${gpu_target_names} ${add_gpu_obj_src} ${ADD_GPU_OBJ_HDRS}
225+
DEPENDS ${gpu_target_objects} ${add_gpu_obj_src} ${ADD_GPU_OBJ_HDRS}
226226
COMMENT "Packaging LLVM offloading binary")
227227
add_custom_target(${packaged_target_name} DEPENDS ${packaged_output_name})
228228
list(APPEND packaged_gpu_names ${packaged_target_name})
@@ -242,7 +242,7 @@ function(_build_gpu_objects fq_target_name internal_target_name)
242242
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/stubs/${stub_filename}"
243243
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/stubs/
244244
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/stubs/${stub_filename}
245-
DEPENDS ${gpu_target_names} ${ADD_GPU_OBJ_SRCS} ${ADD_GPU_OBJ_HDRS}
245+
DEPENDS ${gpu_target_objects} ${ADD_GPU_OBJ_SRCS} ${ADD_GPU_OBJ_HDRS}
246246
)
247247
set(stub_target_name ${fq_target_name}.__stub__)
248248
add_custom_target(${stub_target_name} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/stubs/${stub_filename})

0 commit comments

Comments
 (0)