Skip to content

[onnx] Add features to use ONNX build options - #38879

Closed
PARK DongHa (luncliff) wants to merge 2 commits into
microsoft:masterfrom
luncliff:port/onnx
Closed

[onnx] Add features to use ONNX build options#38879
PARK DongHa (luncliff) wants to merge 2 commits into
microsoft:masterfrom
luncliff:port/onnx

Conversation

@luncliff

@luncliff PARK DongHa (luncliff) commented May 22, 2024

Copy link
Copy Markdown
Contributor

Changes

Make the following CMake build options to features in vcpkg.json

https://github.com/onnx/onnx/blob/b86cc54efce19530fb953e4b21f57e6b3888534c/CMakeLists.txt#L27-L28

References

Checklist

  • Changes comply with the maintainer guide.
  • SHA512s are updated for each updated download.
  • The "supports" clause reflects platforms that may be fixed by this new version.
  • Any fixed CI baseline entries are removed from that file.
  • Any patches that are no longer applied are deleted from the port's directory.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is added to each modified port's versions file.

Comment thread ports/onnx/portfile.cmake Outdated
Comment thread ports/onnx/portfile.cmake Outdated
FEATURES
pybind11 BUILD_ONNX_PYTHON
disable-exception ONNX_DISABLE_EXCEPTIONS
disable-static-generation ONNX_DISABLE_STATIC_REGISTRATION

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be made a positive feature instead since it gives a shorter feature name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I will change them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed their names in 02fe04d

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the discussion, the revert feature here may cause fail when it's being enabled by other ports (means NO ONNX_DISABLE_STATIC_REGISTRATION).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back to disable-static-registration in f339729
(note disable-static-generation was wrong name 😱 )

@WangWeiLin-MV WangWeiLin-MV added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label May 23, 2024

@WangWeiLin-MV WangWeiLin-MV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it disables function, will enabling these two features cause failed for consumers? - do-not-use-features-to-control-alternatives-in-published-interfaces

@luncliff

Copy link
Copy Markdown
Contributor Author

Looks like it disables function, will enabling these two features cause failed for consumers? - do-not-use-features-to-control-alternatives-in-published-interfaces

Honestly. I didn't check deeply for the part because I haven't encountered build errors in my team.
Let me check it

@luncliff
PARK DongHa (luncliff) marked this pull request as draft May 25, 2024 05:14
@luncliff PARK DongHa (luncliff) changed the title [onnx] Support disable-static-generation, disable-exception feature [onnx] Add features to use ONNX build options May 25, 2024
@luncliff

Copy link
Copy Markdown
Contributor Author

ONNX_DISABLE_STATIC_REGISTRATION doesn't affect the public interface, but the implementation's behavior.

@luncliff
PARK DongHa (luncliff) marked this pull request as ready for review May 30, 2024 02:26
@luncliff

Copy link
Copy Markdown
Contributor Author

Sorry for being late.
I added static-registration for default-features to make ONNX_DISABLE_STATIC_REGISTRATION=OFF just like the upstream's default option

@dg0yt

Copy link
Copy Markdown
Contributor

I added static-registration for default-features to make ONNX_DISABLE_STATIC_REGISTRATION=OFF just like the upstream's default option

Note that there are three ports which currently depend on plain "onnx", i.e. implicitly with default features enabled.

@luncliff

Copy link
Copy Markdown
Contributor Author

Yes. static-registration is the default feature. The user ports won't be affected

@dg0yt

Copy link
Copy Markdown
Contributor

The point is that without updating the other ports, it is not possible to disable the feature when you use one of these ports.

@luncliff

PARK DongHa (luncliff) commented May 30, 2024 via email

Copy link
Copy Markdown
Contributor Author

@dg0yt

Copy link
Copy Markdown
Contributor

?

No. Non-additive features aren't accepted, for good reasons.
It is probably the best to add "default-features": false to the other three ports. (Use git grep '"onnx"' ports/*/vcpkg.json.)

@WangWeiLin-MV WangWeiLin-MV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The revert feature may cause failure when it's being enabled by other ports (enable inverted feature static-registrationmeans means NO ONNX_DISABLE_STATIC_REGISTRATION=0).

It is probably the best to add "default-features": false to the other three ports.

This is a fragile workaround causes incompatibility in a case vcpkg install onnx[static-registrationmeans] onnxruntime according to the discussion.

@dg0yt

Copy link
Copy Markdown
Contributor

AFAIU:
(A) It is convenient and expected to have static registration in onnx when it is used directly.
(B) It is not possible to have static registration in onnx when onnxruntime is used.

(A) can only be achieved by a default-enabled capability, like a default-feature.
(B) requires the user (i.e. the top-level manifest) to disable onnx static registration when the project uses onnxruntime.

In vcpkg CI, we have both (A) and (B).

It is probably the best to add "default-features": false to the other three ports.

This is a fragile workaround causes incompatibility in a case vcpkg install onnx[static-registration] onnxruntime according to the discussion.

When you ask for failure, you get failure. Maybe the diagnostics could signal this early.


The alternative is to not change anything and require triplet customization in order to use onnxruntime.

@luncliff

Copy link
Copy Markdown
Contributor Author

For existing ports and vcpkg CI,
I think removing the default-features (like what we did previously) and adding disable-static-registration feature is more simple because the other ports don't need to care about onnx changes.

Thankfully, ONNX_DISABLE_STATIC_REGISTRATION doesn't change the interface.
Unless vcpkg CI runs executables which requires ONNX, the port builds & installations will be fine.

@WangWeiLin-MV WangWeiLin-MV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The port features installation tests pass with the following triplets:

  • x64-windows

@WangWeiLin-MV WangWeiLin-MV added the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label May 31, 2024
@vicroms Victor Romero (vicroms) added the requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. label Jun 3, 2024
@BillyONeal Billy O'Neal (BillyONeal) removed the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label Jun 10, 2024
@BillyONeal

Copy link
Copy Markdown
Member

Kai Pastor (@dg0yt) 's analysis in #38879 (comment) seems correct to me; I think this needs to be controlled with an overlay-port rather than features.

@luncliff

Copy link
Copy Markdown
Contributor Author

Seems like no more comment.

You can close the PR with the team's decision.

@BillyONeal Billy O'Neal (BillyONeal) removed the requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. label Jun 13, 2024
@BillyONeal

Billy O'Neal (BillyONeal) commented Jun 13, 2024

Copy link
Copy Markdown
Member

Related: #36850 . The discussion of the features-as-alternatives problem appears to have been discussed there.

@BillyONeal
Billy O'Neal (BillyONeal) marked this pull request as draft June 13, 2024 21:55
@luncliff
PARK DongHa (luncliff) deleted the port/onnx branch January 6, 2025 14:11
Changming Sun (snnn) pushed a commit to microsoft/onnxruntime that referenced this pull request 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
Changming Sun (snnn) pushed a commit to microsoft/onnxruntime that referenced this pull request 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
Tarek Ziade (tarekziade) pushed a commit to tarekziade/onnxruntime that referenced this pull request 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
Guenther Schmuelling (guschmue) pushed a commit to microsoft/onnxruntime that referenced this pull request 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
Ashrit Shetty (ashrit-ms) pushed a commit to microsoft/onnxruntime that referenced this pull request Mar 17, 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants