Skip to content

Commit a4f553f

Browse files
committed
[libc] Fix using the libcgpu.a for NVPTX in non-LTO builds
CUDA requires a PTX feature to be compiled generally, because the `libcgpu.a` archive contains LLVM-IR we need to have one present to compile it. Currently, the wrapper fatbinary format we use to incorporate these into single-source offloading languages has a special option to provide this. Since this was not present in the builds, if the user did not specify it via `-foffload-lto` it would not compile from CUDA or OpenMP due to the missing PTX features. Fix this by passing it to the packager invocation. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D154864
1 parent 5942ae8 commit a4f553f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libc/cmake/modules/LLVMLibCObjectRules.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,14 @@ function(_build_gpu_objects fq_target_name internal_target_name)
184184

185185
# Append this target to a list of images to package into a single binary.
186186
set(input_file $<TARGET_OBJECTS:${gpu_target_name}>)
187-
list(APPEND packager_images
188-
--image=file=${input_file},arch=${gpu_arch},triple=${gpu_target_triple})
187+
if("${gpu_arch}" IN_LIST all_nvptx_architectures)
188+
string(REGEX MATCH "\\+ptx[0-9]+" nvptx_ptx_feature ${nvptx_options})
189+
list(APPEND packager_images
190+
--image=file=${input_file},arch=${gpu_arch},triple=${gpu_target_triple},feature=${nvptx_ptx_feature})
191+
else()
192+
list(APPEND packager_images
193+
--image=file=${input_file},arch=${gpu_arch},triple=${gpu_target_triple})
194+
endif()
189195
list(APPEND gpu_target_names ${gpu_target_name})
190196
endforeach()
191197

0 commit comments

Comments
 (0)