-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Unify std::os::raw::c_void and libc::c_void via libcore #2521
The head ref may contain hidden characters: "\u7121"
Conversation
CC @rust-lang/libs |
Nice RFC, thanks. Thumbs up. All those issues mentioned were tangentially blocked on making
I don't personally want to bikeshed this, I think My understanding was that the reason these types where in That is, moving these types to The problem that So I am all in with this RFC. The unresolved questions about moving ctypes in |
This is debatable, but let’s not open this subtopic in this thread since it only applies to integer C types, not
I agree, I’ve tweaked that paragraph to explicitly propose that. |
Afaict, this is the only way currently to make a function accept either type, so I doubt it is uncommon. I presume that this is intended to be released as a minor version bump to libc... is there a migration plan for this? Some intermediate way to rewrite such code which is compatible with both old and new libc? I doubt the semver trick can be used for something this big! |
Is making a function accept either type useful? To the point that it’s worth going through the trouble of defining a public trait in your API? Compared to adding The libc crate is currently in version 0.2.x. I’m hoping we can get away with implementing this RFC in another 0.2.y version and won’t have to make a version that Cargo considers incompatible such as 0.3.0 or 1.0.0. In this case, you can have a dependency like Moving the ecosystem from 0.1 to 0.2 was a huge pain, I’m not proposing we go through that again. If you want to keep supporting older Rust versions and accept both types there, then I suppose you’d need a build script like the one proposed in the RFC for lib. |
That idiom is "fair" and works correctly, so I don't think the answer to this question matters at all. This libc change can and will break crates that are not broken (this change is not a bug fix). So for me the question that matters is: How many crates does it break? If it breaks hundreds of crates, we can't do this without doing a libc 0.3 release. If it breaks < 10 crates, I'd be ok with it, but others might not. Anyways, this is a libc issue. And I don't think we can know the answer to these questions without doing a crater run. And even if we cannot do this change in libc 0.2, this change is still worth doing in core, and we might some day do a libc 0.3 release, and we can put this in. So none of these issues should block this RFC. |
I think the question of whether it is useful matters in trying to guess how common it is. But Crater is probably a better way to settle that. |
Re |
Even if we fix up |
it's true. For The |
Re: |
I was curious about this, and one way we could test this out would be to change libc today to reexport |
A crater run is possible, we recently did one for lazy-static. If someone could prepare a PR for libc with the required changes I can look into running crater on it. |
Oh awesome! How should libc be prepared? Would a git branch suffice? Or something on crates.io? |
Git branch is sufficient, I believe. |
Ok! I've uploaded a branch to https://github.com/alexcrichton/libc/tree/c-void |
Okay I think I've started a crater run in check-only mode, we'll see how it goes. Generally speaking should have results in ~24-36 hours. |
The crater run (which I think worked, but can't really be sure) seems to indicate 0 regressions (https://cargobomb-reports.s3.amazonaws.com/libc-1/index.html). Are we aware of any expected regressions (that is, to test if the crater run found them)? |
As a point of data, |
Awesome, thanks @Mark-Simulacrum! @SimonSapin I think that's a pretty convincing data point that this is extremely unlikely to be a breaking change in practice, and that definitely makes me very confident in the proposed design here! (as a minor version bump of libc) |
This has sat for a bit now and has been debated quite a bit in the past. This has also been cc'd in a large number of locations for some good visibility, so that makes me comfortable to propose FCP here! I think that this is a solid step forward in the FFI story for the standard library and definitely one we should take. While we may want to be more ambitious in the future this is at least a good starting point. @rfcbot fcp merge |
I think it would be a shame if we stabilized |
We could use the same configure-script-style-check to just optionally depend on the std one, no new core one needed. |
Since crater has shown that |
@jethrogb I think “has been blocked” is one interpretation of those discussions. Some have expressed a preference for changing the definition of As to #1783, it proposed moving all
Note that If/when we add a new better improved equivalent to C’s |
@retep998 as discussed before it's a breaking change to do that due to The purpose of this RFC is to solve the problem once and for all with |
@alexcrichton no it could be done with some build.rs hack unconditionally as this PR does it with core. The actual "once and for all" solution would be making it an extern type once the temporary issues blocking use of these with |
@Ericson2314 what @retep998 is proposing is not changing |
But why would someone use |
@retep998 a If crate Why would a |
@gnzlbg In the case where crate |
@gnzlbg This, incidentally, is a great example of why we have |
@alexcrichton Also, for what it's worth, I hope in those same ~2 years (while |
@Ericson2314 this is getting off-topic but, as we’ve discussed multiple times already, even with std-aware Cargo the libc crate used by std would still be a separate crate from libc from crates.io that everyone can use in their |
The final comment period, with a disposition to merge, as per the review above, is now complete. |
Huzzah! This RFC has been merged! Tracking issue: rust-lang/rust#53856 |
Uh, don't the final comments need to wind down or something? This discussion seems ongoing. |
@SimonSapin Agreed this getting off topic, but as long as the portion of |
@Ericson2314 I sometimes wait with merging RFCs when new arguments are made that haven't been addressed during FCP; but it seemed to me that the libs team was aware of the new concerns and made different trade-offs. I recommend that you continue this conversation on the tracking issue over at rust-lang/rust#53856. If new significant concerns arise in the tracking issue, then the libs team can still decide to not go through with the RFC as planned. |
I commented there. On a meta level, I still feel like it's constantly an uphill battle to maintain the principle of small libraries with well-delineated purposes, as all mixes of prioritization and rushes (the former which I am much more sympathetic with) instead lead to things constantly being dumped in But even if that flies, I worry that by the time things like alloc polymorphic and std-aware Cargo get to the front of the queue, it will be death by a thousand cuts over the accumulated decisions made without really considering possibilities. Hopefully its just a few more months until the 2018 edition is up, and then those get to the front of the queue, and not too much gets in the way between now and then. If not, I'm already at the point where I feel the |
@Ericson2314 keep in mind that these sorts of decisions are always tradeoffs. We live in the real world where idealistic designs can't appear overnight. Compromises need be made to solve real problems today that also leave room to solutions in the future. The The libs team of course doesn't just blindly prioritize havinvg items "dumped in |
When we soon have |
Move std::os::raw::c_void into libcore and re-export in libstd Implements the first part of [RFC 2521](rust-lang/rfcs#2521). cc #53856
Re-export core::ffi::c_void if it exists This is the second part of the implementation of [RFC 2521](rust-lang/rfcs#2521), replacing the definition of `c_void` in libc with a re-export of the type from `core::ffi::c_void` on builds it exists for. This uses the re-export for rustc version `1.31.0` or greater, as `1.30.x` was the current nightly when [the PR for the changes to libcore and libstd](rust-lang/rust#53910) was merged, so I'm assuming the first nightly they will appear in will be `1.31.0`; is this acceptable? cc rust-lang/rust#53856
Just to let you know, in case you would like to raise objections or provide input, the rest of the C types in |
Unify
std::os::raw::c_void
andlibc::c_void
by making them both re-exports of a definition in libcore.Rendered