Skip to content

Commit 941d0b3

Browse files
committed
Fix builds for ONNX Runtime
1 parent 5444b5c commit 941d0b3

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

onnxruntime/cppbuild.sh

+14-8
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export CUDNN_HOME="/usr/local/cuda"
1616
export MAKEFLAGS="-j $MAKEJ"
1717
export PYTHON_BIN_PATH=$(which python3)
1818

19-
export GPU_FLAGS=
19+
export CUDAFLAGS=
2020
if [[ "$EXTENSION" == *gpu ]]; then
21-
GPU_FLAGS="--use_cuda"
21+
CUDAFLAGS="--use_cuda"
2222
fi
2323

2424
ONNXRUNTIME=1.17.3
@@ -75,18 +75,24 @@ sedinplace '/WX/d' cmake/CMakeLists.txt
7575

7676
# allow cross compilation for linux-arm64
7777
sedinplace 's/if args.arm or args.arm64:/if False:/g' tools/ci_build/build.py
78+
sedinplace 's/is_linux() and platform.machine() == "x86_64"/False/g' tools/ci_build/build.py
79+
sedinplace 's/onnxruntime_target_platform STREQUAL "aarch64"/FALSE/g' cmake/CMakeLists.txt
80+
sedinplace 's/if (NOT APPLE)/if (FALSE)/g' cmake/onnxruntime_mlas.cmake
81+
sedinplace 's/!defined(__APPLE__)/0/g' onnxruntime/core/mlas/inc/mlas.h
82+
sedinplace 's/defined(__aarch64__) && defined(__linux__)/0/g' `find . -name *.cpp -o -name *.cc -o -name *.h`
83+
sedinplace 's/MLAS_CPUIDINFO::GetCPUIDInfo().HasArmNeon_I8MM()/false/g' onnxruntime/core/mlas/lib/platform.cpp
7884

7985
# work around toolchain issues on Mac and Windows
8086
patch -p1 < ../../../onnxruntime.patch
8187
#patch -p1 < ../../../onnxruntime-windows.patch # https://github.com/microsoft/onnxruntime/pull/7883
8288
sedinplace '/--Werror/d' cmake/CMakeLists.txt
8389
sedinplace "s/return 'ON'/return 'OFF'/g" tools/ci_build/build.py
8490
sedinplace "s/Visual Studio 1. 20../Ninja/g" tools/ci_build/build.py
85-
sedinplace 's/Darwin|iOS/iOS/g' cmake/onnxruntime_providers.cmake
86-
sedinplace 's/-fvisibility=hidden//g' cmake/CMakeLists.txt cmake/adjust_global_compile_flags.cmake cmake/onnxruntime_providers.cmake
87-
sedinplace 's:/Yucuda_pch.h /FIcuda_pch.h::g' cmake/onnxruntime_providers.cmake
88-
sedinplace 's/${PROJECT_SOURCE_DIR}\/external\/cub//g' cmake/onnxruntime_providers.cmake
89-
sedinplace 's/ONNXRUNTIME_PROVIDERS_SHARED)/ONNXRUNTIME_PROVIDERS_SHARED onnxruntime_providers_shared)/g' cmake/onnxruntime_providers.cmake
91+
sedinplace 's/Darwin|iOS/iOS/g' cmake/onnxruntime_providers_cpu.cmake cmake/onnxruntime_providers.cmake
92+
sedinplace 's/-fvisibility=hidden//g' cmake/CMakeLists.txt cmake/adjust_global_compile_flags.cmake cmake/onnxruntime_providers_cpu.cmake cmake/onnxruntime_providers.cmake
93+
sedinplace 's:/Yucuda_pch.h /FIcuda_pch.h::g' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers.cmake
94+
sedinplace 's/${PROJECT_SOURCE_DIR}\/external\/cub//g' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers.cmake
95+
sedinplace 's/ONNXRUNTIME_PROVIDERS_SHARED)/ONNXRUNTIME_PROVIDERS_SHARED onnxruntime_providers_shared)/g' cmake/onnxruntime_providers_cpu.cmake cmake/onnxruntime_providers.cmake
9096
sedinplace 's/DNNL_TAG v.*)/DNNL_TAG v3.4.1)/g' cmake/external/dnnl.cmake
9197
sedinplace 's/DNNL_SHARED_LIB libdnnl.1.dylib/DNNL_SHARED_LIB libdnnl.2.dylib/g' cmake/external/dnnl.cmake
9298
sedinplace 's/DNNL_SHARED_LIB libdnnl.so.1/DNNL_SHARED_LIB libdnnl.so.2/g' cmake/external/dnnl.cmake
@@ -160,7 +166,7 @@ sedinplace 's/UTFChars(javaNameStrings/UTFChars((jstring)javaNameStrings/g' java
160166
sedinplace 's/initializers = allocarray/initializers = (const OrtValue**)allocarray/g' java/src/main/native/ai_onnxruntime_OrtSession_SessionOptions.cpp
161167

162168
which ctest3 &> /dev/null && CTEST="ctest3" || CTEST="ctest"
163-
"$PYTHON_BIN_PATH" tools/ci_build/build.py --build_dir ../build --config Release --cmake_path "$CMAKE" --ctest_path "$CTEST" --build_shared_lib $ARCH_FLAGS $DNNL_FLAGS $OPENMP_FLAGS $GPU_FLAGS
169+
"$PYTHON_BIN_PATH" tools/ci_build/build.py --build_dir ../build --config Release --cmake_path "$CMAKE" --ctest_path "$CTEST" --build_shared_lib $ARCH_FLAGS $DNNL_FLAGS $OPENMP_FLAGS $CUDAFLAGS
164170

165171
# install headers and libraries in standard directories
166172
cp -r include/* ../include

0 commit comments

Comments
 (0)