[Build] Show error message when using ROCm with LTO and different compilers (#35232)

Dāvis committed Jun 27, 2026 at 05:43 UTC 1a92dfcce4a9433d002631207b5b01e2e95f1077
1 file changed +10
CMakeLists.txt
+10
@@ -270,6 +270,16 @@ if(VLLM_GPU_LANG STREQUAL "HIP")
270 #
271 set(CMAKE_${VLLM_GPU_LANG}_FLAGS "${CMAKE_${VLLM_GPU_LANG}_FLAGS} -Wno-unused-result -Wno-unused-value")
272 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result -Wno-unused-value")
273 +
274 + # When using LTO then *.cpp files must be compiled with same compiler as used linker
275 + # So if HIP uses clang linker we also must use it
276 + # Otherwise symbols will be missing from .so
277 + if (CMAKE_CXX_FLAGS MATCHES "\-flto")
278 + if(NOT CMAKE_CXX_COMPILER_ID STREQUAL CMAKE_HIP_COMPILER_ID)
279 + message(FATAL_ERROR "LTO is enabled for ROCm build, but the C++ compiler (${CMAKE_CXX_COMPILER_ID}) and HIP compiler (${CMAKE_HIP_COMPILER_ID}) are different which is not supported. "
280 + "Please ensure they are same by setting CXX=${CMAKE_HIP_COMPILER} environment variable. Or alternatively disable LTO.")
281 + endif()
282 + endif()
283 endif()
284
285 #