-
Notifications
You must be signed in to change notification settings - Fork 673
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
Fix nix on Dragonfly #799
Fix nix on Dragonfly #799
Conversation
src/unistd.rs
Outdated
@@ -630,7 +630,7 @@ pub fn execvp(filename: &CString, args: &[CString]) -> Result<Void> { | |||
/// | |||
/// This function is similar to `execve`, except that the program to be executed | |||
/// is referenced as a file descriptor instead of a path. | |||
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", | |||
#[cfg(any(target_os = "android", target_os = "freebsd", |
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.
Can you alphabetize this list and wrap them with one target per line?
test/test_unistd.rs
Outdated
target_os = "netbsd", | ||
target_os = "openbsd", | ||
target_os = "linux", ))] { | ||
execve_test_factory!(test_execve, execve, &CString::new("/bin/sh").unwrap()); | ||
execve_test_factory!(test_fexecve, fexecve, File::open("/bin/sh").unwrap().into_raw_fd()); | ||
} else if #[cfg(any(target_os = "ios", target_os = "macos", ))] { | ||
} else if #[cfg(any(target_os = "ios", target_os = "macos", target_os = "dragonfly"))] { |
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.
Please keep the targets in alphabetical order.
Also, is there a reason this is kept as a separate crate inside nix? I'm not certain we can do that and still publish nix to crates.io honestly. Additionally it just seems like an odd organization, can we not integrate everything with a lot less boilerplate by having it be part of the |
@Susurrus : Added two further commits to address your suggestions. Dunno, why the buildbot is failing :( |
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.
Another thing that I don't see in here is documentation for why we need to do this or a reference to something within Rust or libc that we're waiting on to not need this workaround. I'd like to make sure that it's clear why we need this code here.
src/errno.rs
Outdated
unsafe fn errno_location() -> *mut c_int { | ||
extern { fn __dfly_error() -> *mut c_int; } | ||
__dfly_error() | ||
#[link(name="errno_dragonfly", kind="static")] |
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.
I thought this was thread-local. Do we just not use that yet because Rust doesn't support it on stable yet?
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.
Exactly. And it's unclear when this will become stable. The suggestion to use a C extension for this purpose came from @alexcrichton in this thread rust-lang/rust#29594 (comment)
@Susurrus Rebased on top of master, and stashed 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.
You'll want to rebase this once #800 lands as well.
src/sys/socket/ffi.rs
Outdated
@@ -5,7 +5,7 @@ pub use libc::{socket, listen, bind, accept, connect, setsockopt, sendto, recvfr | |||
|
|||
use libc::{c_int, c_void, socklen_t, ssize_t}; | |||
|
|||
#[cfg(not(target_os = "macos"))] | |||
#[cfg(not(any(target_os = "macos", target_os = "dragonfly")))] |
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.
These should be alphabetized as well.
src/sys/socket/ffi.rs
Outdated
#[cfg(target_os = "dragonfly")] | ||
pub type type_of_cmsg_data = c_int; | ||
|
||
#[cfg(not(any(target_os = "macos", target_os = "dragonfly")))] |
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.
Also alphabetized.
src/sys/socket/ffi.rs
Outdated
@@ -23,7 +23,10 @@ pub type type_of_cmsg_len = socklen_t; | |||
#[cfg(target_os = "macos")] |
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.
I'd actually suggest putting these in a cfg_if!
macro, as this will be a lot easier to understand.
@Susurrus Rebased, alphabetized and used the cfg_if! in socket/ffi.rs. Hoping it still builds everywhere and we are finally ready to merge :) |
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.
Just 2 minor changes, and then please squash all of these commits into 1 and we'll get this merged!
test/sys/mod.rs
Outdated
// works or not heavily depends on which pthread implementation is chosen | ||
// by the user at link time. For this reason we do not want to run aio test | ||
// cases on DragonFly. | ||
#[cfg(any(target_os = "freebsd", target_os = "ios", |
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.
Can you use a single OS per line as done in other places?
build.rs
Outdated
} | ||
|
||
#[cfg(not(target_os = "dragonfly"))] | ||
fn main() { |
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.
Please put the braces on the same line.
* DragonFly does not have a O_DSYNC flag * Fix type_of_cmsg_data on DragonFly * No fexecve() on DragonFly * Do not run aio test cases on DragonFly * Keep target lists in alphabetical order * Unscrable #[cfg] directives and use cfg_if! macro instead * Fix errno on DragonFly Below follows an explanation why we have to use a C extension to get errno working on DragonFly: DragonFly uses a thread-local errno variable, but #[thread_local] is feature-gated and not available in stable Rust as of this writing (Rust 1.21.0). We have to use a C extension (src/errno_dragonfly.c) to access it. Tracking issue for `thread_local` stabilization: rust-lang/rust#29594 Once this becomes stable, we can remove build.rs, src/errno_dragonfly.c, remove the build-dependency from Cargo.toml, and use: extern { #[thread_local] static errno: c_int; } Now all targets will use the build.rs script, but only on DragonFly this will do something. Also, there are no additional dependencies for targets other than DragonFly (no gcc dep).
@Susurrus : Fixed your above suggestions and squashed everything into one single commit. |
LGTM, thanks @mneumann! bors r+ |
799: Fix nix on Dragonfly r=Susurrus a=mneumann This commit replaces pull request #684. It fixes building `nix` on DragonFly. All tests pass. This requires most recent libc to build: rust-lang/libc#851.
@Susurrus : Thank you very much for your reviews :). |
This commit replaces pull request #684. It fixes building
nix
on DragonFly. All tests pass. This requires most recent libc to build: rust-lang/libc#851.