Skip to content

Commit

Permalink
[SYCL][CMake][MSVC] Fix link.exe /OPT detection (#16811)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Maetveis authored Jan 29, 2025
1 parent 5afb184 commit 0b3f4e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if(MSVC)
add_link_options("LINKER:/DEBUG")

# Enable unreferenced removal and ICF in Release mode.
check_linker_flag(CXX "LINKER:/OPT:REF LINKER:/OPT:ICF" LINKER_SUPPORTS_OPTS)
check_linker_flag(CXX "LINKER:/OPT:REF,/OPT:ICF" LINKER_SUPPORTS_OPTS)
if (LINKER_SUPPORTS_OPTS AND uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
add_link_options("LINKER:/OPT:REF" "LINKER:/OPT:ICF")
endif()
Expand Down

0 comments on commit 0b3f4e7

Please sign in to comment.