This is done in the context of the libbitcoinkernel project, wherein
reliance of libbitcoinkernel code on the global gArgs is incrementally
removed.
This is a partial backport of core#27576
https://github.com/bitcoin/bitcoin/pull/27576/commits/05870b1c92f39d90e5ba6e0caf2f6c2b37955528
Depends on D18692