Skip to content

Commit 9194cad

Browse files
Fix version info for onnxruntime.dll and QNN, TensorRT, and CUDA EP dlls (#24606)
### Description Fixes #24500 - Fixes local build of onnxruntime.dll to have a valid version, such as "1.23.0", instead of the literal string "ORT_VERSION" - Adds version info to onnxruntime_providers_qnn.dll, onnxruntime_providers_cuda.dll, and onnxruntime_providers_tensorrt.dll. It was missing completely. This was done by adding `onnxruntime_providers_*.rc` files to define each EP's [DLL version info](https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource). Fixed onnxruntime.dll version info (local non-ADO build): <img width="263" alt="image" src="https://github.com/user-attachments/assets/33ef85ea-ac36-4c6a-9171-8fe4fb35955d" /> Fixed onnxruntime_providers_qnn.dll version info (adds QNN SDK version too): <img width="275" alt="image" src="https://github.com/user-attachments/assets/a1f04604-2e3c-416d-989e-e92cb7df1776" /> ### Motivation and Context We create dlls with invalid or missing version info.
1 parent 72ec0e8 commit 9194cad

File tree

8 files changed

+224
-12
lines changed

8 files changed

+224
-12
lines changed

cmake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ if(VERSION_MAJOR_PART STREQUAL "0" AND VERSION_MINOR_PART STREQUAL "0" AND VERSI
17341734
list(GET ORT_VERSION_STRING_LIST 0 VERSION_MAJOR_PART)
17351735
list(GET ORT_VERSION_STRING_LIST 1 VERSION_MINOR_PART)
17361736
list(GET ORT_VERSION_STRING_LIST 2 VERSION_BUILD_PART)
1737-
set(VERSION_STRING ORT_VERSION)
1737+
set(VERSION_STRING ${ORT_VERSION})
17381738
endif()
17391739

17401740

cmake/onnxruntime_providers_cuda.cmake

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,38 @@
122122
if (onnxruntime_REDUCED_OPS_BUILD)
123123
substitute_op_reduction_srcs(onnxruntime_providers_cuda_src)
124124
endif()
125+
125126
if(onnxruntime_ENABLE_CUDA_EP_INTERNAL_TESTS)
126127
# cuda_provider_interface.cc is removed from the object target: onnxruntime_providers_cuda_obj and
127128
# added to the lib onnxruntime_providers_cuda separately.
128129
# onnxruntime_providers_cuda_ut can share all the object files with onnxruntime_providers_cuda except cuda_provider_interface.cc.
129130
set(cuda_provider_interface_src ${ONNXRUNTIME_ROOT}/core/providers/cuda/cuda_provider_interface.cc)
130131
list(REMOVE_ITEM onnxruntime_providers_cuda_src ${cuda_provider_interface_src})
131132
onnxruntime_add_object_library(onnxruntime_providers_cuda_obj ${onnxruntime_providers_cuda_src})
132-
onnxruntime_add_shared_library_module(onnxruntime_providers_cuda ${cuda_provider_interface_src} $<TARGET_OBJECTS:onnxruntime_providers_cuda_obj>)
133+
134+
set(onnxruntime_providers_cuda_all_srcs ${cuda_provider_interface_src})
135+
if(WIN32)
136+
# Sets the DLL version info on Windows: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
137+
list(APPEND onnxruntime_providers_cuda_all_srcs "${ONNXRUNTIME_ROOT}/core/providers/cuda/onnxruntime_providers_cuda.rc")
138+
endif()
139+
140+
onnxruntime_add_shared_library_module(onnxruntime_providers_cuda ${onnxruntime_providers_cuda_all_srcs}
141+
$<TARGET_OBJECTS:onnxruntime_providers_cuda_obj>)
133142
else()
134-
onnxruntime_add_shared_library_module(onnxruntime_providers_cuda ${onnxruntime_providers_cuda_src})
143+
set(onnxruntime_providers_cuda_all_srcs ${onnxruntime_providers_cuda_src})
144+
if(WIN32)
145+
# Sets the DLL version info on Windows: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
146+
list(APPEND onnxruntime_providers_cuda_all_srcs "${ONNXRUNTIME_ROOT}/core/providers/cuda/onnxruntime_providers_cuda.rc")
147+
endif()
148+
149+
onnxruntime_add_shared_library_module(onnxruntime_providers_cuda ${onnxruntime_providers_cuda_all_srcs})
150+
endif()
151+
152+
if(WIN32)
153+
# FILE_NAME preprocessor definition is used in onnxruntime_providers_cuda.rc
154+
target_compile_definitions(onnxruntime_providers_cuda PRIVATE FILE_NAME=\"onnxruntime_providers_cuda.dll\")
135155
endif()
156+
136157
# config_cuda_provider_shared_module can be used to config onnxruntime_providers_cuda_obj, onnxruntime_providers_cuda & onnxruntime_providers_cuda_ut.
137158
# This function guarantees that all 3 targets have the same configurations.
138159
function(config_cuda_provider_shared_module target)

cmake/onnxruntime_providers_qnn.cmake

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@
1313
"${ONNXRUNTIME_ROOT}/core/providers/qnn/*.cc"
1414
)
1515

16+
function(extract_qnn_sdk_version_from_yaml QNN_SDK_YAML_FILE QNN_VERSION_OUTPUT)
17+
file(READ "${QNN_SDK_YAML_FILE}" QNN_SDK_YAML_CONTENT)
18+
# Match a line of text like "version: 1.33.2"
19+
string(REGEX MATCH "(^|\n|\r)version: ([0-9]+\\.[0-9]+\\.[0-9]+)" QNN_VERSION_MATCH "${QNN_SDK_YAML_CONTENT}")
20+
if(QNN_VERSION_MATCH)
21+
set(${QNN_VERSION_OUTPUT} "${CMAKE_MATCH_2}" PARENT_SCOPE)
22+
message(STATUS "Extracted QNN SDK version ${CMAKE_MATCH_2} from ${QNN_SDK_YAML_FILE}")
23+
else()
24+
message(WARNING "Failed to extract QNN SDK version from ${QNN_SDK_YAML_FILE}")
25+
endif()
26+
endfunction()
27+
28+
if(NOT QNN_SDK_VERSION)
29+
if(EXISTS "${onnxruntime_QNN_HOME}/sdk.yaml")
30+
extract_qnn_sdk_version_from_yaml("${onnxruntime_QNN_HOME}/sdk.yaml" QNN_SDK_VERSION)
31+
else()
32+
message(WARNING "Cannot open sdk.yaml to extract QNN SDK version")
33+
endif()
34+
endif()
35+
message(STATUS "QNN SDK version ${QNN_SDK_VERSION}")
36+
1637
if(onnxruntime_BUILD_QNN_EP_STATIC_LIB)
1738
#
1839
# Build QNN EP as a static library
@@ -23,7 +44,7 @@
2344
onnxruntime_add_include_to_target(onnxruntime_providers_qnn onnxruntime_common onnxruntime_framework onnx
2445
onnx_proto protobuf::libprotobuf-lite
2546
flatbuffers::flatbuffers Boost::mp11
26-
nlohmann_json::nlohmann_json)
47+
nlohmann_json::nlohmann_json)
2748
add_dependencies(onnxruntime_providers_qnn onnx ${onnxruntime_EXTERNAL_DEPENDENCIES})
2849
set_target_properties(onnxruntime_providers_qnn PROPERTIES CXX_STANDARD_REQUIRED ON)
2950
set_target_properties(onnxruntime_providers_qnn PROPERTIES FOLDER "ONNXRuntime")
@@ -61,20 +82,39 @@
6182
"${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.cc"
6283
)
6384
set(onnxruntime_providers_qnn_srcs ${onnxruntime_providers_qnn_ep_srcs}
64-
${onnxruntime_providers_qnn_shared_lib_srcs})
85+
${onnxruntime_providers_qnn_shared_lib_srcs})
6586

6687
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_qnn_srcs})
67-
onnxruntime_add_shared_library_module(onnxruntime_providers_qnn ${onnxruntime_providers_qnn_srcs})
88+
89+
set(onnxruntime_providers_qnn_all_srcs ${onnxruntime_providers_qnn_srcs})
90+
if(WIN32)
91+
# Sets the DLL version info on Windows: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
92+
list(APPEND onnxruntime_providers_qnn_all_srcs "${ONNXRUNTIME_ROOT}/core/providers/qnn/onnxruntime_providers_qnn.rc")
93+
endif()
94+
95+
onnxruntime_add_shared_library_module(onnxruntime_providers_qnn ${onnxruntime_providers_qnn_all_srcs})
6896
onnxruntime_add_include_to_target(onnxruntime_providers_qnn ${ONNXRUNTIME_PROVIDERS_SHARED} ${GSL_TARGET} onnx
69-
onnxruntime_common Boost::mp11 safeint_interface
70-
nlohmann_json::nlohmann_json)
97+
onnxruntime_common Boost::mp11 safeint_interface
98+
nlohmann_json::nlohmann_json)
7199
target_link_libraries(onnxruntime_providers_qnn PRIVATE ${ONNXRUNTIME_PROVIDERS_SHARED} ${ABSEIL_LIBS} ${CMAKE_DL_LIBS})
72100
add_dependencies(onnxruntime_providers_qnn onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
73101
target_include_directories(onnxruntime_providers_qnn PRIVATE ${ONNXRUNTIME_ROOT}
74102
${CMAKE_CURRENT_BINARY_DIR}
75103
${onnxruntime_QNN_HOME}/include/QNN
76104
${onnxruntime_QNN_HOME}/include)
77105

106+
# Set preprocessor definitions used in onnxruntime_providers_qnn.rc
107+
if(WIN32)
108+
if(NOT QNN_SDK_VERSION)
109+
set(QNN_DLL_FILE_DESCRIPTION "ONNX Runtime QNN Provider")
110+
else()
111+
set(QNN_DLL_FILE_DESCRIPTION "ONNX Runtime QNN Provider (QAIRT ${QNN_SDK_VERSION})")
112+
endif()
113+
114+
target_compile_definitions(onnxruntime_providers_qnn PRIVATE FILE_DESC=\"${QNN_DLL_FILE_DESCRIPTION}\")
115+
target_compile_definitions(onnxruntime_providers_qnn PRIVATE FILE_NAME=\"onnxruntime_providers_qnn.dll\")
116+
endif()
117+
78118
# Set linker flags for function(s) exported by EP DLL
79119
if(UNIX)
80120
target_link_options(onnxruntime_providers_qnn PRIVATE
@@ -120,4 +160,4 @@
120160
COMMAND ${CMAKE_COMMAND} -E copy "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf" $<TARGET_FILE_DIR:${onnxruntime_providers_qnn_target}>
121161
)
122162
endif()
123-
endif()
163+
endif()

cmake/onnxruntime_providers_tensorrt.cmake

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,14 @@
166166
)
167167

168168
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_tensorrt_cc_srcs})
169-
onnxruntime_add_shared_library_module(onnxruntime_providers_tensorrt ${onnxruntime_providers_tensorrt_cc_srcs})
169+
170+
set(onnxruntime_providers_tensorrt_all_srcs ${onnxruntime_providers_tensorrt_cc_srcs})
171+
if(WIN32)
172+
# Sets the DLL version info on Windows: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
173+
list(APPEND onnxruntime_providers_tensorrt_all_srcs "${ONNXRUNTIME_ROOT}/core/providers/tensorrt/onnxruntime_providers_tensorrt.rc")
174+
endif()
175+
176+
onnxruntime_add_shared_library_module(onnxruntime_providers_tensorrt ${onnxruntime_providers_tensorrt_all_srcs})
170177
onnxruntime_add_include_to_target(onnxruntime_providers_tensorrt onnxruntime_common)
171178
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE Eigen3::Eigen onnx flatbuffers::flatbuffers Boost::mp11 safeint_interface Eigen3::Eigen)
172179
add_dependencies(onnxruntime_providers_tensorrt onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
@@ -183,6 +190,12 @@
183190
set_target_properties(onnxruntime_providers_tensorrt PROPERTIES FOLDER "ONNXRuntime")
184191
target_compile_definitions(onnxruntime_providers_tensorrt PRIVATE ONNXIFI_BUILD_LIBRARY=1)
185192
target_compile_options(onnxruntime_providers_tensorrt PRIVATE ${DISABLED_WARNINGS_FOR_TRT})
193+
194+
if(WIN32)
195+
# FILE_NAME preprocessor definition is used in onnxruntime_providers_tensorrt.rc
196+
target_compile_definitions(onnxruntime_providers_tensorrt PRIVATE FILE_NAME=\"onnxruntime_providers_tensorrt.dll\")
197+
endif()
198+
186199
if (WIN32)
187200
target_compile_options(onnxruntime_providers_tensorrt INTERFACE /wd4456)
188201
endif()

onnxruntime/core/dll/onnxruntime.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
// This file REQUIRES the following external definitions:
5-
// VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE, and VER_STRING
5+
// FILE_NAME, VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE, and VER_STRING
66

77
#include <Winver.h>
88

@@ -43,4 +43,4 @@ BEGIN
4343
BEGIN
4444
VALUE "Translation", 0x409, 1252
4545
END
46-
END
46+
END
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// This file REQUIRES the following external definitions:
5+
// FILE_NAME, VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE, and VER_STRING
6+
7+
#include <Winver.h>
8+
9+
#if defined(DEBUG) || defined(_DEBUG)
10+
#define VER_DEBUG VS_FF_DEBUG
11+
#else
12+
#define VER_DEBUG 0
13+
#endif
14+
15+
// -----------------------------------------------------------------------------
16+
17+
VS_VERSION_INFO VERSIONINFO
18+
FILEVERSION VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE
19+
PRODUCTVERSION VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE
20+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
21+
FILEFLAGS VER_DEBUG
22+
FILEOS VOS__WINDOWS32
23+
FILETYPE VFT_DLL
24+
FILESUBTYPE VFT2_UNKNOWN
25+
26+
BEGIN
27+
BLOCK "StringFileInfo"
28+
BEGIN
29+
BLOCK "040904E4"
30+
BEGIN
31+
VALUE "CompanyName", "Microsoft Corporation"
32+
VALUE "FileDescription", "ONNX Runtime CUDA Provider"
33+
VALUE "FileVersion", VER_STRING
34+
VALUE "InternalName", "ONNX Runtime CUDA Provider"
35+
VALUE "LegalCopyright", "\251 Microsoft Corporation. All rights reserved."
36+
VALUE "OriginalFilename", FILE_NAME
37+
VALUE "ProductName", "Microsoft\256 Windows\256 Operating System"
38+
VALUE "ProductVersion", VER_STRING
39+
END
40+
END
41+
42+
BLOCK "VarFileInfo"
43+
BEGIN
44+
VALUE "Translation", 0x409, 1252
45+
END
46+
END
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// This file REQUIRES the following external definitions:
5+
// FILE_DESC, FILE_NAME, VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE, and VER_STRING
6+
7+
#include <Winver.h>
8+
9+
#if defined(DEBUG) || defined(_DEBUG)
10+
#define VER_DEBUG VS_FF_DEBUG
11+
#else
12+
#define VER_DEBUG 0
13+
#endif
14+
15+
// -----------------------------------------------------------------------------
16+
17+
VS_VERSION_INFO VERSIONINFO
18+
FILEVERSION VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE
19+
PRODUCTVERSION VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE
20+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
21+
FILEFLAGS VER_DEBUG
22+
FILEOS VOS__WINDOWS32
23+
FILETYPE VFT_DLL
24+
FILESUBTYPE VFT2_UNKNOWN
25+
26+
BEGIN
27+
BLOCK "StringFileInfo"
28+
BEGIN
29+
BLOCK "040904E4"
30+
BEGIN
31+
VALUE "CompanyName", "Microsoft Corporation"
32+
VALUE "FileDescription", FILE_DESC
33+
VALUE "FileVersion", VER_STRING
34+
VALUE "InternalName", FILE_DESC
35+
VALUE "LegalCopyright", "\251 Microsoft Corporation. All rights reserved."
36+
VALUE "OriginalFilename", FILE_NAME
37+
VALUE "ProductName", "Microsoft\256 Windows\256 Operating System"
38+
VALUE "ProductVersion", VER_STRING
39+
END
40+
END
41+
42+
BLOCK "VarFileInfo"
43+
BEGIN
44+
VALUE "Translation", 0x409, 1252
45+
END
46+
END
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// This file REQUIRES the following external definitions:
5+
// FILE_NAME, VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE, and VER_STRING
6+
7+
#include <Winver.h>
8+
9+
#if defined(DEBUG) || defined(_DEBUG)
10+
#define VER_DEBUG VS_FF_DEBUG
11+
#else
12+
#define VER_DEBUG 0
13+
#endif
14+
15+
// -----------------------------------------------------------------------------
16+
17+
VS_VERSION_INFO VERSIONINFO
18+
FILEVERSION VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE
19+
PRODUCTVERSION VER_MAJOR, VER_MINOR, VER_BUILD, VER_PRIVATE
20+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
21+
FILEFLAGS VER_DEBUG
22+
FILEOS VOS__WINDOWS32
23+
FILETYPE VFT_DLL
24+
FILESUBTYPE VFT2_UNKNOWN
25+
26+
BEGIN
27+
BLOCK "StringFileInfo"
28+
BEGIN
29+
BLOCK "040904E4"
30+
BEGIN
31+
VALUE "CompanyName", "Microsoft Corporation"
32+
VALUE "FileDescription", "ONNX Runtime TensorRT Provider"
33+
VALUE "FileVersion", VER_STRING
34+
VALUE "InternalName", "ONNX Runtime TensorRT Provider"
35+
VALUE "LegalCopyright", "\251 Microsoft Corporation. All rights reserved."
36+
VALUE "OriginalFilename", FILE_NAME
37+
VALUE "ProductName", "Microsoft\256 Windows\256 Operating System"
38+
VALUE "ProductVersion", VER_STRING
39+
END
40+
END
41+
42+
BLOCK "VarFileInfo"
43+
BEGIN
44+
VALUE "Translation", 0x409, 1252
45+
END
46+
END

0 commit comments

Comments
 (0)