Skip to content

Commit

Permalink
[libc] Use LTO for AMDGPU compilation and linking
Browse files Browse the repository at this point in the history
Summary:
The AMDGPU ABI isn't stable or well defined. For that reson we prefer to
rely on LTO to ensure that multiple files get linked correctly.
Currently the internal targets used for testing mix LLVM-IR and
assembly. We should be consistent here.
  • Loading branch information
jhuber6 committed Mar 29, 2023
1 parent 389e93c commit 2dc60b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libc/cmake/modules/LLVMLibCObjectRules.cmake
Expand Up @@ -193,7 +193,7 @@ function(_build_gpu_objects fq_target_name internal_target_name)
target_compile_options(${internal_target_name} BEFORE PRIVATE
${common_compile_options} --target=${LIBC_GPU_TARGET_TRIPLE})
if(LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU)
target_compile_options(${internal_target_name} PRIVATE -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE})
target_compile_options(${internal_target_name} PRIVATE -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto)
elseif(LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
target_compile_options(${internal_target_name} PRIVATE -march=${LIBC_GPU_TARGET_ARCHITECTURE})
endif()
Expand Down
2 changes: 1 addition & 1 deletion libc/cmake/modules/LLVMLibCTestRules.cmake
Expand Up @@ -503,7 +503,7 @@ function(add_integration_test test_name)
# The GPU build requires overriding the default CMake triple and architecture.
if(LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU)
target_compile_options(${fq_build_target_name} PRIVATE
-mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -emit-llvm
-mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto
--target=${LIBC_GPU_TARGET_TRIPLE})
elseif(LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
target_compile_options(${fq_build_target_name} PRIVATE
Expand Down

0 comments on commit 2dc60b4

Please sign in to comment.