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

Migrate stubbing transformation to be performed in the instance body #3072

Closed
celinval opened this issue Mar 12, 2024 · 0 comments · Fixed by #3245
Closed

Migrate stubbing transformation to be performed in the instance body #3072

celinval opened this issue Mar 12, 2024 · 0 comments · Fixed by #3245
Assignees
Labels
[C] Internal Tracks some internal work. I.e.: Users should not be affected. [I] Refactoring / Clean Up Refactoring or cleaning up of existing code

Comments

@celinval
Copy link
Contributor

Proposed change:

Perform stubbing in the instance body instead of the generic one.

Motivation

This will simplify stubbing code, remove the redundant compilation and provide more precise error handling.

Background:

The stubbing transformation and validation are spread into multiple stages. The stubbing itself is done in the generic body by hijacking rustc's transformation query. Because of that, we have the following limitations:

  1. If the function being stubbed is generic, we delay the instantiation requirements validation to be done during the reachability analysis.
  2. We need to re-run the compilation for every set of stubs to invalidate the query cache and apply the right set of stubs.
  3. We have to override collect_and_partition_mono_items query to avoid an ICE related to the delayed validation of the instantiation requirements.

There is a downside though. Today, we are able to apply the stubs to concrete playback, which wouldn't be possible until changes to the StableMIR are visible to the rust compiler.

@celinval celinval added [C] Internal Tracks some internal work. I.e.: Users should not be affected. [I] Refactoring / Clean Up Refactoring or cleaning up of existing code labels Mar 12, 2024
@celinval celinval self-assigned this Jun 8, 2024
celinval added a commit that referenced this issue Jun 10, 2024
…3245)

Using stubs or function contracts as part of the `verify-std`
sub-command does not work with multiple rustc executions as previous
implementation. This happens because we now enable verifying
dependencies, and cargo crashes due to a race condition. As soon as the
first rustc invocation succeeds, cargo starts the compilation of the
dependents crate. However, new executions can override files.

Instead, we moved the stub logic to the new transformation framework,
which is done on the top of the StableMIR body, and doesn't affect the
Rust compiler session. We are now able to apply stub without restarting
the compiler. This is a much better user experience as well, since
multiple calls to the compiler can print the same warnings multiple
times.

Resolves #3072
Towards #3152 


Co-authored-by: Felipe R. Monteiro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Internal Tracks some internal work. I.e.: Users should not be affected. [I] Refactoring / Clean Up Refactoring or cleaning up of existing code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant