Skip to content

Commit ef5bfb8

Browse files
[SYCL][CMake] Add an option to enable IPO for runtime builds (#20548)
1 parent ffde618 commit ef5bfb8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

sycl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ option(SYCL_ADD_DEV_VERSION_POSTFIX "Adds -V postfix to version string" ON)
1111
option(SYCL_ENABLE_COVERAGE "Enables code coverage for runtime and unit tests" OFF)
1212
option(SYCL_ENABLE_STACK_PRINTING "Enables stack printing on crashes of SYCL applications" OFF)
1313
option(SYCL_LIB_WITH_DEBUG_SYMBOLS "Builds SYCL runtime libraries with debug symbols" OFF)
14+
option(SYCL_ENABLE_IPO "Builds SYCL runtime libraries with interprocedural optimization" OFF)
1415

1516
if (NOT SYCL_COVERAGE_PATH)
1617
set(SYCL_COVERAGE_PATH "${CMAKE_CURRENT_BINARY_DIR}/profiles")

sycl/source/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#cmake_policy(SET CMP0057 NEW)
55
#include(AddLLVM)
66
include(CheckLinkerFlag)
7+
include(CheckIPOSupported)
78
configure_file(
89
${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in
910
${CMAKE_CURRENT_BINARY_DIR}/version.rc
@@ -16,13 +17,24 @@ if (SYCL_ENABLE_XPTI_TRACING)
1617
include_directories(${LLVM_EXTERNAL_XPTI_SOURCE_DIR}/include)
1718
endif()
1819

20+
if(SYCL_ENABLE_IPO)
21+
check_ipo_supported(RESULT SYCL_USE_IPO)
22+
if (NOT SYCL_USE_IPO)
23+
message(WARNING "Interprocedural optimization is not supported by the compiler, disabling")
24+
endif()
25+
endif()
26+
1927
function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)
2028
# Add an optional argument so we can get the library name to
2129
# link with for Windows Debug version
2230
cmake_parse_arguments(ARG "" "XPTI_LIB;IMPLIB_NAME" "COMPILE_OPTIONS;SOURCES" ${ARGN})
2331

2432
add_library(${LIB_OBJ_NAME} OBJECT ${ARG_SOURCES})
2533

34+
if(SYCL_USE_IPO)
35+
set_property(TARGET ${LIB_OBJ_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
36+
endif()
37+
2638
# Common compilation step setup
2739

2840
check_cxx_compiler_flag(-Winstantiation-after-specialization
@@ -79,6 +91,10 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)
7991
$<TARGET_OBJECTS:${LIB_OBJ_NAME}>
8092
${CMAKE_CURRENT_BINARY_DIR}/version.rc)
8193

94+
if(SYCL_USE_IPO)
95+
set_property(TARGET ${LIB_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
96+
endif()
97+
8298
find_package(Threads REQUIRED)
8399

84100
target_link_libraries(${LIB_NAME}

0 commit comments

Comments
 (0)