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

Building 0.0.125 on i686-linux-android fails #3415

Open
ok300 opened this issue Nov 19, 2024 · 3 comments
Open

Building 0.0.125 on i686-linux-android fails #3415

ok300 opened this issue Nov 19, 2024 · 3 comments

Comments

@ok300
Copy link
Contributor

ok300 commented Nov 19, 2024

Building version 0.0.125 on 32 bit fails with

attempt to compute 184_usize - 192_usize, which would overflow

cargo ndk -t i686-linux-android build --release
...

error[E0080]: evaluation of constant value failed
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lightning-0.0.125/src/routing/scoring.rs:807:46
    |
807 | const _LIQUIDITY_MAP_SIZING_CHECK_2: usize = ::core::mem::size_of::<(u64, ChannelLiquidity)>() - 192;
    |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `184_usize - 192_usize`, which would overflow

For more information about this error, try `rustc --explain E0080`.
error: could not compile `lightning` (lib) due to 1 previous error

Maybe the 32 bit usize affects the ChannelLiquidity size calculation in _LIQUIDITY_MAP_SIZING_CHECK_2?

const _LIQUIDITY_MAP_SIZING_CHECK_2: usize = ::core::mem::size_of::<(u64, ChannelLiquidity)>() - 192;

This worked fine with the previous version we used, 0.0.118.

Is this a bug, or was support for 32 bit dropped in the meantime? Thanks.

@TheBlueMatt
Copy link
Collaborator

Oh interesting, we do release builds on android which built fine. What version of rustc are you using?

@TheBlueMatt
Copy link
Collaborator

Oh, I see your struct is smaller, yea, that maybe makes sense on some 32-bit platforms on newer rustc. Will fix anyway.

TheBlueMatt added a commit to TheBlueMatt/rust-lightning that referenced this issue Nov 23, 2024
We expect `ChannelLiquidity` to be exactly three cache lines to
ensure the first bytes we need are all one one cache line, but in
practice its a bit more ideal for `ChannelLiquidity`s to always
start on an even cache line as x86 CPUs will often load the
neighboring cache line automatically.

Further, it looks like some versions of `rustc` on some platforms
don't pack `ChannelLiquidity` as well (in lightningdevkit#3415) and the next
commit is going to push us over three cache lines anyway.

Instead, here we calculate out the proper padding for
`ChannelLiquidity` to make it align to four 64-byte cache lines.

Should fix lightningdevkit#3415.
@TheBlueMatt
Copy link
Collaborator

Should be fixed by #3422, at least.

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