Skip to content

Link delayimp.lib for onnxruntime_pybind11_state when delay-loading is enabled - #31637

Open
jnagi-intel wants to merge 1 commit into
microsoft:mainfrom
jnagi-intel:fix/pybind11-delayload-missing-delayimp-lib
Open

Link delayimp.lib for onnxruntime_pybind11_state when delay-loading is enabled #31637
jnagi-intel wants to merge 1 commit into
microsoft:mainfrom
jnagi-intel:fix/pybind11-delayload-missing-delayimp-lib

Conversation

@jnagi-intel

Copy link
Copy Markdown
Contributor

Description

Add target_link_libraries(onnxruntime_pybind11_state PRIVATE delayimp.lib),
guarded on onnxruntime_DELAYLOAD_FLAGS being non-empty, matching the existing
pattern in onnxruntime.cmake, onnxruntime_providers_webgpu.cmake, and
onnxruntime_providers_dml.cmake.

Motivation and Context

target_link_options() sets /DELAYLOAD: flags for onnxruntime_pybind11_state
via onnxruntime_DELAYLOAD_FLAGS (e.g. /DELAYLOAD:shell32.dll), but nothing links
delayimp.lib to resolve __delayLoadHelper2 for this target.

Under the Visual Studio/MSBuild generator this is masked because
Microsoft.Cpp.targets auto-adds delayimp.lib whenever /DELAYLOAD is used. Ninja
has no such implicit behavior, so building the Python bindings with -G Ninja and
onnxruntime_ENABLE_DELAY_LOADING_WIN_DLLS=ON (the WIN32 default) fails with:
LNK2001: unresolved external symbol __delayLoadHelper2

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant