libbpf-sys icon indicating copy to clipboard operation
libbpf-sys copied to clipboard

32 bit build broken?

Open danielocfb opened this issue 2 years ago • 1 comments

In response to https://github.com/libbpf/libbpf-rs/issues/500 I created https://github.com/danielocfb/libbpf-sys/commit/5e93a20fecc8ca9e9823449d8e8ea388003511d2 to make sure that libbpf-sys is also tested in a 32 bit setting. That seems to blow up pretty prominently immediately: https://github.com/danielocfb/libbpf-sys/actions/runs/5479871661/jobs/9982296567

--> src/bindings.rs:512:49
    |
512 | pub const PERF_TXN_ABORT_MASK: _bindgen_ty_52 = 18446744069414584320;
    |                                                 ^^^^^^^^^^^^^^^^^^^^
    |
    = note: the literal `18446744069414584320` does not fit into the type `u32` whose range is `0..=4294967295`
    = note: `#[deny(overflowing_literals)]` on by default

error: literal out of range for `u32`
    --> src/bindings.rs:1478:53
     |
1478 | pub const PERF_CONTEXT_HV: perf_callchain_context = 18446744073709551584;
     |                                                     ^^^^^^^^^^^^^^^^^^^^
     |
     = note: the literal `18446744073709551584` does not fit into the type `u32` whose range is `0..=4294967295`

error: literal out of range for `u32`
    --> src/bindings.rs:1479:57
     |
1479 | pub const PERF_CONTEXT_KERNEL: perf_callchain_context = 18446744073709551488;
     |                                                         ^^^^^^^^^^^^^^^^^^^^
     |
     = note: the literal `18446744073709551488` does not fit into the type `u32` whose range is `0..=4294967295`

error: literal out of range for `u32`
    --> src/bindings.rs:1480:55
     |
1480 | pub const PERF_CONTEXT_USER: perf_callchain_context = 18446744073709551104;
     |                                                       ^^^^^^^^^^^^^^^^^^^^
     |
     = note: the literal `18446744073709551104` does not fit into the type `u32` whose range is `0..=4294967295`

error: literal out of range for `u32`
    --> src/bindings.rs:1481:56
     |
1481 | pub const PERF_CONTEXT_GUEST: perf_callchain_context = 18446744073709549568;
     |                                                        ^^^^^^^^^^^^^^^^^^^^
     |
     = note: the literal `18446744073709549568` does not fit into the type `u32` whose range is `0..=4294967295`

error: literal out of range for `u32`
    --> src/bindings.rs:1482:63
     |
1482 | pub const PERF_CONTEXT_GUEST_KERNEL: perf_callchain_context = 18446744073709549440;
     |                                                               ^^^^^^^^^^^^^^^^^^^^
     |
     = note: the literal `18446744073709549440` does not fit into the type `u32` whose range is `0..=4294967295`

error: literal out of range for `u32`
    --> src/bindings.rs:1483:61
     |
1483 | pub const PERF_CONTEXT_GUEST_USER: perf_callchain_context = 18446744073709549056;
     |                                                             ^^^^^^^^^^^^^^^^^^^^
     |
     = note: the literal `18446744073709549056` does not fit into the type `u32` whose range is `0..=4294967295`

error: literal out of range for `u32`
    --> src/bindings.rs:1484:54
     |
1484 | pub const PERF_CONTEXT_MAX: perf_callchain_context = 18446744073709547521;
     |                                                      ^^^^^^^^^^^^^^^^^^^^
     |
     = note: the literal `18446744073709547521` does not fit into the type `u32` whose range is `0..=4294967295`

error: literal out of range for `u32`
    --> src/bindings.rs:2908:47
     |
2908 | pub const BPF_F_CTXLEN_MASK: _bindgen_ty_65 = 4503[59](https://github.com/danielocfb/libbpf-sys/actions/runs/5479871661/jobs/9982296567#step:8:60)5332403200;
     |                                               ^^^^^^^^^^^^^^^^
     |
     = note: the literal `4503595332403200` does not fit into the type `u32` whose range is `0..=4294967295`

error: could not compile `libbpf-sys` (lib) due to 9 previous errors

Any idea how we can adjust the type of those constants, by any chance? I haven't found any knobs.

danielocfb avatar Jul 06 '23 20:07 danielocfb

There's no way to fixup the bindings right now. See these for more background (same underlying issue)...

  • https://github.com/libbpf/libbpf-sys/issues/27
  • https://github.com/libbpf/libbpf-sys/issues/33

I prefer to continue generating bindings ahead-of-time, rather than forcing every user of this library run bindgen. I think we could generate bindings for multiple platforms, and then conditionally include the correct binding file for the platform here: https://github.com/libbpf/libbpf-sys/blob/0be89351f28ff88ade996cc99b5fc263b4f47e14/src/lib.rs#L7

alexforster avatar Jul 21 '23 15:07 alexforster