Closed jtmoon79 closed 6 months ago
tl;dr A good way to allow Alpine builds is using #[cfg(accessible(..))]
, e.g.
// if not defined __timeval then define it
#[cfg(not(accessible(::uapi::c::__timeval)))]
#[doc(hidden)]
#[derive(Clone, Copy)]
#[repr(C)]
pub struct __timeval {
pub tv_sec: i32,
pub tv_usec: i32,
}
These uapi
imports have been handled by conditional compilation based on target_os
. See https://github.com/jtmoon79/super-speedy-syslog-searcher/blob/0.5.59/src/data/utmpx.rs#L33-L117
But there is currently no way to further distinguish at build-time that this is Alpine Linux, e.g. there is no #[cfg(target_os_flavor = "Alpine")]
.
The ideal mechanism is cfg(accessible)
. This could be used to entirely replace conditional compilation based on target_os
and would be more reliable.
Currently, #[cfg(accessible(..))]
is still unimplemented https://github.com/rust-lang/rust/issues/64797
Version 0.6.62
fails less
Compiling super_speedy_syslog_searcher v0.6.62
error[E0432]: unresolved import `uapi::c::__timeval`
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/super_speedy_syslog_searcher-0.6.62/src/data/utmpx.rs:118:13
|
118 | __timeval,
| ^^^^^^^^^
| |
| no `__timeval` in `c`
| help: a similar name exists in the module: `timeval`
Verified this built on Alpine 3.17 x64.
Summary
cargo install super_speedy_syslog_searcher
fails on Alpine Linux 3.17.Current behavior
Reviewing the resident
utmpx.h
,Indeed, there is a
utmpx.ut_tv
but noutmpx.__timeval
.Suggested behavior
It should build and install.
Environment: