summarylogtreecommitdiffstats
path: root/0001-Fix-LTO-build-for-ROCm-when-default-compiler-is-GCC.patch
blob: 050f726796352e31873b89fd3958af9c01886a44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From 306e5545261b7d71557a80a45c1f889e7539d3ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?D=C4=81vis=20Mos=C4=81ns?=
Date: Wed, 29 Apr 2026 22:37:01 +0300
Subject: [PATCH] Fix LTO build for ROCm when default compiler is GCC

---
 CMakeLists.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fb8a1d7e1e1..0b6e5d9e060 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -230,6 +230,13 @@ if(VLLM_GPU_LANG STREQUAL "HIP")
   #
   set(CMAKE_${VLLM_GPU_LANG}_FLAGS "${CMAKE_${VLLM_GPU_LANG}_FLAGS} -Wno-unused-result -Wno-unused-value")
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result -Wno-unused-value")
+
+  # When using LTO then *.cpp files must be compiled with same compiler as used linker
+  # So if HIP uses clang linker we also must use it
+  # Otherwise symbols will be missing from .so
+  if (CMAKE_CXX_FLAGS MATCHES "\-flto")
+    set(CMAKE_CXX_COMPILER ${CMAKE_HIP_COMPILER})
+  endif()
 endif()
 
 #
-- 
2.53.0