build: GCC-12 build improvements
Summary:
2 changes to better support building with GCC 12, which out of the box, is currently broken if you want to build using depends.
Backport of core#25436.
Test Plan: Run the Linux64 build
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Differential Revision: https://reviews.bitcoinabc.org/D17032