Skip to content

Commit 0b3f4e7

Browse files
authored
[SYCL][CMake][MSVC] Fix link.exe /OPT detection (#16811)
CMake's check_linker_flag does no split flags by spaces, so the current call passes the single option `"/OPT:REF LINKER:/OPT:ICF"` with a space in it to link.exe. (The first `LINKER:` prefix is parsed). This was also broken before ede906c ([CMake][MSVC] Wrap more Linker flags for ICX (#16284)), where it would pass `"/OPT:REF /OPT:ICF"` as a single option. This results in the check failing and so the build does not ever enable these flags, even though they would be supported if the check was correct. Use comma as the separator as supported by the `LINKER:` syntax to fix it.
1 parent 5afb184 commit 0b3f4e7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ if(MSVC)
7575
add_link_options("LINKER:/DEBUG")
7676

7777
# Enable unreferenced removal and ICF in Release mode.
78-
check_linker_flag(CXX "LINKER:/OPT:REF LINKER:/OPT:ICF" LINKER_SUPPORTS_OPTS)
78+
check_linker_flag(CXX "LINKER:/OPT:REF,/OPT:ICF" LINKER_SUPPORTS_OPTS)
7979
if (LINKER_SUPPORTS_OPTS AND uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
8080
add_link_options("LINKER:/OPT:REF" "LINKER:/OPT:ICF")
8181
endif()

0 commit comments

Comments
 (0)