Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUnify std::os::raw::c_void and libc::c_void via libcore #2521
Conversation
SimonSapin
added
the
T-libs
label
Aug 9, 2018
This comment has been minimized.
This comment has been minimized.
This was referenced Aug 9, 2018
This comment has been minimized.
This comment has been minimized.
|
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 comment has been minimized.
This comment has been minimized.
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. |
This comment has been minimized.
This comment has been minimized.
ExpHP
commented
Aug 9, 2018
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! |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
Re |
This comment has been minimized.
This comment has been minimized.
|
Even if we fix up |
This comment has been minimized.
This comment has been minimized.
|
it's true. For The |
This comment has been minimized.
This comment has been minimized.
|
Re: |
This comment has been minimized.
This comment has been minimized.
|
I was curious about this, and one way we could test this out would be to change libc today to reexport |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
Oh awesome! How should libc be prepared? Would a git branch suffice? Or something on crates.io? |
This comment has been minimized.
This comment has been minimized.
|
Git branch is sufficient, I believe. |
This comment has been minimized.
This comment has been minimized.
|
Ok! I've uploaded a branch to https://github.com/alexcrichton/libc/tree/c-void |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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)? |
This comment has been minimized.
This comment has been minimized.
|
As a point of data, |
This comment has been minimized.
This comment has been minimized.
|
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 comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
I think it would be a shame if we stabilized |
This comment has been minimized.
This comment has been minimized.
|
We could use the same configure-script-style-check to just optionally depend on the std one, no new core one needed. |
This comment has been minimized.
This comment has been minimized.
|
Since crater has shown that |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@Ericson2314 what @retep998 is proposing is not changing |
This comment has been minimized.
This comment has been minimized.
|
But why would someone use |
This comment has been minimized.
This comment has been minimized.
@retep998 a If crate Why would a |
This comment has been minimized.
This comment has been minimized.
|
@gnzlbg In the case where crate |
This comment has been minimized.
This comment has been minimized.
|
@gnzlbg This, incidentally, is a great example of why we have |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton Also, for what it's worth, I hope in those same ~2 years (while |
This comment has been minimized.
This comment has been minimized.
|
@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 |
rfcbot
added
the
finished-final-comment-period
label
Aug 31, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Aug 31, 2018
|
The final comment period, with a disposition to merge, as per the review above, is now complete. |
rfcbot
removed
the
final-comment-period
label
Aug 31, 2018
Centril
referenced this pull request
Aug 31, 2018
Open
Tracking issue for RFC 2521, "Unify std::os::raw::c_void and libc::c_void via libcore" #53856
Centril
merged commit 9bb8d58
into
rust-lang:master
Aug 31, 2018
This comment has been minimized.
This comment has been minimized.
|
Huzzah! This RFC has been merged! Tracking issue: rust-lang/rust#53856 |
This comment has been minimized.
This comment has been minimized.
|
Uh, don't the final comments need to wind down or something? This discussion seems ongoing. |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin Agreed this getting off topic, but as long as the portion of |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
faern
commented
Sep 1, 2018
|
When we soon have |
SimonSapin commentedAug 9, 2018
•
edited by Centril
Unify
std::os::raw::c_voidandlibc::c_voidby making them both re-exports of a definition in libcore.Rendered