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

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

Closed
jirutka opened this issue Apr 13, 2021 · 1 comment
Closed

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

jirutka opened this issue Apr 13, 2021 · 1 comment
Assignees

Comments

@jirutka
Copy link

jirutka commented Apr 13, 2021

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.com-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.com-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.

brayniac added a commit to brayniac/rezolus-twitter that referenced this issue Apr 26, 2021
The NTP sampler uses some libc functions which are present in
glibc but not in musl libc. This causes the build to fail under
Alpine as reported in twitter#216

Fixes the build issue by specializing the NTP sampler using
conditional compilation for the target env. Currently, this means
that the NTP sampling is a no-op for musl targets.

Adds a simple build-only CI pass for a musl target, which is
appropriate given that the musl target is tier 2 for Rust, meaning
it is only guaranteed to build and may not product a working
build.

Rezolus should now build for musl target.
@brayniac brayniac self-assigned this Apr 26, 2021
brayniac added a commit that referenced this issue Apr 26, 2021
The NTP sampler uses some libc functions which are present in
glibc but not in musl libc. This causes the build to fail under
Alpine as reported in #216

Fixes the build issue by specializing the NTP sampler using
conditional compilation for the target env. Currently, this means
that the NTP sampling is a no-op for musl targets.

Adds a simple build-only CI pass for a musl target, matching its
tier 2 status for Rust overall.
@brayniac
Copy link
Contributor

Thanks for reporting.

Fixed by #218

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

No branches or pull requests

2 participants