Skip to content
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 netbsd kevent for breakage introduced by libc #790

Merged
merged 2 commits into from
Nov 5, 2017

Conversation

Susurrus
Copy link
Contributor

@Susurrus Susurrus commented Nov 5, 2017

No description provided.

@Susurrus Susurrus force-pushed the fix_netbsd_kevent branch 2 times, most recently from f167c8e to f100d4e Compare November 5, 2017 16:47
@asomers
Copy link
Member

asomers commented Nov 5, 2017

So to be clear, the problem is that libc switched kevent.filter from i32 to u32? In addition to fixing Nix for 0.10.0, should we release a 0.9.1 that contains a maximum allowed version of libc in Cargo.toml to prevent people from running into this problem?

@Susurrus
Copy link
Contributor Author

Susurrus commented Nov 5, 2017

Probably. What we should definitely do during a release is to use a locked version of libc instead of specifying a minimum version. Because their backwards compatibility guarantees are different from ours.

@asomers asomers added this to the 0.10.0 milestone Nov 5, 2017
@asomers
Copy link
Member

asomers commented Nov 5, 2017

Supposedly libc always guarantees backwards compatibility. In the past, they've even refused to let me fix buggy definitions because it would break backwards compatibility. This kevent business is the first time I've seen otherwise.

@Susurrus
Copy link
Contributor Author

Susurrus commented Nov 5, 2017

@asomers They only guarantee backwards compatibility for certain targets (Tier 1 I think), not all targets, since that doesn't match our target list, we have this issue.

src/sys/event.rs Outdated
libc_enum!{
#[cfg_attr(target_os = "netbsd", repr(u32))]
#[cfg_attr(not(target_os = "netbsd"), repr(i16))]
#[derive(Clone, Copy, Debug, PartialEq)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the build is breaking because all of these derived things are also derived by libc_enum!.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, WIP since I don't know how to crosscompile to these platforms from Linux.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross compiling is blissfully easy. It's the best thing about FFI. If you use rustup, you can do something like rustup target add i686-unknown-freebsd then cargo build --target=i686-unknown-freebsd.

src/sys/event.rs Outdated
EVFILT_VM = libc::EVFILT_VM,
EVFILT_VNODE = libc::EVFILT_VNODE,
EVFILT_WRITE = libc::EVFILT_WRITE,
cfg_if!{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use a cfg_if! instead of just plain #[cfg()] like the old code did?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remnant of my first revision. This was supposed to make things clearer, but can you can't put the cfg_attr(..., repr(..)) inside it, so it's less useful.

@Susurrus Susurrus changed the title Fix netbsd kevent for breakage introduced by libc [WIP] Fix netbsd kevent for breakage introduced by libc Nov 5, 2017
The datatype for kevent.filter is u32 on NetBSD and
i16 on all other supported platforms. This was recently
fixed in upstream libc, breaking this API, so this
fixes it.

This change also modernizes the code a bit to unify the
EventFilter datatype across platforms and switch to the
libc_enum! macro.
@asomers asomers mentioned this pull request Nov 5, 2017
@Susurrus Susurrus changed the title [WIP] Fix netbsd kevent for breakage introduced by libc Fix netbsd kevent for breakage introduced by libc Nov 5, 2017
@Susurrus
Copy link
Contributor Author

Susurrus commented Nov 5, 2017

@asomers I think this should be GTM, please review.

@asomers
Copy link
Member

asomers commented Nov 5, 2017

Everything LGTM

bors r+

bors bot added a commit that referenced this pull request Nov 5, 2017
790: Fix netbsd kevent for breakage introduced by libc r=asomers a=Susurrus
@bors
Copy link
Contributor

bors bot commented Nov 5, 2017

@bors bors bot merged commit 5a7d5b1 into nix-rust:master Nov 5, 2017
@Susurrus Susurrus deleted the fix_netbsd_kevent branch November 5, 2017 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants