Skip to content
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

Fix: onnxruntime 1.17.0をビルドできるように #36

Merged
merged 13 commits into from
Feb 6, 2024
45 changes: 32 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
env:
ONNXRUNTIME_VERSION:
|- # releaseタグ名か、workflow_dispatchでのバージョン名が入る。無指定なら適当なバージョン
${{ github.event.release.tag_name || github.event.inputs.version || '1.16.3' }}
${{ github.event.release.tag_name || github.event.inputs.version || '1.17.0' }}
RELEASE:
|- # releaseタグ名か、workflow_dispatchでのreleaseフラグがあればリリースする
${{ github.event.release.tag_name != '' || github.event.inputs.release == 'true' }}
Expand Down Expand Up @@ -68,17 +68,17 @@ jobs:
release_config: Release
- artifact_name: onnxruntime-linux-armhf
os: ubuntu-20.04
cc_version: "9"
cxx_version: "9"
cc_version: "10"
cxx_version: "10"
linux_cross_arch: arm-linux-gnueabihf
symlink_workaround: true
build_opts: --arm --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=armv7l --config Release --parallel --compile_no_warning_as_error --update --build --build_shared_lib
result_dir: build
release_config: Release
- artifact_name: onnxruntime-linux-arm64
os: ubuntu-20.04
cc_version: "9"
cxx_version: "9"
cc_version: "10"
cxx_version: "10"
linux_cross_arch: aarch64-linux-gnu
symlink_workaround: true
build_opts: --arm64 --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=aarch64 --config Release --parallel --compile_no_warning_as_error --update --build --build_shared_lib
Expand Down Expand Up @@ -106,19 +106,19 @@ jobs:
release_config: Release
- artifact_name: onnxruntime-ios-arm64
os: macos-12
build_opts: --config Release --parallel --compile_no_warning_as_error --update --build --build_shared_lib --skip_tests --use_xcode --ios --ios_sysroot iphoneos --osx_arch arm64 --apple_deploy_target 16.0
build_opts: --config Release --parallel --compile_no_warning_as_error --update --build --build_shared_lib --skip_tests --use_xcode --ios --apple_sysroot iphoneos --osx_arch arm64 --apple_deploy_target 16.0
build_opts_workaround_protoc: --path_to_protoc_exe /usr/local/opt/protobuf@21/bin/protoc
result_dir: build/Release
release_config: Release-iphoneos
- artifact_name: onnxruntime-ios-sim-arm64
os: macos-12
build_opts: --config Release --parallel --compile_no_warning_as_error --update --build --build_shared_lib --skip_tests --use_xcode --ios --ios_sysroot iphonesimulator --osx_arch arm64 --apple_deploy_target 16.0
build_opts: --config Release --parallel --compile_no_warning_as_error --update --build --build_shared_lib --skip_tests --use_xcode --ios --apple_sysroot iphonesimulator --osx_arch arm64 --apple_deploy_target 16.0
build_opts_workaround_protoc: --path_to_protoc_exe /usr/local/opt/protobuf@21/bin/protoc
result_dir: build/Release
release_config: Release-iphonesimulator
- artifact_name: onnxruntime-ios-sim-x86_64
os: macos-12
build_opts: --config Release --parallel --compile_no_warning_as_error --update --build --build_shared_lib --skip_tests --use_xcode --ios --ios_sysroot iphonesimulator --osx_arch x86_64 --apple_deploy_target 16.0
build_opts: --config Release --parallel --compile_no_warning_as_error --update --build --build_shared_lib --skip_tests --use_xcode --ios --apple_sysroot iphonesimulator --osx_arch x86_64 --apple_deploy_target 16.0
build_opts_workaround_protoc: --path_to_protoc_exe /usr/local/opt/protobuf@21/bin/protoc
result_dir: build/Release
release_config: Release-iphonesimulator
Expand All @@ -132,10 +132,10 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Version check (semver)
run: |
VERSION="${{ env.ONNXRUNTIME_VERSION }}"
Expand All @@ -147,11 +147,24 @@ jobs:
fi

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: microsoft/onnxruntime
submodules: true
ref: v${{ env.ONNXRUNTIME_VERSION }}
- name: Checkout builder
uses: actions/checkout@v4
with:
path: builder

- name: Apply patch
run: |
# https://stackoverflow.com/a/37939589
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }

if [ $(version ${{ env.ONNXRUNTIME_VERSION }}) -ge $(version 1.17.0) ]; then
git apply --ignore-whitespace --reject --whitespace=fix --verbose ./builder/1_17_patch.patch
fi

- name: Dump matrix context
env:
Expand Down Expand Up @@ -258,6 +271,12 @@ jobs:
echo "CC=${{ env.ARCH_PREFIX }}gcc-${{ matrix.cc_version }}" >> "$GITHUB_ENV"
echo "CXX=${{ env.ARCH_PREFIX }}g++-${{ matrix.cxx_version }}" >> "$GITHUB_ENV"

- name: Configure to use latest Android NDK
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') && startsWith(matrix.artifact_name, 'onnxruntime-android')
run: |
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2004-Readme.md#environment-variables-2
echo "ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> "$GITHUB_ENV"

- name: Build ONNX Runtime
if: steps.cache-build-result.outputs.cache-hit != 'true'
run: |
Expand Down
22 changes: 22 additions & 0 deletions 1_17_patch.patch
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py
index 31f242cce..c42ba9386 100644
--- a/tools/ci_build/build.py
+++ b/tools/ci_build/build.py
@@ -987,6 +987,8 @@ def generate_build_tree(
disable_optional_type = "optional" in types_to_disable
disable_sparse_tensors = "sparsetensor" in types_to_disable

+ is_x86_64_build = not (args.android or args.ios or args.build_wasm or args.arm or args.arm64 or args.arm64ec)
+
cmake_args += [
"-Donnxruntime_RUN_ONNX_TESTS=" + ("ON" if args.enable_onnx_tests else "OFF"),
"-Donnxruntime_GENERATE_TEST_REPORTS=ON",
@@ -1569,7 +1571,7 @@ def generate_build_tree(
"-pipe",
"-ggdb3",
]
- if is_linux() and platform.machine() == "x86_64":
+ if is_linux() and is_x86_64_build:
# The following flags needs GCC 8 and newer
cflags += ["-fstack-clash-protection", "-fcf-protection"]
cxxflags = cflags.copy()