Skip to content

Fix build on FreeBSD#815

Merged
Osspial merged 3 commits intomasterfrom
unknown repository
Mar 22, 2019
Merged

Fix build on FreeBSD#815
Osspial merged 3 commits intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Mar 17, 2019

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Note that I only tested on FreeBSD. The OpenBSD and NetBSD bits are a pure guess on my part based on libc documentation and their errno.h [2,3,4,5].

[1] FreeBSD: https://rust-lang.github.io/libc/x86_64-unknown-freebsd/libc/fn.__error.html
[2] NetBSD: https://rust-lang.github.io/libc/x86_64-unknown-netbsd/libc/fn.__errno.html
[3] NetBSD: https://github.com/NetBSD/src/blob/trunk/include/errno.h
[4] OpenBSD: https://rust-lang.github.io/libc/x86_64-unknown-openbsd/libc/fn.__errno.html
[5] OpenBSD: https://github.com/OpenBSD/src/blob/master/include/errno.h

@ghost
Copy link
Copy Markdown
Author

ghost commented Mar 17, 2019

An alternative solution might be to use the errno crate to access errno in a cross-platform way.

https://crates.io/crates/errno

@elinorbgr
Copy link
Copy Markdown
Contributor

Hi, thanks for the PR!

Just as a stylistic nitpick, maybe it'd be better to just rename the imports, to avoid littering #[cfg()] markers all over the source, given this is apparently just a name change.

I'm thinking something like:

#[cfg(target_os = "linux")]
use libc::__errno_location;
#[cfg(target_os = "freebsd")]
use libc::__error as __errno_location;
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
use libc::__errno as __errno_location;

Do we have any strong stylistic constraints wrt to this ? @francesca64 @Osspial ?

@ghost
Copy link
Copy Markdown
Author

ghost commented Mar 20, 2019

I've changed it as you've suggested. Anything else I can to do to get this merged?

@Osspial
Copy link
Copy Markdown
Contributor

Osspial commented Mar 21, 2019

The only thing I can see blocking this is a lack of changelog entry. We should be able to merge this once that's added in.

@ghost
Copy link
Copy Markdown
Author

ghost commented Mar 21, 2019

Added one.

Tobias Kortkamp added 3 commits March 21, 2019 19:13
error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <t@tobik.me>
Signed-off-by: Tobias Kortkamp <t@tobik.me>
Signed-off-by: Tobias Kortkamp <t@tobik.me>
@Osspial Osspial merged commit 0019ff2 into rust-windowing:master Mar 22, 2019
elinorbgr pushed a commit to elinorbgr/winit that referenced this pull request Apr 7, 2019
* Fix build on FreeBSD

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <t@tobik.me>

* Import __error / __errno on *BSD as __errno_location

Signed-off-by: Tobias Kortkamp <t@tobik.me>

* Add changelog entry

Signed-off-by: Tobias Kortkamp <t@tobik.me>
elinorbgr pushed a commit to elinorbgr/winit that referenced this pull request Apr 7, 2019
* Fix build on FreeBSD

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <t@tobik.me>

* Import __error / __errno on *BSD as __errno_location

Signed-off-by: Tobias Kortkamp <t@tobik.me>

* Add changelog entry

Signed-off-by: Tobias Kortkamp <t@tobik.me>
felixrabe pushed a commit to felixrabe/winit that referenced this pull request Jun 30, 2019
* Fix build on FreeBSD

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <t@tobik.me>

* Import __error / __errno on *BSD as __errno_location

Signed-off-by: Tobias Kortkamp <t@tobik.me>

* Add changelog entry

Signed-off-by: Tobias Kortkamp <t@tobik.me>
kosyak pushed a commit to kosyak/winit that referenced this pull request Jul 10, 2019
* Fix build on FreeBSD

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <t@tobik.me>

* Import __error / __errno on *BSD as __errno_location

Signed-off-by: Tobias Kortkamp <t@tobik.me>

* Add changelog entry

Signed-off-by: Tobias Kortkamp <t@tobik.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants