This PR more tightly integrates building Univalue into our build system. This follows the same approach we use for LevelDB, (Makefile.leveldb.include
), and CRC32C (Makefile.crc32c.include
), and will be the same approach we use for minisketch; see #23114.
This approach yields a number of benefits, including:
- Faster configuration due to one less subconfigure being run during
./configure
i.e 22s with this PR vs 26s - Faster autoconf i.e 13s with this PR vs 17s
- Improved caching
- No more issues with compiler flags i.e #12467
- More direct control means we can build exactly the objects we want
There might be one argument against making this change, which is that builders should have the option to use “proper shared/system libraries”. However, I think that falls down for a few reasons. The first being that we already don’t support building with a number of system libraries (secp256k1, leveldb, crc32c); some for good reason. Univalue is really the odd one out at the moment.
Note that the only fork of Core I’m aware of, that actively patches in support for using system libs, also explicitly marks them as “DANGEROUS” and “NOT SUPPORTED”. So it would seem they exist more to satisfy a distro requirement, as opposed to something that anyone should, or would actually use in practice.
PRs like #22412 highlight the “issue” with us operating with our own Univalue fork, where we actively fix bugs, and make improvements, when upstream (https://github.com/jgarzik/univalue) may not be taking those improvements, and by all accounts, is not currently actively maintained. Bitcoin Core should not be hamstrung into not being able to fix bugs in a library, and/or have to litter our source with “workarounds”, i.e #22412, for bugs we’ve already fixed, based on the fact that an upstream project is not actively being maintained. Allowing builders to use system libs is really only exacerbating this problem, with little benefit to our project. Bitcoin Core is not quite like your average piece of distro packaged software.
There is the potential for us to give the same treatment to libsecp256k1, however it seems doing that is currently less straightforward.