zng-ui / zng

Cross-platform GUI framework.
Apache License 2.0
44 stars 0 forks source link

Android miscompilation with lto=fat #488

Open SamRodri opened 4 days ago

SamRodri commented 4 days ago

Building a project that depends on zng with release-lto profile for target aarch64-linux-android causes miscompilation of this function:

pub fn test() {
    use zng::layout::*;
    // (Rect(3240pxx7200px at (-1080px, -2400px)), Rect(1080pxx90px at (0px, 0px))
    let cull = std::hint::black_box(PxRect::new(PxPoint::new(Px(-1080), Px(-2400)), PxSize::new(Px(3240), Px(7200))));
    let bounds = std::hint::black_box(PxRect::new(PxPoint::new(Px(0), Px(0)), PxSize::new(Px(1080), Px(90))));
    let i = cull.intersection(&bounds);
    println!("{:?}", i);
}

The function prints Some(_) correctly if compiled at the start of main, but prints None if compiled on a touch event handler.

I tested both "fat" and "thin" LTO, both can fail. I have not managed to reduce the reproducer project, just replacing the dependencies to the minimal required to compile causes it to always work.

SamRodri commented 3 days ago

Test project here: https://github.com/SamRodri/miscomp-issue

Build from Github Ubuntu, Windows and maOS also miscompile. Working on reducing the test now.

SamRodri commented 3 days ago

Testing with "thin" again, it looks like it works actually, both local builds and from GitHub runners, I may have messed up the previous test.

Edit: tested the template gain, it failed with "thin" too.