[compiler-rt] [compiler-rt] Add COMPILER_RT_GPU_THIN_LTO to build with -flto=thin (PR #226916)
Wenju He via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 01:03:03 PDT 2026
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/226916
COMPILER_RT_GPU_THIN_LTO option (default: off) allows to build compiler-rt GPU runtime with -flto=thin instead of -flto. ThinLTO Function Import requires runtime libraries to have ThinLTO summaries.
This flag intends to support downstream ThinLTO pipeline for GPU compilation. There is no upstream user of the flag yet.
>From 588a654239794837df56d9987bf629b18dd9cff3 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Mon, 28 Sep 2026 09:46:02 +0200
Subject: [PATCH] [compiler-rt] Add COMPILER_RT_GPU_THIN_LTO to build with
-flto=thin
COMPILER_RT_GPU_THIN_LTO option (default: off) allows to build
compiler-rt GPU runtime with -flto=thin instead of -flto.
ThinLTO Function Import requires runtime libraries to have ThinLTO
summaries.
This flag intends to support downstream ThinLTO pipeline for GPU
compilation. There is no upstream user of the flag yet.
---
compiler-rt/CMakeLists.txt | 8 +++++++-
compiler-rt/cmake/config-ix.cmake | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 0458b17ba38c2..82d7bddb987a4 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -194,6 +194,8 @@ else()
endif()
option(COMPILER_RT_DEBUG "Build runtimes with full debug info" OFF)
+option(COMPILER_RT_GPU_THIN_LTO
+ "Build GPU runtimes with -flto=thin instead of -flto" OFF)
option(COMPILER_RT_EXTERNALIZE_DEBUGINFO
"Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
# COMPILER_RT_DEBUG_PYBOOL is used by lit.common.configured.in.
@@ -397,7 +399,11 @@ if(COMPILER_RT_GPU_BUILD)
append_list_if(UBSAN_COMMON_SUPPORTED_ARCH -ffreestanding SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_NOGPULIB_FLAG -nogpulib SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_NOSTDLIBINC_FLAG -nostdlibinc SANITIZER_COMMON_CFLAGS)
- append_list_if(COMPILER_RT_HAS_FLTO_FLAG -flto SANITIZER_COMMON_CFLAGS)
+ if(COMPILER_RT_GPU_THIN_LTO)
+ append_list_if(COMPILER_RT_HAS_FLTO_THIN_FLAG -flto=thin SANITIZER_COMMON_CFLAGS)
+ else()
+ append_list_if(COMPILER_RT_HAS_FLTO_FLAG -flto SANITIZER_COMMON_CFLAGS)
+ endif()
if(COMPILER_RT_TARGET_AMDGPU)
append_list_if(COMPILER_RT_HAS_CODE_OBJECT_VERSION_FLAG
"SHELL:-Xclang -mcode-object-version=none" SANITIZER_COMMON_CFLAGS)
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index e1abc7eb5c44e..76b32a6a2cab2 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -119,6 +119,7 @@ check_cxx_compiler_flag("-Werror;-ftrivial-auto-var-init=pattern" COMPILER_RT_HA
check_c_compiler_flag(-nogpulib COMPILER_RT_HAS_NOGPULIB_FLAG)
check_c_compiler_flag(-nostdlibinc COMPILER_RT_HAS_NOSTDLIBINC_FLAG)
check_c_compiler_flag(-flto COMPILER_RT_HAS_FLTO_FLAG)
+check_c_compiler_flag(-flto=thin COMPILER_RT_HAS_FLTO_THIN_FLAG)
check_c_compiler_flag("-Xclang;-mcode-object-version=none" COMPILER_RT_HAS_CODE_OBJECT_VERSION_FLAG)
if(NOT WIN32 AND NOT CYGWIN)
More information about the llvm-commits
mailing list