-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add __errno_location on Redox, DragonFlyBSD, Haiku #1432
Conversation
r? @gnzlbg (rust_highfive has picked a reviewer for you, use r? to override) |
@bors: r+ Thanks! |
📌 Commit 4fc38ca has been approved by |
Add __errno_location on Redox, DragonFlyBSD, Haiku Currently [`libstd`](https://github.com/rust-lang/rust/blob/909f5a049415a815b23502a5498de9a99bbf276b/src/libstd/sys/unix/os.rs#L29-L49) and the [`getrandom` crate](https://github.com/rust-random/getrandom/pull/54/files#diff-027a56068e2bf3d31dc4273ee6e07034R12) have to use external declarations in order to implement `errno_location` across all UNIX platforms. This change adds bindings for the remaining UNIX platforms, allowing everyone to just use normal `libc` bindings. This also removes the need for a seperate [`errno-dragonfly`](https://crates.io/crates/errno-dragonfly) crate. Links to the relevant header files: - Redox: [`relibc`'s `bits/errno.h`](https://github.com/redox-os/relibc/blob/master/include/bits/errno.h) uses `__errno_location` - Haiku: [`posix/errno.h`](https://github.com/luciang/haiku/blob/master/headers/posix/errno.h) uses `_errnop` - DragonFlyBSD: [`sys/errno.h`](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/errno.h) uses `__error` just like FreeBSD (which makes sense) - Note that the `__error` function is inlined. I don't think this causes a problem.
@bors: r- The paths need fixing. |
💔 Test failed - checks-travis |
Copy paste bites again, should be fixed now. |
Thanks! @bors: r+ |
📌 Commit e9c1ade has been approved by |
Add __errno_location on Redox, DragonFlyBSD, Haiku Currently [`libstd`](https://github.com/rust-lang/rust/blob/909f5a049415a815b23502a5498de9a99bbf276b/src/libstd/sys/unix/os.rs#L29-L49) and the [`getrandom` crate](https://github.com/rust-random/getrandom/pull/54/files#diff-027a56068e2bf3d31dc4273ee6e07034R12) have to use external declarations in order to implement `errno_location` across all UNIX platforms. This change adds bindings for the remaining UNIX platforms, allowing everyone to just use normal `libc` bindings. This also removes the need for a seperate [`errno-dragonfly`](https://crates.io/crates/errno-dragonfly) crate. Links to the relevant header files: - Redox: [`relibc`'s `bits/errno.h`](https://github.com/redox-os/relibc/blob/master/include/bits/errno.h) uses `__errno_location` - Haiku: [`posix/errno.h`](https://github.com/luciang/haiku/blob/master/headers/posix/errno.h) uses `_errnop` - DragonFlyBSD: [`sys/errno.h`](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/errno.h) uses `__error` just like FreeBSD (which makes sense) - Note that the `__error` function is inlined. I don't think this causes a problem.
💔 Test failed - status-appveyor |
Note that both std and errno-dragonfly seem to implement this differently than what's in this PR for Dragonfly. Was that intentional? |
cc @strangelittlemonkey - could you review the dragonfly impl ? |
cc @sikmir could you review this for haiku? |
This was intentional. Implementing The only difference between DragonFlyBSD an all the other UNIXes is that static __inline int *__error(void) { ... } in the header file (see the above link). I think Rust can handle such a function OK, but that could be the reason for the difference. |
Interesting. The N.B. I am speaking from ignorance here. I'm only asking these questions because I'm curious. :-) |
The DragonflyBSD defines extern __thread int errno;
static __inline int* __error() { return &errno; } This: extern __thread int errno;
int* foo() { return &errno; } emits: define dso_local i32* @foo() #0 {
ret i32* @errno
} Notice the I think that in Rust we would need: |
Also cc @joshtriplett: there is no stable Rust way to link against |
I don't think so. They can't create a pointer to the |
|
@eddyb so we lower the @errno = external thread_local global i32 clang lowers this to: @errno = external thread_local global i32, align 4 So I think |
@josephlr we do have a cargo feature I don't think there is a pure Rust solution available for stable Rust users. Linking to a C snippet that returns a pointer to the thread local like the |
Could that platform's |
@eddyb sure, and libstd enables the "unstable" feature, so it can make use of this to simplify the implementation. The |
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.
This is correct for Redox
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.
LGTM
@gnzlbg that works, I’ll make the change to add |
It turns out the CI is failing due to a transitive All the errors (as far as I can tell) are related to this bug, so the breakage is not caused by this PR. |
You’re fine to write DragonFly code for something needing nightly but it’s dead code because we have no nightly build and I’m not sure we’ll ever have nightly support or a nightly build even. If you’re requiring nightly you should take DragonFly off the support list for the crate or any other like that because it would just be misleading.
… On Jul 10, 2019, at 9:06 PM, Joseph Richey ***@***.***> wrote:
It turns out the CI is failing due to a transitive serde_derive dependency, which is breaking because of rust-lang/rust#62562
All the errors (as far as I can tell) are related to this bug, so the breakage is not caused by this PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@strangelittlemonkey "nightly" is misleading - what's important here is "unstable", which is allowed for any dependency of Even if users of |
@strangelittlemonkey or in other words, when the compiler is compiling itself, which is something that has to be done to build a compiler for DragonflyBSD, it can use unstable features that are generally only available on nightly. |
I’m just saying requiring nightly to build it at all would make DragonFly a moot point, but allowing extra features if building with nightly would be different and fine, but still dead code if it applied to DragonFly specifically.
… On Jul 11, 2019, at 9:24 AM, gnzlbg ***@***.***> wrote:
@strangelittlemonkey or in other words, when the compiler is compiling itself, which is something that has to be done to build a compiler for DragonflyBSD, it can use unstable features that are generally only available on nightly.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
It's the latter, we're talking about an opt-in way to enable Like I said before, that opt-in would be enabled by So when you build any future release of Rust (including stable ones) for DragonFlyBSD, the So, yes, it's dead code for normal users of this crate, but would still be needed and used for the standard library (which does its OS FFI through this very same crate). |
@gnzlbg rust-lang/rust#62562 has been fixed, so the CI is passing again @strangelittlemonkey Nightly build issues aside, the code added in this PR is required to build I updated the docs to point out why we need |
Just to triple check, is there any crate that wants to use this from crates.io ? If not, then we don't need the |
Initially the thought was to also use this for
Sounds good, I'll make the change unless anyone else wants to use this. |
@josephlr you can chime in in the |
Yes. |
OK, as |
Looking at the tracking issue, and the Maybe we could reduce the scope of an initial version of |
@gnzlbg I removed the |
Thanks! @bors: r+ |
📌 Commit df34d17 has been approved by |
Add __errno_location on Redox, DragonFlyBSD, Haiku Currently [`libstd`](https://github.com/rust-lang/rust/blob/909f5a049415a815b23502a5498de9a99bbf276b/src/libstd/sys/unix/os.rs#L29-L49) and the [`getrandom` crate](https://github.com/rust-random/getrandom/pull/54/files#diff-027a56068e2bf3d31dc4273ee6e07034R12) have to use external declarations in order to implement `errno_location` across all UNIX platforms. This change adds bindings for the remaining UNIX platforms, allowing everyone to just use normal `libc` bindings. This also removes the need for a seperate [`errno-dragonfly`](https://crates.io/crates/errno-dragonfly) crate. Links to the relevant header files: - Redox: [`relibc`'s `bits/errno.h`](https://github.com/redox-os/relibc/blob/master/include/bits/errno.h) uses `__errno_location` - Haiku: [`posix/errno.h`](https://github.com/luciang/haiku/blob/master/headers/posix/errno.h) uses `_errnop` - DragonFlyBSD: [`sys/errno.h`](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/errno.h) uses `__error` just like FreeBSD (which makes sense) - Note that the `__error` function is inlined. I don't think this causes a problem.
☀️ Test successful - checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, checks-travis, status-appveyor |
libc 0.2.60 has been published with this - I'll update libc on rust-lang/rust |
Currently
libstd
and thegetrandom
crate have to use external declarations in order to implementerrno_location
across all UNIX platforms. This change adds bindings for the remaining UNIX platforms, allowing everyone to just use normallibc
bindings.This also removes the need for a seperate
errno-dragonfly
crate.Links to the relevant header files:
relibc
'sbits/errno.h
uses__errno_location
posix/errno.h
uses_errnop
sys/errno.h
uses__error
just like FreeBSD (which makes sense)__error
function is inlined. I don't think this causes a problem.