Skip to content

Commit e215ca9

Browse files
committed
devel/rust-cbindgen: Fix rust errno binding.
It looks like that rust-random/getrandom#54 has wrongly assigned us to Darwin case. The __error() is not libc callable function, but rather inline helper implemented at headers level to assist code that was using errno incorrectly. It seems that thread_local has still not become stable feature in rust? If this very useful language feature does not get official support soon enough in rust, it would be trivial for us to add simple helper function in libc using the most common __errno_location() variant out there. Since I could not figure out how to disable -Werror on this warning when using "extern { #[thread_local] static errno: c_int; }", just bringing back the previous crate helper that worked (using google search).
1 parent 77e9b84 commit e215ca9

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
#
2-
# XXX - The current logic in Mk/Uses/cargo.mk will try to append
3-
# LDFLAGS to RUSTFLAGS (via -C link-arg) but it turns out that as
4-
# we don't define LDFLAGS for this port, it will pass an empty arg
5-
# which rustc converts into "" and gcc doesn't like that. It produces
6-
# a 'No such file or directory' error.
7-
#
8-
# Add a dummy argument to the $CC call so that the build succeeds.
9-
LDFLAGS="-v"
1+
2+
CARGO_CRATES+= gcc-0.3.55 errno-dragonfly-0.1.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- distinfo.orig 2019-08-28 19:53:49 UTC
2+
+++ distinfo
3+
@@ -73,3 +73,7 @@ SHA256 (rust/crates/winapi-i686-pc-windo
4+
SIZE (rust/crates/winapi-i686-pc-windows-gnu-0.4.0.tar.gz) = 2918815
5+
SHA256 (rust/crates/winapi-x86_64-pc-windows-gnu-0.4.0.tar.gz) = 712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f
6+
SIZE (rust/crates/winapi-x86_64-pc-windows-gnu-0.4.0.tar.gz) = 2947998
7+
+SHA256 (rust/crates/gcc-0.3.55.tar.gz) = 8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2
8+
+SIZE (rust/crates/gcc-0.3.55.tar.gz) = 37262
9+
+SHA256 (rust/crates/errno-dragonfly-0.1.1.tar.gz) = 14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067
10+
+SIZE (rust/crates/errno-dragonfly-0.1.1.tar.gz) = 1370
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--- cargo-crates/getrandom-0.1.11/Cargo.toml.intermediate 2019-09-06 14:30:19.000000000 +0000
2+
+++ cargo-crates/getrandom-0.1.11/Cargo.toml
3+
@@ -33,6 +33,9 @@ version = "1.0"
4+
optional = true
5+
package = "rustc-std-workspace-core"
6+
7+
+[dependencies.errno-dragonfly]
8+
+version = "0.1.1"
9+
+
10+
[dependencies.log]
11+
version = "0.4"
12+
optional = true
13+
--- cargo-crates/getrandom-0.1.11/src/util_libc.rs.orig 2019-08-24 23:12:51 UTC
14+
+++ cargo-crates/getrandom-0.1.11/src/util_libc.rs
15+
@@ -10,6 +10,7 @@ use crate::util::LazyUsize;
16+
use crate::Error;
17+
use core::num::NonZeroU32;
18+
use core::ptr::NonNull;
19+
+extern crate errno_dragonfly;
20+
21+
cfg_if! {
22+
if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android"))] {
23+
@@ -18,10 +19,13 @@ cfg_if! {
24+
use libc::__errno_location as errno_location;
25+
} else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] {
26+
use libc::___errno as errno_location;
27+
- } else if #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly"))] {
28+
+ } else if #[cfg(any(target_os = "macos", target_os = "freebsd"))] {
29+
use libc::__error as errno_location;
30+
} else if #[cfg(target_os = "haiku")] {
31+
use libc::_errnop as errno_location;
32+
+ } else if #[cfg(target_os = "dragonfly")] {
33+
+ // soon will be use libc::__errno_location as errno_location;
34+
+ use errno_dragonfly::errno_location;
35+
}
36+
}
37+

0 commit comments

Comments
 (0)