onnxruntime icon indicating copy to clipboard operation
onnxruntime copied to clipboard

[Build] passing --arm64 to ci_build/build.py has error in arm64 host

Open aungthetnaing opened this issue 1 year ago • 4 comments

Describe the issue

--arm64 should not mean that there is cross-compilation. --arm64 flag should work in both arm64 and x64 hosts.

After this PR https://github.com/microsoft/onnxruntime/commit/8d09baf49f03ff8a50e30f1c662ea706ab657bb5

--arm64 flag in arm64 host will fail with the following error-check.

CMAKE_HOST_SYSTEM_NAME: Windows CMake Error at external/onnxruntime_external_deps.cmake:189 (message): ONNX_CUSTOM_PROTOC_EXECUTABLE must be set to cross-compile. Call Stack (most recent call first): CMakeLists.txt:586 (include)

Urgency

No response

Target platform

arm64

Build script

build.bat --build_shared_lib --config Release --parallel --skip_submodule_sync --skip_tests --use_binskim_compliant_compile_flags --msvc_toolset v143 --arm64 --enable_msvc_static_runtime --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF "CMAKE_C_FLAGS=/Qspectre /guard:cf /Zi" "CMAKE_CXX_FLAGS=/Qspectre /guard:cf /Zi" "CMAKE_SHARED_LINKER_FLAGS=/guard:cf /DYNAMICBASE /DEBUG" "CMAKE_EXE_LINKER_FLAGS=/guard:cf /DYNAMICBASE /DEBUG"

Error / output

CMAKE_HOST_SYSTEM_NAME: Windows CMake Error at external/onnxruntime_external_deps.cmake:189 (message): ONNX_CUSTOM_PROTOC_EXECUTABLE must be set to cross-compile. Call Stack (most recent call first): CMakeLists.txt:586 (include)

Visual Studio Version

VS2022

GCC / Compiler Version

No response

aungthetnaing avatar May 24 '24 18:05 aungthetnaing

Please download protobuf 3.21.12 from https://www.nuget.org/packages/Google.Protobuf, unzip the package, then set ONNX_CUSTOM_PROTOC_EXECUTABLE to the path of the x64 version of protoc.exe. Put ONNX_CUSTOM_PROTOC_EXECUTABLE
in cmake_extra_defines .

snnn avatar May 26 '24 03:05 snnn

Please download protobuf 3.21.12 from https://www.nuget.org/packages/Google.Protobuf, unzip the package, then set ONNX_CUSTOM_PROTOC_EXECUTABLE to the path of the x64 version of protoc.exe. Put ONNX_CUSTOM_PROTOC_EXECUTABLE in cmake_extra_defines .

This step is not required for --arm64 flag run in host x64. So, I believe we should fix it in a way that --arm64 flag will behave the same in both x64 and arm64 host.

aungthetnaing avatar May 27 '24 04:05 aungthetnaing

Platform flags like --arm64 or --x86 are intended for cross compiling. If you're not cross-compiling, simply don't add the --arm64 flag.

skottmckay avatar May 27 '24 08:05 skottmckay

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

github-actions[bot] avatar Jun 26 '24 15:06 github-actions[bot]

Building from source on arm64 device without --arm64 flag (build.bat --build_shared_lib --config Release --parallel --skip_submodule_sync --skip_tests --use_dml --cmake_generator "Visual Studio 17 2022" ) ** works fine** but same binary on x64 fails to execute with error - "onnxruntime_perf_test.exe is valid, but it is for a machine type other than the current machine". I tried on X Elite with commit id - https://github.com/microsoft/onnxruntime/commit/80b56feb412f7b9a637efee5ab2f31d00ec07643.

Few app vendors will be shipping single onnxruntime.dll for ARM/x64. How to generate binary cross compatible and uses native instructions - x64 : AVX/AVX2 ; ARM: NEON (not emulated).

mrsabhar avatar Jul 18 '24 05:07 mrsabhar

You want a single binary that supports both x64 and arm64 CPUs ?

snnn avatar Jul 18 '24 16:07 snnn

On Windows we support 4 ABIs:

  1. ARM64
  2. ARM64EC
  3. 32-bit x86
  4. 64-bit x86

Except for ARM64EC, you can build the code natively on a CPU with the instruction set and with a python.exe with the same ABI. In this case, you do not need to add the flags like "--arm64". For example, if you want a ARM64 binary, you get a ARM64 python.exe from python.org, the use the python to build ONNX Runtime code and do not add the "--arm64" flag. If you want to build for ARM64EC, you need to add the "--arm64ec" flag. If you want to build for ARM64 or ARM64EC in a x64 Windows, you need to add the "--arm64" or "--arm64ec" flag.

snnn avatar Jul 18 '24 16:07 snnn

build.bat --android --android_sdk_path D:\Users\lxwang8\AppData\Local\android_sdk --android_ndk_path D:\android-ndk-r21e --android_abi arm64-v8a --android_api 29 --use_nnapi --config Release --cmake_generator Ninja

use this command to build for android on windows has the same issue. onnxruntime-1.20.1

CMake Error at external/onnxruntime_external_deps.cmake:189 (message): ONNX_CUSTOM_PROTOC_EXECUTABLE must be set to cross-compile.

wanglxchina avatar Dec 25 '24 09:12 wanglxchina

This issue has been automatically closed as 'not planned' because it has been marked as 'stale' for more than 30 days without activity. If you believe this is still an issue, please feel free to reopen it.

snnn avatar Jun 07 '25 23:06 snnn