mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-12 17:57:38 +00:00
Merged PR 5805461: Add ARM64X forwarder libs
Add ARM64X implementation libs, to be forwarded to by the ARM64X lib.
From Ben Niu:
For system dlls that are built outside of windows repo and ingested through vpacks or binary check-ins, we always start by trying to port them to ARM64X. However, due to immature support for ARM64X build from Visual Studio 2019, it could be quite uphill to port dlls to ARM64X.
When that happens, we have an alternative without porting the dll to ARM64X. The alternative solution is, we build an ARM64X pure forwarder from windows repo, for example, onnxruntime.dll. That forwarder does nothing but forwards all the ARM64 API calls to a native ARM64 onnxruntime_arm64.dll, and all the x64 APIs to native x64 onnxruntime_amd64.dll. Please see here for an example: 29ae6ca516
At load time, applications still loads the ARM64X forwarder onnxruntime.dll. In an ARM64 process, that forwarder dll will further load the native ARM64 onnxruntime_arm64.dll; otherwise, the x64 onnxruntime_amd64.dll will be loaded, both the ARM64 and x64 dlls are happy.
The onnxruntime_arm64.dll and onnxruntime_amd64.dll are essentially aliases of their native counterparts, but we cannot directly rename existing native dlls in windows build. The reason is about PDB binplacing. If you simply rename a dll, the PDB name embedded in the dll is still unchanged. So you can imagine that if we just rename the native dlls in ARM64 windows build, there will be two renamed native dlls, onnxruntime_arm64.dll and onnxruntime_amd64.dll, sharing the same PDB name onnxruntime.pdb. When binplacing happens (basically moving dll and pdb from os\obj to os\bin), one PDB will overwrite the other. As a result, we either lose the PDB for the ARM64 dll, or the x64 dll.
That’s why we are asking to change the build pipeline to execute the link commands two extra times to produce onnxruntime_arm64/amd64.dll with different pdb names. You don’t need to do the compilation twice, but just the link. See here for an example: https://microsoft.visualstudio.com/DefaultCollection/Xbox/_git/Xbox.ShaderCompiler.WinTools/pullrequest/5291717
Related work items: #31925159
This commit is contained in:
commit
934bb52cfb
1 changed files with 29 additions and 0 deletions
|
|
@ -828,3 +828,32 @@ endif()
|
|||
# However, there are no cuda imports in winml_dll, and the linker throws the 4199 warning.
|
||||
# This is needed to allow winml_dll build with cuda enabled.
|
||||
target_link_options(winml_dll PRIVATE /ignore:4199)
|
||||
|
||||
if (winml_is_inbox)
|
||||
# Link *_x64/*_arm64 DLLs for the ARM64X forwarder
|
||||
function(duplicate_shared_library target new_target)
|
||||
get_target_property(sources ${target} SOURCES)
|
||||
get_target_property(compile_definitions ${target} COMPILE_DEFINITIONS)
|
||||
get_target_property(compile_options ${target} COMPILE_OPTIONS)
|
||||
get_target_property(include_directories ${target} INCLUDE_DIRECTORIES)
|
||||
get_target_property(link_libraries ${target} LINK_LIBRARIES)
|
||||
|
||||
add_library(${new_target} SHARED ${sources})
|
||||
add_dependencies(${target} ${new_target})
|
||||
target_compile_definitions(${new_target} PRIVATE ${compile_definitions})
|
||||
target_compile_options(${new_target} PRIVATE ${compile_options})
|
||||
target_include_directories(${new_target} PRIVATE ${include_directories})
|
||||
target_link_libraries(${new_target} PRIVATE ${link_libraries})
|
||||
endfunction()
|
||||
|
||||
if (WAI_ARCH STREQUAL x64 OR WAI_ARCH STREQUAL arm64)
|
||||
if (TARGET winml_dll)
|
||||
duplicate_shared_library(winml_dll Windows_AI_MachineLearning_${WAI_ARCH})
|
||||
target_compile_features(Windows_AI_MachineLearning_${WAI_ARCH} PRIVATE cxx_std_17)
|
||||
target_precompiled_header(Windows_AI_MachineLearning_${WAI_ARCH} pch.h)
|
||||
endif()
|
||||
if (TARGET onnxruntime)
|
||||
duplicate_shared_library(onnxruntime onnxruntime_${WAI_ARCH})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Reference in a new issue