Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

luncliff
Copy link
Contributor

@luncliff luncliff commented May 22, 2024

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.

* disable-static-generation, disable-exception
@@ -24,6 +24,8 @@ endif()
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
pybind11 BUILD_ONNX_PYTHON
disable-exception ONNX_DISABLE_EXCEPTIONS
disable-static-generation ONNX_DISABLE_STATIC_REGISTRATION
Copy link
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
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
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
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
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
Copy link
Contributor

@WangWeiLin-MV WangWeiLin-MV left a comment

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
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 luncliff marked this pull request as draft May 25, 2024 05:14
@luncliff 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
Contributor Author

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

@luncliff luncliff marked this pull request as ready for review May 30, 2024 02:26
@luncliff
Copy link
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
Contributor

dg0yt commented May 30, 2024

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
Contributor Author

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

@dg0yt
Copy link
Contributor

dg0yt commented May 30, 2024

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
Copy link
Contributor Author

luncliff commented May 30, 2024 via email

@dg0yt
Copy link
Contributor

dg0yt commented May 30, 2024

?

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.)

Copy link
Contributor

@WangWeiLin-MV WangWeiLin-MV left a comment

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
Contributor

dg0yt commented May 30, 2024

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
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.

Copy link
Contributor

@WangWeiLin-MV WangWeiLin-MV left a comment

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:reviewed Pull Request changes follow basic guidelines label May 31, 2024
@vicroms 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 BillyONeal removed the info:reviewed Pull Request changes follow basic guidelines label Jun 10, 2024
@BillyONeal
Copy link
Member

@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
Contributor Author

Seems like no more comment.

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

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

BillyONeal commented Jun 13, 2024

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

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.

None yet

6 participants