Skip to content

build: Introduce internal kernel library#28690

Open
sedited wants to merge 1 commit intobitcoin:masterfrom
sedited:kernelInternalLib
Open

build: Introduce internal kernel library#28690
sedited wants to merge 1 commit intobitcoin:masterfrom
sedited:kernelInternalLib

Conversation

@sedited
Copy link
Contributor

@sedited sedited commented Oct 20, 2023

This PR introduces a new libbitcoin_kernel internal library. It completes the internal library design as laid out in doc/design/libraries.md. Since the util library contains a bunch of modules that are not required by the kernel library, a new kernel_util library is introduced as well that only consists of the modules required by the kernel library. The external libbitcoinkernel library now re-uses the compiled objects from the internal libraries.

There is a trade-off to this. Since we don't manually export symbols from the kernel library yet, this would make the library unusable if REDUCE_EXPORTS=ON. For now this means that the patch here introduces a separate source file list for the external library that gets populated by the source files of its static dependents.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 20, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/28690.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK stickies-v, theuni, kashifs, pablomartin4btc, ismaelsadeeq
Approach ACK hebasto
Stale ACK ryanofsky, yuvicc, janb84

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34654 ([RFC] BlockMap and CChain Concurrency Improvement by alexanderwiederin)
  • #34641 (node: scale default -dbcache with system RAM by l0rinc)
  • #34495 (Replace boost signals with minimal compatible implementation by theuni)
  • #34075 (fees: Introduce Mempool Based Fee Estimation to reduce overestimation by ismaelsadeeq)
  • #32427 ((RFC) kernel: Replace leveldb-based BlockTreeDB with flat-file based store by sedited)
  • #32297 (bitcoin-cli: Add -ipcconnect option by ryanofsky)
  • #31132 (validation: fetch block inputs on parallel threads by andrewtoth)
  • #26022 (Add util::ResultPtr class by ryanofsky)
  • #25665 (refactor: Add util::Result failure types and ability to merge result values by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@hebasto
Copy link
Member

hebasto commented Oct 21, 2023

To fix the MSVC build, suggesting to apply the diff as follows:

--- a/build_msvc/bitcoin.sln
+++ b/build_msvc/bitcoin.sln
@@ -82,6 +82,10 @@ Global
         {460FEE33-1FE1-483F-B3BF-931FF8E969A5}.Debug|x64.Build.0 = Debug|x64
         {460FEE33-1FE1-483F-B3BF-931FF8E969A5}.Release|x64.ActiveCfg = Release|x64
         {460FEE33-1FE1-483F-B3BF-931FF8E969A5}.Release|x64.Build.0 = Release|x64
+        {A938586F-1016-4C60-9B82-56123264EE14}.Debug|x64.ActiveCfg = Debug|x64
+        {A938586F-1016-4C60-9B82-56123264EE14}.Debug|x64.Build.0 = Debug|x64
+        {A938586F-1016-4C60-9B82-56123264EE14}.Release|x64.ActiveCfg = Release|x64
+        {A938586F-1016-4C60-9B82-56123264EE14}.Release|x64.Build.0 = Release|x64
         {5724BA7D-A09A-4BA8-800B-C4C1561B3D69}.Debug|x64.ActiveCfg = Debug|x64
         {5724BA7D-A09A-4BA8-800B-C4C1561B3D69}.Debug|x64.Build.0 = Debug|x64
         {5724BA7D-A09A-4BA8-800B-C4C1561B3D69}.Release|x64.ActiveCfg = Release|x64

@sedited
Copy link
Contributor Author

sedited commented Oct 21, 2023

Thanks for the fixes @hebasto! Looks like the remaining test failure is a timeout?

@hebasto
Copy link
Member

hebasto commented Oct 21, 2023

Looks like the remaining test failure is a timeout?

I believe that this PR changes are unrelated to that timeout. See: #28703.

@sedited
Copy link
Contributor Author

sedited commented Nov 25, 2025

Copy link
Contributor

@janb84 janb84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 4c387e9

Looks good to me, next to several builds & tests, I did a (subsection of a ) Guix build to see if there where any issues with that. It ran fine, see below.

my Guix Build Output

Host architecture: aarch64
Commit: 4c387e938015

0eea1fa55868cf288544de481d7ae5e8285f068074536723e927c20b9ece0518  guix-build-4c387e938015/output/dist-archive/bitcoin-4c387e938015.tar.gz
bf648f3ef27667e011b2c4547987527111c3d5c286933d092ad82697181c7918  guix-build-4c387e938015/output/x86_64-apple-darwin/SHA256SUMS.part
da7d979957fb90516e47e1c2a976888e934776eee59f3248be798ffb57f2a781  guix-build-4c387e938015/output/x86_64-apple-darwin/bitcoin-4c387e938015-x86_64-apple-darwin-codesigning.tar.gz
902f1ed15f8bae87129447d24de0356ec20781a813808e1b0274c815ac89072f  guix-build-4c387e938015/output/x86_64-apple-darwin/bitcoin-4c387e938015-x86_64-apple-darwin-unsigned.tar.gz
6c23aa0d3c94029af56e0573927f5d634cd32444c5cebf97f405864fb2e30139  guix-build-4c387e938015/output/x86_64-apple-darwin/bitcoin-4c387e938015-x86_64-apple-darwin-unsigned.zip
dfa686c73f0f54f71d5d81cba48e8d809106ca708c2619b641df412a48d43efa  guix-build-4c387e938015/output/x86_64-w64-mingw32/SHA256SUMS.part
34f7c1142fcab95318de2c15b10e3ef2f511137c3da196cf275061d2e7921095  guix-build-4c387e938015/output/x86_64-w64-mingw32/bitcoin-4c387e938015-win64-codesigning.tar.gz
9c6aec8c60d30ef857da2538c939f0d16642bb05f0dd50f2d282ea56c533f2cf  guix-build-4c387e938015/output/x86_64-w64-mingw32/bitcoin-4c387e938015-win64-debug.zip
45132cb1e70e6930ad4ca85ab9ae6258e61eeee4aef8858a4902e8dceb71db5e  guix-build-4c387e938015/output/x86_64-w64-mingw32/bitcoin-4c387e938015-win64-setup-unsigned.exe
7bffc2f307b721320cc5358ce79945fe241eec208b86d969affecbe5d14f9667  guix-build-4c387e938015/output/x86_64-w64-mingw32/bitcoin-4c387e938015-win64-unsigned.zip

@sedited
Copy link
Contributor Author

sedited commented Dec 9, 2025

Copy link
Contributor

@janb84 janb84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re ACK 5656bfa

changes since last ACK:

  • rebase

@maflcko
Copy link
Member

maflcko commented Dec 9, 2025

It could make sense to keep ../util/expected.cpp? Otherwise, iwyu won't run and the file could just be fully deleted?

@sedited
Copy link
Contributor Author

sedited commented Dec 9, 2025

It could make sense to keep ../util/expected.cpp? Otherwise, iwyu won't run and the file could just be fully deleted?

That was not the intention, forgot that it was just empty for now and was expecting a compile error in case I missed it. Fixed it now.

@yuvicc
Copy link
Contributor

yuvicc commented Dec 16, 2025

re-ACK 5f096da

Only rebased since last review.

Copy link
Contributor

@janb84 janb84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re ACK 5f096da

changes since last ACK:

  • added expected.cpp to util for IWYU

@sedited
Copy link
Contributor Author

sedited commented Jan 13, 2026

@sedited
Copy link
Contributor Author

sedited commented Jan 19, 2026

@sedited
Copy link
Contributor Author

sedited commented Feb 20, 2026

To facilitate compiling the external kernel library with different
symbol visibility, re-use the same source file list from its dependent
internal counterpart.
@sedited
Copy link
Contributor Author

sedited commented Mar 14, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Architecture & Performance

Development

Successfully merging this pull request may close these issues.