sync.h: Make runtime lock checks require compile-time lock checks
Summary:
This is a backport of core#19668 [4/5]
https://github.com/bitcoin/bitcoin/pull/19668/commits/2ee7743fe723227f2ea1b031eddb14fc6863f4c8
Depends on D10163
Test Plan:
With TSAN:
ninja check check-functional
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D10164