-
Notifications
You must be signed in to change notification settings - Fork 432
document guidelines for which shims have a place in Miri #4767
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
base: master
Are you sure you want to change the base?
Conversation
|
Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two. |
|
|
||
| ## Scope of Miri shims | ||
|
|
||
| Miri has "shims" to implement functionality that is usually implemented in C libraries which are |
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.
Miri also has shims for various SIMD intrinsics, or would you not call those shims?
| Miri has "shims" to implement functionality that is usually implemented in C libraries which are | ||
| invoked from Rust code, such as opening files or spawning threads. However, the set of C functions | ||
| that Rust code invokes this way is enormous, and for obvious reasons we have no intention of | ||
| implementing every C API ever in Miri. |
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.
| implementing every C API ever in Miri. | |
| implementing every C API ever written in Miri. |
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.
"every C API ever" is fine in informal spoken English, but I think it seems weirdly incomplete in such documentation.
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.