tikv / rust-prometheus

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

Compile latest version failed on Linux #454

Closed rts-gordon closed 2 years ago

rts-gordon commented 2 years ago

Hi there, I can't compile latest source code on Linux, would anybody like to have a look at this, many thanks.

Describe the bug Compile latest version of "rust-prometheus" failed on Linux

System information

To Reproduce Steps to reproduce the behavior:

  1. git clone https://github.com/tikv/rust-prometheus.git
  2. cd rust-prometheus
  3. cargo run --features="process" --example example_process_collector

There are compile errors:

error[E0658]: `const extern fn` definitions are unstable
    --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.132/src/macros.rs:188:17
     |
188  | /                 pub $($constness)* unsafe extern fn $i($($arg: $argty),*
189  | |                 ) -> $ret {
190  | |                     $($body);*
191  | |                 }
     | |_________________^
     |
    ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.132/src/unix/linux_like/mod.rs:1499:1
     |
1499 | / f! {
1500 | |     pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
1501 | |         if (*mhdr).msg_controllen as usize >= ::mem::size_of::<cmsghdr>() {
1502 | |             (*mhdr).msg_control as *mut cmsghdr
...    |
1545 | |     }
1546 | | }
     | |_- in this macro invocation
     |
     = note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
     = help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
     = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: `const extern fn` definitions are unstable
    --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.132/src/macros.rs:203:17
     |
203  | /                 pub $($constness)* extern fn $i($($arg: $argty),*
204  | |                 ) -> $ret {
205  | |                     $($body);*
206  | |                 }
     | |_________________^
     |
    ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.132/src/unix/linux_like/mod.rs:1548:1
     |
1548 | / safe_f! {
1549 | |     pub fn SIGRTMAX() -> ::c_int {
1550 | |         unsafe { __libc_current_sigrtmax() }
1551 | |     }
...    |
1615 | |     }
1616 | | }
     | |_- in this macro invocation
     |
     = note: see issue #64926 <https://github.com/rust-lang/rust/issues/64926> for more information
     = help: add `#![feature(const_extern_fn)]` to the crate attributes to enable
     = note: this error originates in the macro `safe_f` (in Nightly builds, run with -Z macro-backtrace for more info)

Expected behavior program can be compile and run on Linux.

lucab commented 2 years ago

Rustc 1.62.0-nightly (8f36334ca 2022-04-06)

Thanks for the report. I think this build failure is due to your toolchain, which is an ancient unstable one. Please consider using the official stable toolchain, or upgrade to a newer nightly one (current one is 1.65.0-nightly).