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

feat(hax-lib): intro. hax feature #983

Merged
merged 19 commits into from
Nov 13, 2024
Merged

feat(hax-lib): intro. hax feature #983

merged 19 commits into from
Nov 13, 2024

Conversation

W95Psp
Copy link
Collaborator

@W95Psp W95Psp commented Oct 9, 2024

This PR introduces a (default) hax feature on hax-lib.

When this feature is disabled:

  • hax-lib-macros defines identity proc-macros, and keeps its dependencies to a minimum (only quote and syn)
  • hax-lib becomes a one-module tiny and "inert" library, with only hax-lib-macros as a dependency (when the feature macros is enabled)

Fixes #639.

@W95Psp W95Psp force-pushed the dummy-lib branch 2 times, most recently from a791629 to cd0890a Compare October 10, 2024 08:13
@W95Psp W95Psp changed the title Dummy lib feat(hax-lib): intro. hax feature Oct 10, 2024
@W95Psp W95Psp force-pushed the dummy-lib branch 2 times, most recently from a375b7c to 7d1a846 Compare October 10, 2024 08:37
Copy link
Contributor

@karthikbhargavan karthikbhargavan left a comment

Choose a reason for hiding this comment

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

I tested this on libcrux and it appears to work well.

@karthikbhargavan
Copy link
Contributor

@franziskuskiefer fixed the flags on this PR, and now the hax engine fails because of this error:

# File "lib/concrete_ident_generated.ml", lines 1-476, characters 0-94:
#   1 | type t = 
#   2 |       Hax_lib_protocol__crypto__Impl_5__from_bytes
#   3 |     | Core__result__Impl__E
#   4 |     | Core__ops__control_flow__ControlFlow__Break
#   5 |     | Core__ops__bit__BitAnd__bitand
# ...
# 473 |     | Core__cmp__PartialEq__eq__'__1
# 474 |     | Rust_primitives__hax__control_flow_monad__moption
# 475 |     | Core__array__iter__Impl__T
# 476 |     | Core__iter__traits__iterator__Iterator[@@deriving show, yojson, compare, sexp, eq, hash]
# Error: Two constructors are named Hax_lib__assert

This is because the hax-engine also depends on hax-lib to extract names, and with the new cfg flags, something is going wrong in the way this is used.

@W95Psp: maybe this will be easy for you to fix.

…ing Json THIR

For instance:
 - `... | jq 'include ".utils/jq_utils"; thir_str_of_def_ids'` will transform all THIR def ids into strings;
 - `... | jq 'include ".utils/jq_utils"; remove_field("span")'` will remove most of spans.
Copy link
Member

@franziskuskiefer franziskuskiefer left a comment

Choose a reason for hiding this comment

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

Clearing the review. Re-request when it's ready to look at.

hax-lib/macros/src/dummy.rs Outdated Show resolved Hide resolved
@W95Psp
Copy link
Collaborator Author

W95Psp commented Nov 12, 2024

The engine is fixed and the library is fixed as well, things are passing CI.
@karthikbhargavan can you check if that's working fine on MLKEM?

Copy link
Member

@franziskuskiefer franziskuskiefer left a comment

Choose a reason for hiding this comment

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

Looks good to me now. The main thing I checked is that we are really not getting any dependencies or code when not using the hax cfg.

@karthikbhargavan
Copy link
Contributor

libcrux proofs use hax_lib::loop_invariant!; so this needs to be in the dummy-lib.

@W95Psp
Copy link
Collaborator Author

W95Psp commented Nov 13, 2024

I fixed it, now it should be fine!

Copy link
Contributor

@karthikbhargavan karthikbhargavan left a comment

Choose a reason for hiding this comment

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

This works for me now. Thanks!

@W95Psp W95Psp enabled auto-merge November 13, 2024 13:19
@W95Psp W95Psp added this pull request to the merge queue Nov 13, 2024
Merged via the queue into main with commit 3ca3bde Nov 13, 2024
15 checks passed
@W95Psp W95Psp deleted the dummy-lib branch November 13, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants