-
Notifications
You must be signed in to change notification settings - Fork 78
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
Support building Verus-verified components with ordinary stable Rust #733
Conversation
I was planning to use the unstable allocator_api for #460 Is there a way to keep that? |
Good question. I guess some projects like Syn are highly configurable based on cfg feature flags. Should we make |
Well the allocator_api is supposed to be used by executable code. So restricting it to |
Ok, so maybe the proper thing to do is to add a separate cfg flag for executable vstd code that relies on unstable Rust features. |
That makes sense to me if @tjhance believes it would work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only concern I have is the potential UB in public verus functions that are safe but have a precondition, which is being discussed here #105 (comment)
But I don't think that has to be resolved before merging, as long as it's clear that we may make breaking changes to the conditionally safe parts of vstd, or to the code produced with ordinary stable Rust, as a result of that discussion.
So far, we've been using the
verus
executable to build and compile Verus projects in their entirety. However, there are also scenarios where Verus-verified code is used as a component in a larger unverified Rust-based project. In this case, the Verus-verified component still depends onbuiltin
,builtin_macros
, andvstd
, which currently depend on special Verus build procedures that include non-stable Rust features.This pull request observes that once ghost code is erased,
builtin
,builtin_macros
, andvstd
don't actually depend on any special Verus build procedures or non-stable Rust features, and can in fact be built with ordinary stablerustc
andcargo
, making them easier to incorporate as dependencies in larger Rust projects. To take advantage of this, this pull request replaces theverus_macro_erase_ghost
cfg flag with two cfg flags,verus_keep_ghost
andverus_keep_ghost_body
. This supports the two existing scenarios where verus runs rustc with unstable features, plus the new stable-Rust scenario:builtin
, to enable compiling code with ordinary stable rustc and cargo as part of a larger projectSince not(verus_keep_ghost) and not(verus_keep_ghost_body) are the default configuration, no special cfg flags are required for compiling Verus-verified code with ordinary rustc and cargo. In addition, this pull request adds an ordinary
Cargo.toml
file forvstd
that builds the not(verus_keep_ghost) and not(verus_keep_ghost_body) version ofvstd
and vstd's dependencies (includingbuiltin
,builtin_macros
,syn_verus
, etc.). Larger Rust projects can easily use thisCargo.toml
file to build the dependencies of any Verus-verified code. Finally, this pull request makes building this no-ghost version ofvstd
part of CI.Note: this pull request avoids triggering the issue that motivated #709 and is therefore orthogonal to #709 .
[edited to fix misspelling of
verus_keep_ghost
]