Skip to content

Commit 6506173

Browse files
committed
onnxruntime
1 parent 1210d49 commit 6506173

File tree

15 files changed

+186
-21
lines changed

15 files changed

+186
-21
lines changed

.github/workflows/rebuildDependencies.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,18 @@ jobs:
4545
os: windows-latest
4646
conan_profiles: '["msvc-x64"]'
4747
conan_options: -o "&:target_pre_windows10=True"
48+
- platform: windows-x64-win7
49+
os: windows-latest
50+
conan_profiles: '["msvc-x64-win7"]'
51+
conan_options: -o "&:target_pre_windows10=True" -o "&:with_onnxruntime=False"
4852
- platform: windows-x86
4953
os: windows-latest
5054
conan_profiles: '["msvc-x86"]'
5155
conan_options: -o "&:target_pre_windows10=True"
56+
- platform: windows-x86-win7
57+
os: windows-latest
58+
conan_profiles: '["msvc-x86-win7"]'
59+
conan_options: -o "&:target_pre_windows10=True" -o "&:with_onnxruntime=False"
5260
- platform: windows-arm64
5361
os: windows-11-arm
5462
conan_profiles: '["msvc-arm64"]'
@@ -119,6 +127,7 @@ jobs:
119127
120128
- name: Build recipes with our patches
121129
run: |
130+
set -x
122131
cciRepo='conan-center-index'
123132
branchName='master'
124133
recipePathQt='recipes/qt'
@@ -134,20 +143,27 @@ jobs:
134143
git sparse-checkout set \
135144
recipes/minizip \
136145
recipes/flac \
146+
recipes/onnxruntime \
137147
$recipePathQt \
138148
139149
git checkout
140150
151+
# Patch conan recipe to prevent dragging libcurl as a dependency
152+
# (can't be done via VCMI's conanfile as onnxruntime is built beforehand)
153+
git apply --ignore-whitespace ../conan_patches/onnxruntime/recipe.diff
154+
141155
# versions must be synced with: conan_patches/<package>/conandata.yml
142156
# if no custom patches are required for a package, it should be removed from here
143-
for p in minizip/1.3.1 flac/1.4.2 ; do
157+
for p in minizip/1.3.1 flac/1.4.2 onnxruntime/1.18.1 ; do
144158
IFS_OLD="$IFS"
145159
IFS=/
146160
read package version <<<"$p"
147161
IFS="$IFS_OLD"
148162
149163
if [[ $package == qt ]] ; then
150164
packagePath="$recipePathQt/5.x.x"
165+
elif [[ $package == onnxruntime ]] && ${{ contains(matrix.conan_options, 'with_onnxruntime=False') }} ; then
166+
continue
151167
else
152168
packagePath="recipes/$package/all"
153169
fi
@@ -219,8 +235,11 @@ jobs:
219235

