From: Joseph Huber Date: Wed, 29 Mar 2023 19:19:08 +0000 (-0500) Subject: [libc] Use LTO for AMDGPU compilation and linking X-Git-Tag: upstream/17.0.6~13284 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2dc60b4ea4f1a3f321ea93055038d711f0af4c49;p=platform%2Fupstream%2Fllvm.git [libc] Use LTO for AMDGPU compilation and linking 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. --- diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake index b3503a9..289612b 100644 --- a/libc/cmake/modules/LLVMLibCObjectRules.cmake +++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake @@ -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() diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index 4e1a63d..0e1b9f1 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -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