build fail with either lto or static, aarch64 debian sid
I am building on aarch64, rock 3a rk3568 with GNU 13.2.0, kernel 6.7-arm64. I cloned repo with --recursive so I have all external dependencies available, and my system also have libzmq3-dev installed (debian sid).

Setting manual C and CXX flags to LTO and static gives this (somewhat expected)

>     C_FLAGS:         -O3 -flto -static -march=native -pthread -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 -Wall -Wextra -Wcast-qual -Wlogical-op -Wstrict-overflow=2 -Wundef -Wformat=2 -Wpointer-arith -Werror -Ofast -s -flto -fuse-linker-plugin
>     CXX_FLAGS:       -O3 -flto -static -march=native -pthread -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 -Wall -Wextra -Wcast-qual -Wlogical-op -Wstrict-overflow=2 -Wundef -Wformat=2 -Wpointer-arith -Werror -Ofast -s -flto -fuse-linker-plugin
> /usr/bin/ld: attempted static link of dynamic object `/usr/lib/aarch64-linux-gnu/libzmq.so'
> collect2: error: ld returned 1 exit status

I found the option in CMakeLists.txt for STATIC_BINARY and STATIC_LIBS so I then ran this

> CFLAGS="-O3 -flto -march=native -static" CXXFLAGS="-O3 -flto -march=native -static" cmake ../ -DSTATIC_BINARY=ON -DSTATIC_LIBS=ON -DWITH_RANDOMX=ON -DWITH_LTO=ON -DWITH_UPNP=OFF

I don't think my flags are affecting anything because -Ofast and -flto are specified later in the build command, overwriting mine. The output of this gives

> make[2]: *** No rule to make target '/home/knuxyl/p2pool/external/src/libzmq/build/lib/libzmq.a', needed by 'p2pool'.  Stop.

So my first attempt tried to static link a dynamic library, and then the second attempt tried to include the static library but there was no rule to make it.

My third attempt I removed "-static" from the flags but kept the CMake defines and I still get the same error

> make[2]: *** No rule to make target '/home/knuxyl/p2pool/external/src/libzmq/build/lib/libzmq.a', needed by 'p2pool'.  Stop.

Also I should note that the C and CXX flags generated by CMake include fixes for cortex A53, but this cpu is a quad core A55. I'm not sure why these are being included, I'm guessing a GCC thing so not relevant here.
> -mfix-cortex-a53-835769 -mfix-cortex-a53-843419

EDIT

Disabling LTO and Static will allow it to build, but no combination of lto and/or static will work. Either one of those options causes the build to fail.