Skip to content

Commit 18e4cbb

Browse files
[SYCL] Reenable MSVC linker optimization on release builds (#5030)
The addition of the /DEBUG flag in release build disables some linker optimizations. These changes reenable the linker optimizations. Signed-off-by: Steffen Larsen <[email protected]>
1 parent 790aa8b commit 18e4cbb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sycl/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ if(MSVC)
5757
if(LINKER_SUPPORTS_DEBUG)
5858
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
5959
add_link_options("/DEBUG")
60+
61+
# Enable unreferenced removal and ICF in Release mode.
62+
llvm_check_linker_flag(CXX "/OPT:REF /OPT:ICF" LINKER_SUPPORTS_OPTS)
63+
if (LINKER_SUPPORTS_OPTS AND uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
64+
add_link_options("/OPT:REF" "/OPT:ICF")
65+
endif()
6066
endif()
6167
endif()
6268

0 commit comments

Comments
 (0)