220236
- name: Remove build requirements' binaries
221237
run: |
238+
set -x
222239
graphFile='graph.json'
223-
packageListFile='pkglist.json'
240+
hostPackagesFile='packages-host.json'
241+
buildPackagesFile='packages-build.json'
242+
buildFilteredPackagesFile='packages-build-filtered.txt'
224243
225244
conan graph info . \
226245
$CONAN_PROFILES \
@@ -229,12 +248,30 @@ jobs:
229248
--build=never \
230249
--no-remote \
231250
> "$graphFile"
251+
232252
conan list \
233253
--graph "$graphFile" \
234254
--graph-context=build-only \
235255
--format=json \
236-
> "$packageListFile"
237-
conan remove --list "$packageListFile" --confirm
256+
> $buildPackagesFile
257+
258+
conan list \
259+
--graph "$graphFile" \
260+
--graph-context=host \
261+
--format=json \
262+
> $hostPackagesFile
263+
264+
# Some are both build and host requirements and must not be removed
265+
# => exclude them from the list
266+
cat $buildPackagesFile $hostPackagesFile | jq -s '
267+
.[0]["Local Cache"] as $build_packages
268+
| (.[1]["Local Cache"] | keys) as $host_package_names
269+
| $build_packages
270+
| with_entries(select(.key as $k | $host_package_names | index($k) == null)) as $packages
271+
| {"Local Cache": $packages}
272+
' > $buildFilteredPackagesFile
273+
274+
conan remove --list "$buildFilteredPackagesFile" --confirm
238275
239276
- name: Create list of built packages
240277
run: |
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
patches:
2+
"1.18.1":
3+
- patch_file: "patches/android-64.diff"
4+
patch_description: |
5+
Fixes error for arm64-v8a targets:
6+
onnxruntime/core/mlas/lib/mlasi.h:366:11: error: unknown type name 'bfloat16_t'
7+
- patch_file: "patches/msvc-x86.diff"
8+
patch_description: |
9+
Fixes detection of x86 windows targets during cross-compilation.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--- a/cmake/onnxruntime_mlas.cmake
2+
+++ b/cmake/onnxruntime_mlas.cmake
3+
@@ -352,7 +362,7 @@ else()
4+
${MLAS_SRC_DIR}/sqnbitgemm_kernel_neon.cpp
5+
)
6+
set_source_files_properties(${MLAS_SRC_DIR}/sqnbitgemm_kernel_neon.cpp
7+
- PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+dotprod")
8+
+ PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+dotprod+bf16")
9+
if (NOT APPLE)
10+
set(mlas_platform_srcs
11+
${mlas_platform_srcs}
12+
@@ -368,13 +378,13 @@ else()
13+
${MLAS_SRC_DIR}/qgemm_kernel_ummla.cpp
14+
${MLAS_SRC_DIR}/sbgemm_kernel_neon.cpp
15+
)
16+
- set_source_files_properties(${MLAS_SRC_DIR}/aarch64/HalfGemmKernelNeon.S PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ")
17+
- set_source_files_properties(${MLAS_SRC_DIR}/aarch64/QgemmS8S8KernelSmmla.S PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+i8mm ")
18+
- set_source_files_properties(${MLAS_SRC_DIR}/aarch64/QgemmU8X8KernelUmmla.S PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+i8mm ")
19+
+ set_source_files_properties(${MLAS_SRC_DIR}/aarch64/HalfGemmKernelNeon.S PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16+bf16 ")
20+
+ set_source_files_properties(${MLAS_SRC_DIR}/aarch64/QgemmS8S8KernelSmmla.S PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+i8mm+bf16 ")
21+
+ set_source_files_properties(${MLAS_SRC_DIR}/aarch64/QgemmU8X8KernelUmmla.S PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+i8mm+bf16 ")
22+
set_source_files_properties(${MLAS_SRC_DIR}/aarch64/SbgemmKernelNeon.S PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+bf16 ")
23+
- set_source_files_properties(${MLAS_SRC_DIR}/activate_fp16.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ")
24+
- set_source_files_properties(${MLAS_SRC_DIR}/dwconv.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ")
25+
- set_source_files_properties(${MLAS_SRC_DIR}/pooling_fp16.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ")
26+
+ set_source_files_properties(${MLAS_SRC_DIR}/activate_fp16.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16+bf16 ")
27+
+ set_source_files_properties(${MLAS_SRC_DIR}/dwconv.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16+bf16 ")
28+
+ set_source_files_properties(${MLAS_SRC_DIR}/pooling_fp16.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16+bf16 ")
29+
set_source_files_properties(${MLAS_SRC_DIR}/sbgemm_kernel_neon.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+bf16 ")
30+
endif()
31+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--- a/cmake/adjust_global_compile_flags.cmake
2+
+++ b/cmake/adjust_global_compile_flags.cmake
3+
@@ -226,13 +226,17 @@ endmacro()
4+
5+
#Set global compile flags for all the source code(including third_party code like protobuf)
6+
#This section must be before any add_subdirectory, otherwise build may fail because /MD,/MT mismatch
7+
+message(STATUS "MSVC=${MSVC} | CMAKE_VS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME} | CMAKE_C_COMPILER_ARCHITECTURE_ID=${CMAKE_C_COMPILER_ARCHITECTURE_ID} | CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")
8+
if (MSVC)
9+
if (CMAKE_VS_PLATFORM_NAME)
10+
# Multi-platform generator
11+
set(onnxruntime_target_platform ${CMAKE_VS_PLATFORM_NAME})
12+
+ elseif (CMAKE_C_COMPILER_ARCHITECTURE_ID)
13+
+ set(onnxruntime_target_platform ${CMAKE_C_COMPILER_ARCHITECTURE_ID})
14+
else()
15+
set(onnxruntime_target_platform ${CMAKE_SYSTEM_PROCESSOR})
16+
endif()
17+
+ message(STATUS "Temporary onnxruntime_target_platform=${onnxruntime_target_platform}")
18+
if (onnxruntime_target_platform STREQUAL "ARM64")
19+
set(onnxruntime_target_platform "ARM64")
20+
enable_language(ASM_MARMASM)
21+
@@ -241,18 +245,19 @@ if (MSVC)
22+
elseif (onnxruntime_target_platform STREQUAL "ARM" OR CMAKE_GENERATOR MATCHES "ARM")
23+
set(onnxruntime_target_platform "ARM")
24+
enable_language(ASM_MARMASM)
25+
- elseif (onnxruntime_target_platform STREQUAL "x64" OR onnxruntime_target_platform STREQUAL "x86_64" OR onnxruntime_target_platform STREQUAL "AMD64" OR CMAKE_GENERATOR MATCHES "Win64")
26+
+ elseif (onnxruntime_target_platform MATCHES "[Xx]64" OR onnxruntime_target_platform MATCHES "[Xx]86_64" OR onnxruntime_target_platform STREQUAL "AMD64" OR CMAKE_GENERATOR MATCHES "Win64")
27+
set(onnxruntime_target_platform "x64")
28+
enable_language(ASM_MASM)
29+
- elseif (onnxruntime_target_platform STREQUAL "Win32" OR onnxruntime_target_platform STREQUAL "x86" OR onnxruntime_target_platform STREQUAL "i386" OR onnxruntime_target_platform STREQUAL "i686")
30+
+ elseif (onnxruntime_target_platform STREQUAL "Win32" OR onnxruntime_target_platform MATCHES "[Xx]86" OR onnxruntime_target_platform STREQUAL "i386" OR onnxruntime_target_platform STREQUAL "i686")
31+
set(onnxruntime_target_platform "x86")
32+
enable_language(ASM_MASM)
33+
message("Enabling SAFESEH for x86 build")
34+
set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /safeseh")
35+
else()
36+
- message(FATAL_ERROR "Unknown CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
37+
+ message(FATAL_ERROR "Unknown onnxruntime_target_platform: ${onnxruntime_target_platform}")
38+
endif()
39+
40+
+ message(STATUS "Final onnxruntime_target_platform=${onnxruntime_target_platform}")
41+
42+
#Always enable exception handling, even for Windows ARM
43+
if (NOT onnxruntime_DISABLE_EXCEPTIONS)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
index 0757ecd..587294b 100644
2+
--- a/recipes/onnxruntime/all/conanfile.py
3+
+++ b/recipes/onnxruntime/all/conanfile.py
4+
@@ -34,6 +34,11 @@ class OnnxRuntimeConan(ConanFile):
5+
"fPIC": True,
6+
"with_xnnpack": False,
7+
"with_cuda": False,
8+
+ # Prevents libcurl dependency (fails to build due to system zlib)
9+
+ # NOTE:
10+
+ # 'use_system_tz_db' is specific to date/3.0.1 (version pinned by onnxruntime/1.18.1).
11+
+ # Newer date recipes would need the tz_db=system option instead.
12+
+ "date/*:use_system_tz_db": True,
13+
}
14+
short_paths = True
15+

conan_profiles/base/msvc-intel

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,11 @@ include(msvc)
33
[settings]
44
# https://blog.knatten.org/2022/08/26/microsoft-c-versions-explained/
55
# https://learn.microsoft.com/en-us/cpp/overview/compiler-versions
6-
# v142 / 14.29 / 19.29
7-
compiler.version=192
8-
compiler.update=9
6+
# https://github.com/actions/runner-images/blob/win25/20251102.77/images/windows/Windows2025-Readme.md#microsoft-visual-c
7+
# v144 / 14.44 / 19.44
8+
compiler.version=194
9+
compiler.update=4
910

1011
[conf]
1112
# VS 2022
1213
tools.microsoft.msbuild:vs_version=17
13-
14-
# https://walbourn.github.io/a-brief-history-of-windows-sdks/
15-
# https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt
16-
# https://learn.microsoft.com/en-us/windows/win32/WinProg/using-the-windows-headers
17-
{% set _WIN32_WINNT_WIN7 = '0x0601' %}
18-
{% set NTDDI_WIN7 = '0x06010000' %}
19-
{% set win7_defines = [
20-
'_WIN32_WINNT={}'.format(_WIN32_WINNT_WIN7),
21-
'WINVER={}'.format(_WIN32_WINNT_WIN7),
22-
'NTDDI_VERSION={}'.format(NTDDI_WIN7),
23-
] %}
24-
tools.build:defines={{ win7_defines }}

conan_profiles/base/msvc-win7

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[conf]
2+
# https://walbourn.github.io/a-brief-history-of-windows-sdks/
3+
# https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt
4+
# https://learn.microsoft.com/en-us/windows/win32/WinProg/using-the-windows-headers
5+
{% set _WIN32_WINNT_WIN7 = '0x0601' %}
6+
{% set NTDDI_WIN7 = '0x06010000' %}
7+
{% set win7_defines = [
8+
'_WIN32_WINNT={}'.format(_WIN32_WINNT_WIN7),
9+
'WINVER={}'.format(_WIN32_WINNT_WIN7),
10+
'NTDDI_VERSION={}'.format(NTDDI_WIN7),
11+
] %}
12+
tools.build:defines={{ win7_defines }}

conan_profiles/base/msvc-win8

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[conf]
2+
# https://walbourn.github.io/a-brief-history-of-windows-sdks/
3+
# https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt
4+
# https://learn.microsoft.com/en-us/windows/win32/WinProg/using-the-windows-headers
5+
{% set _WIN32_WINNT_WIN8 = '0x0602' %}
6+
{% set NTDDI_WIN8 = '0x06020000' %}
7+
{% set win8_defines = [
8+
'_WIN32_WINNT={}'.format(_WIN32_WINNT_WIN8),
9+
'WINVER={}'.format(_WIN32_WINNT_WIN8),
10+
'NTDDI_VERSION={}'.format(NTDDI_WIN8),
11+
] %}
12+
tools.build:defines={{ win8_defines }}

conan_profiles/ios-arm64

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include(base/ios)
22

33
[settings]
4-
os.version=12.0
4+
os.version=13.0
55
arch=armv8

conan_profiles/macos-intel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include(base/macos)
22

33
[settings]
4-
os.version=10.13
4+
os.version=10.15
55
arch=x86_64

0 commit comments

Comments
 (0)