tikv / rust-prometheus

Prometheus instrumentation library for Rust applications
Apache License 2.0
1.05k stars 182 forks source link

cross-compilation broken for 32-bit builds #442

Closed Kiskae closed 2 years ago

Kiskae commented 2 years ago

Describe the bug when cross-compiling for 32-bit linux, the libc::sysconf call returns a 32-bit integer which is incompatible with the i64 it wants to be stored in.

PR #430 made this change but it also removed the cast that made the previous version work on all platforms.

To Reproduce

Cross-compile using the i686-unknown-linux-musl target.

Error: --> /cargo/registry/src/github.com-1ecc6299db9ec823/prometheus-0.13.1/src/process_collector.rs:199:13 197 static ref PAGESIZE: i64 = { --- expected i64 because of return type 198 unsafe { 199 libc::sysconf(libc::_SC_PAGESIZE) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected i64, found i32

help: you can convert an i32 to an i64 | 199 | libc::sysconf(libc::_SC_PAGESIZE).into() | +++++++

For more information about this error, try rustc --explain E0308. error: could not compile prometheus due to 2 previous errors

Expected behavior There is no reason why it shouldn't be able to compile on 32-bit systems.

System information

Additional context Ran into this problem while building multi-arch docker images. It might be an idea to add cross-compilation to CI to catch problems like this in the future