Skip to content

ntp sampler fails to build on musl libc (Alpine Linux) #216

@jirutka

Description

@jirutka

Describe the bug

ntp sampler fails to build on a system with musl libc (Alpine Linux):

error[E0425]: cannot find function `ntp_gettime` in crate `libc`
  --> src/samplers/ntp/mod.rs:94:37
   |
94 |         let status = unsafe { libc::ntp_gettime(&mut timeval) };
   |                                     ^^^^^^^^^^^ not found in `libc`

error[E0412]: cannot find type `ntptimeval` in crate `libc`
   --> src/samplers/ntp/mod.rs:128:34
    |
128 |   fn default_ntptimeval() -> libc::ntptimeval {
    |                                    ^^^^^^^^^^ help: a struct with a similar name exists: `timeval`
    | 
   ::: .cargo/registry/src/github.tiyicn.workers.dev-1ecc6299db9ec823/libc-0.2.82/src/unix/mod.rs:43:1
    |
43  | / s! {
44  | |     pub struct group {
45  | |         pub gr_name: *mut ::c_char,
46  | |         pub gr_passwd: *mut ::c_char,
...   |
195 | |     }
196 | | }
    | |_- similarly named struct `timeval` defined here

error[E0422]: cannot find struct, variant or union type `ntptimeval` in crate `libc`
   --> src/samplers/ntp/mod.rs:129:11
    |
129 |       libc::ntptimeval {
    |             ^^^^^^^^^^ help: a struct with a similar name exists: `timeval`
    | 
   ::: .cargo/registry/src/github.tiyicn.workers.dev-1ecc6299db9ec823/libc-0.2.82/src/unix/mod.rs:43:1
    |
43  | / s! {
44  | |     pub struct group {
45  | |         pub gr_name: *mut ::c_char,
46  | |         pub gr_passwd: *mut ::c_char,
...   |
195 | |     }
196 | | }
    | |_- similarly named struct `timeval` defined here

error: aborting due to 3 previous errors

To Reproduce
Steps to reproduce the behavior:

Build the project on Alpine Linux Edge.

  1. apk add build-base cargo
  2. wget https://github.com/twitter/rezolus/archive/v2.11.1.tar.gz && tar -xzf v2.11.1.tar.gz && cd rezolus-2.11.1
  3. cargo build --release --locked

Expected behavior
The build should complete successfully.

Environment

  • rust 1.51.0
  • musl libc 1.2.2
  • Alpine Linux Edge
  • x86_64

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions