microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.7k stars 2.93k forks source link

[Build] Build fails with `vcpkg` due to an incorrect protobuf version. #22750

Open cyanic-selkie opened 1 week ago

cyanic-selkie commented 1 week ago

Describe the issue

Hi, I am building onnxruntime with vcpkg enabled on an ARM64 Macbook.

Looking at the build logs, I can see the protobuf version being used is 4.25.1

Installing 20/23 protobuf:arm64-osx@4.25.1#1...

This causes the error below.

I was under the impression that vcpkg would pick the correct version, not the latest... Is there any way to fix this?

Urgency

No response

Target platform

MacOS

Build script

./build.sh --config Release --parallel --compile_no_warning_as_error --skip_submodule_sync --update --build --build_dir build/macos --use_xcode --cmake_extra_defines CMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake --use_vcpkg

Error / output

... /path/to/onnxruntime/build/macos/Release/_deps/onnx-build/onnx/onnx-ml.pb.h:17:2: error: This file was generated by an older version of protoc which is 17 | #error This file was generated by an older version of protoc which is | ^ /path/to/onnxruntime/build/macos/Release/_deps/onnx-build/onnx/onnx-ml.pb.h:18:2: error: incompatible with your Protocol Buffer headers. Please 18 | #error incompatible with your Protocol Buffer headers. Please | ^ /path/to/onnxruntime/build/macos/Release/_deps/onnx-build/onnx/onnx-ml.pb.h:19:2: error: regenerate this file with a newer version of protoc. 19 | #error regenerate this file with a newer version of protoc. | ^ ...

Visual Studio Version

No response

GCC / Compiler Version

No response

cyanic-selkie commented 1 week ago

This passes when I add

  "overrides": [
    { "name": "protobuf", "version": "3.21.12" },
    { "name": "flatbuffers", "version": "23.5.26" }
  ],

to cmake/vcpkg.json. Otherwise, it installs the latest versions which are incompatible (protobuf > 3.12 and flatbuffers > 23)

snnn commented 1 week ago

Our CI build has:

--path_to_protoc_exe /Users/runner/work/onnxruntime/onnxruntime/.build/X64-osx/tools/protobuf/protoc

We may need to do some tweaks at https://github.com/microsoft/onnxruntime/blob/main/cmake/external/onnxruntime_external_deps.cmake#L121

I should we should not enter that code path if vcpkg is in-use.

cyanic-selkie commented 1 week ago

@snnn I'm not sure I follow. Isn't the actual fix properly setting the allowed versions of the protobuf and flatbuffers dependencies, essentially what I did?

snnn commented 1 week ago

Either can work.