Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
cyanic-selkie opened this issue Nov 6, 2024 · 4 comments · Fixed by #23285
Closed

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

cyanic-selkie opened this issue Nov 6, 2024 · 4 comments · Fixed by #23285
Labels
build build issues; typically submitted using template contributions welcome external contributions welcome

Comments

@cyanic-selkie
Copy link

cyanic-selkie commented Nov 6, 2024

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 cyanic-selkie added the build build issues; typically submitted using template label Nov 6, 2024
@cyanic-selkie
Copy link
Author

cyanic-selkie commented Nov 6, 2024

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
Copy link
Member

snnn commented Nov 6, 2024

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.

@snnn snnn added the contributions welcome external contributions welcome label Nov 6, 2024
@cyanic-selkie
Copy link
Author

@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
Copy link
Member

snnn commented Nov 7, 2024

Either can work.

@snnn snnn closed this as completed in 5b9c968 Jan 8, 2025
snnn pushed a commit that referenced this issue Jan 8, 2025
### Description

Changes vcpkg manifest and configuration file (vcpkg.json &
vcpkg-configuration.json)

* Update vcpkg version to
https://github.com/microsoft/vcpkg/releases/tag/2024.12.16
* Use protobuf 3.21.12(= `v21.12`) to sync with
[cmake/deps.txt](https://github.com/microsoft/onnxruntime/blob/main/cmake/deps.txt)
  * Resolve #22750
* Add `onnx` to vcpkg manifest so `find_package(ONNX)` and
`find_dependency(Protobuf)` can work as expected.
  * Currently, It uses 1.16.2
* v1.17.0 will become available after
microsoft/vcpkg#42942

However, `onnx` in vcpkg doesn't configure
`ONNX_DISABLE_STATIC_REGISTRATION` build option.

* microsoft/vcpkg#38879
* Create "cmake/vcpkg-triplets/" folder and triplet files which use
`VCPKG_CMAKE_CONFIGURE_OPTIONS` for the option
* This requires `VCPKG_OVERLAY_TRIPLETS` environment variable for CI
steps, which is a bit inconvenient.
     I will try to find simple way to get same result

### Motivation and Context

* Help #23158 
  * "ONNX is not consumed from vcpkg"
* "Mismatch protobuf version. When vcpkg is enabled , we should not
fetch protoc from Github which may cause version mismatches."
* microsoft/vcpkg#43126
* #21348
tarekziade pushed a commit to tarekziade/onnxruntime that referenced this issue Jan 10, 2025
### Description

Changes vcpkg manifest and configuration file (vcpkg.json &
vcpkg-configuration.json)

* Update vcpkg version to
https://github.com/microsoft/vcpkg/releases/tag/2024.12.16
* Use protobuf 3.21.12(= `v21.12`) to sync with
[cmake/deps.txt](https://github.com/microsoft/onnxruntime/blob/main/cmake/deps.txt)
  * Resolve microsoft#22750
* Add `onnx` to vcpkg manifest so `find_package(ONNX)` and
`find_dependency(Protobuf)` can work as expected.
  * Currently, It uses 1.16.2
* v1.17.0 will become available after
microsoft/vcpkg#42942

However, `onnx` in vcpkg doesn't configure
`ONNX_DISABLE_STATIC_REGISTRATION` build option.

* microsoft/vcpkg#38879
* Create "cmake/vcpkg-triplets/" folder and triplet files which use
`VCPKG_CMAKE_CONFIGURE_OPTIONS` for the option
* This requires `VCPKG_OVERLAY_TRIPLETS` environment variable for CI
steps, which is a bit inconvenient.
     I will try to find simple way to get same result

### Motivation and Context

* Help microsoft#23158 
  * "ONNX is not consumed from vcpkg"
* "Mismatch protobuf version. When vcpkg is enabled , we should not
fetch protoc from Github which may cause version mismatches."
* microsoft/vcpkg#43126
* microsoft#21348
guschmue pushed a commit that referenced this issue Jan 12, 2025
### Description

Changes vcpkg manifest and configuration file (vcpkg.json &
vcpkg-configuration.json)

* Update vcpkg version to
https://github.com/microsoft/vcpkg/releases/tag/2024.12.16
* Use protobuf 3.21.12(= `v21.12`) to sync with
[cmake/deps.txt](https://github.com/microsoft/onnxruntime/blob/main/cmake/deps.txt)
  * Resolve #22750
* Add `onnx` to vcpkg manifest so `find_package(ONNX)` and
`find_dependency(Protobuf)` can work as expected.
  * Currently, It uses 1.16.2
* v1.17.0 will become available after
microsoft/vcpkg#42942

However, `onnx` in vcpkg doesn't configure
`ONNX_DISABLE_STATIC_REGISTRATION` build option.

* microsoft/vcpkg#38879
* Create "cmake/vcpkg-triplets/" folder and triplet files which use
`VCPKG_CMAKE_CONFIGURE_OPTIONS` for the option
* This requires `VCPKG_OVERLAY_TRIPLETS` environment variable for CI
steps, which is a bit inconvenient.
     I will try to find simple way to get same result

### Motivation and Context

* Help #23158 
  * "ONNX is not consumed from vcpkg"
* "Mismatch protobuf version. When vcpkg is enabled , we should not
fetch protoc from Github which may cause version mismatches."
* microsoft/vcpkg#43126
* #21348
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
build build issues; typically submitted using template contributions welcome external contributions welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants