Using master @ d73f37dda221835b5109ede1b84db2dc7c4b74a1.
The following seems incorrect, because
make -C depends/ NO_QT=1 NO_WALLET=1 NO_ZMQ=1 -j18 CFLAGS="-O3" CXXFLAGS="-O3"
cmake -B build --toolchain /root/ci_scratch/depends/aarch64-unknown-linux-gnu/toolchain.cmake
<snip>
C++ compiler flags .................... -O3 -O2 -g
Linker flags .......................... -O3 -O2 -g
is overriding the user-provided -O3.
If you configure by providing an explicit -DCMAKE_BUILD_TYPE=RelWithDebInfo, you get:
cmake -B build --toolchain /root/ci_scratch/depends/aarch64-unknown-linux-gnu/toolchain.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo
C++ compiler flags .................... -O3
Linker flags .......................... -O3
No -O2 at all, so the user provided -O3 is used (also missing -g for debug info?).
If you configure with -DCMAKE_BUILD_TYPE=Release:
cmake -B build --toolchain /root/ci_scratch/depends/aarch64-unknown-linux-gnu/toolchain.cmake -DCMAKE_BUILD_TYPE=Release
C++ compiler flags .................... -O3 -O2
Linker flags .......................... -O3 -O2
Now we are back to (inconsistently) overriding the user.