document guidelines for which shims have a place in Miri #4767
+14
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I figured it would be good to document this somewhere, also to ensure we have consensus in the team.
So @rust-lang/miri what do you think -- do you agree with the proposal here?
From what I can tell, all shims we currently have fit the rules described here. We do not use
libcorwindows-sysor other 3rd-party crates for any of the Miri shims. (We use it for native-lib support, but that's different. It's not something that needs separate work for each shim.)We did have an
flockshim for some time that usedlibcandwindows-sys, but meanwhile std gained APIs forflockso we can use those -- and honestly I think next time I'd prefer to wait until std has APIs; I always felt uneasy about getting enough test coverage for the host part of that implementation, and it invited several PRs where people added more implementations of that for more targets. Miri is IMO not the place to develop a portable HAL for all sorts of random system APIs.This part here...
...is foreshadowing: I plan to add support for sockets to Miri, which needs a way to do "wait until any of these file descriptors is ready". I plan to use
miofor that, so there will be no platform-dependent code in Miri. I think that is reasonable:miowill not just go away, and it is portable so we don't have to worry about (host) target support in Miri.We had a similar situation in the past where we used the
attycrate to implement, well,atty, which eventually got replaced by the standard library gaining support viais_terminal. That actually did not go so well,attyis unmaintained now. That's why we have to be picky about which crates we use to implement more shims.