Skip to content

[SYCL] Add delayloading for ze_loader #11902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 5, 2023
6 changes: 5 additions & 1 deletion sycl/plugins/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ add_sycl_plugin(level_zero
Threads::Threads
${XPTI_LIBS}
)

add_dependencies(pi_level_zero ze-api)

if (WIN32)
target_link_libraries(pi_level_zero PRIVATE delayimp)
target_link_options(pi_level_zero PRIVATE /DELAYLOAD:ze_loader.dll)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing LevelZeroLoader to /DELAYLOAD doesn't seem to work, it needs the exact name of the DLL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_link_options supports generator expressions and LevelZeroLoader is a target, try TARGET_FILE like this:

Suggested change
target_link_options(pi_level_zero PRIVATE /DELAYLOAD:ze_loader.dll)
target_link_options(pi_level_zero PRIVATE /DELAYLOAD:$<TARGET_FILE:LevelZeroLoader>)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion @kbenzie! However, i get a build error: Error evaluating generator expression:
$<TARGET_FILE:LevelZeroLoader>
Target "LevelZeroLoader" is not an executable or library.

endif()

if (SYCL_ENABLE_XPTI_TRACING)
target_compile_definitions(pi_level_zero PRIVATE
XPTI_ENABLE_INSTRUMENTATION
Expand Down