Bitcoin Core integration/staging tree
Go to file
fanquake 3af495d697
Merge bitcoin/bitcoin#22840: build: fix unoptimized libraries in depends
76f031b050 build: fix unoptimized libraries in depends (fanquake)

Pull request description:

  We need to append-to rather than set CXXFLAGS, otherwise we loose `-O2` & `-pipe` from our defaults. Currently this results in zeromq being built without optimizations at all (or whatever the compiler would default too, essentially  always `-O0`).

  Bdb is the same, for the CXX portion of its code. C code has been built with `-O2`. Boost has actually been unaffected because it receives `-O3` from it's own build flags.

  Noticed while reworking #22380. For bdb & zeromq, I assume (haven't checked) this has been the case since #7165.

  You can inspect the effcts in bitcoind comparing a function from a unoptimised library, i.e libzmq.

  Build bitcoind with zeromq from depends (7be143a960):
  ```
  gmake -C depends NO_QT=1 NO_UPNP=1 NO_NATPMP=1 NO_WALLET=1 -j9

  ./autogen.sh
  CONFIG_SITE=/path/to/share/config.site ./configure
  gmake -C src bitcoind -j9
  ```

  Find a zeromq function:
  ```bash
  nm -C src/bitcoind | rg zmq
  ...
  000000010053a7e0 T _zmq_ctx_new
  ```

  Disassemble it:
  ```bash
  lldb src/bitcoind
  disassemble -a 000000010053a7e0
  ...
  bitcoind`zmq_ctx_new:
  bitcoind[0x10053a7e0] <+0>:   pushq  %rbp
  bitcoind[0x10053a7e1] <+1>:   movq   %rsp, %rbp
  bitcoind[0x10053a7e4] <+4>:   subq   $0x50, %rsp
  bitcoind[0x10053a7e8] <+8>:   callq  0x1004b2ee0               ; zmq::initialize_network()
  bitcoind[0x10053a7ed] <+13>:  testb  $0x1, %al
  bitcoind[0x10053a7ef] <+15>:  jne    0x10053a802               ; <+34>
  bitcoind[0x10053a7f5] <+21>:  movq   $0x0, -0x8(%rbp)
  bitcoind[0x10053a7fd] <+29>:  jmp    0x10053a8e8               ; <+264>
  bitcoind[0x10053a802] <+34>:  movq   0xadab7(%rip), %rsi       ; (void *)0x0000000000000000
  bitcoind[0x10053a809] <+41>:  movl   $0x2b8, %edi              ; imm = 0x2B8
  bitcoind[0x10053a80e] <+46>:  callq  0x100556c58               ; symbol stub for: operator new(unsigned long, std::nothrow_t const&)
  bitcoind[0x10053a813] <+51>:  xorl   %ecx, %ecx
  bitcoind[0x10053a815] <+53>:  movl   %ecx, %edx
  bitcoind[0x10053a817] <+55>:  movb   $0x0, -0x19(%rbp)
  bitcoind[0x10053a81b] <+59>:  cmpq   $0x0, %rax
  bitcoind[0x10053a81f] <+63>:  movq   %rax, -0x38(%rbp)
  bitcoind[0x10053a823] <+67>:  movq   %rdx, -0x40(%rbp)
  bitcoind[0x10053a827] <+71>:  je     0x10053a858               ; <+120>
  bitcoind[0x10053a82d] <+77>:  movq   -0x38(%rbp), %rax
  bitcoind[0x10053a831] <+81>:  movq   %rax, -0x18(%rbp)
  bitcoind[0x10053a835] <+85>:  movb   $0x1, -0x19(%rbp)
  bitcoind[0x10053a839] <+89>:  movq   -0x38(%rbp), %rdi
  bitcoind[0x10053a83d] <+93>:  movq   %rax, -0x48(%rbp)
  bitcoind[0x10053a841] <+97>:  callq  0x100497aa0               ; zmq::ctx_t::ctx_t()
  bitcoind[0x10053a846] <+102>: jmp    0x10053a84b               ; <+107>
  bitcoind[0x10053a84b] <+107>: movq   -0x48(%rbp), %rax
  bitcoind[0x10053a84f] <+111>: movq   %rax, -0x40(%rbp)
  bitcoind[0x10053a853] <+115>: jmp    0x10053a858               ; <+120>
  bitcoind[0x10053a858] <+120>: movq   -0x40(%rbp), %rax
  bitcoind[0x10053a85c] <+124>: movq   %rax, -0x10(%rbp)
  bitcoind[0x10053a860] <+128>: cmpq   $0x0, -0x10(%rbp)
  bitcoind[0x10053a865] <+133>: je     0x10053a8e0               ; <+256>
  bitcoind[0x10053a86b] <+139>: movq   -0x10(%rbp), %rdi
  bitcoind[0x10053a86f] <+143>: callq  0x100497ee0               ; zmq::ctx_t::valid() const
  bitcoind[0x10053a874] <+148>: testb  $0x1, %al
  bitcoind[0x10053a876] <+150>: jne    0x10053a8db               ; <+251>
  bitcoind[0x10053a87c] <+156>: movq   -0x10(%rbp), %rax
  bitcoind[0x10053a880] <+160>: cmpq   $0x0, %rax
  bitcoind[0x10053a884] <+164>: movq   %rax, -0x50(%rbp)
  bitcoind[0x10053a888] <+168>: je     0x10053a8a3               ; <+195>
  bitcoind[0x10053a88e] <+174>: movq   -0x50(%rbp), %rdi
  bitcoind[0x10053a892] <+178>: callq  0x100497ec0               ; zmq::ctx_t::~ctx_t()
  bitcoind[0x10053a897] <+183>: movq   -0x50(%rbp), %rax
  bitcoind[0x10053a89b] <+187>: movq   %rax, %rdi
  bitcoind[0x10053a89e] <+190>: callq  0x100556c3a               ; symbol stub for: operator delete(void*)
  bitcoind[0x10053a8a3] <+195>: movq   $0x0, -0x8(%rbp)
  bitcoind[0x10053a8ab] <+203>: jmp    0x10053a8e8               ; <+264>
  bitcoind[0x10053a8b0] <+208>: movq   %rax, -0x28(%rbp)
  bitcoind[0x10053a8b4] <+212>: movl   %edx, -0x2c(%rbp)
  bitcoind[0x10053a8b7] <+215>: testb  $0x1, -0x19(%rbp)
  bitcoind[0x10053a8bb] <+219>: jne    0x10053a8c6               ; <+230>
  bitcoind[0x10053a8c1] <+225>: jmp    0x10053a8d6               ; <+246>
  bitcoind[0x10053a8c6] <+230>: movq   0xad9f3(%rip), %rsi       ; (void *)0x0000000000000000
  bitcoind[0x10053a8cd] <+237>: movq   -0x18(%rbp), %rdi
  bitcoind[0x10053a8d1] <+241>: callq  0x100556c40               ; symbol stub for: operator delete(void*, std::nothrow_t const&)
  bitcoind[0x10053a8d6] <+246>: jmp    0x10053a8f2               ; <+274>
  bitcoind[0x10053a8db] <+251>: jmp    0x10053a8e0               ; <+256>
  bitcoind[0x10053a8e0] <+256>: movq   -0x10(%rbp), %rax
  bitcoind[0x10053a8e4] <+260>: movq   %rax, -0x8(%rbp)
  bitcoind[0x10053a8e8] <+264>: movq   -0x8(%rbp), %rax
  bitcoind[0x10053a8ec] <+268>: addq   $0x50, %rsp
  bitcoind[0x10053a8f0] <+272>: popq   %rbp
  bitcoind[0x10053a8f1] <+273>: retq
  bitcoind[0x10053a8f2] <+274>: movq   -0x28(%rbp), %rdi
  bitcoind[0x10053a8f6] <+278>: callq  0x100556856               ; symbol stub for: _Unwind_Resume
  bitcoind[0x10053a8fb] <+283>: ud2
  bitcoind[0x10053a8fd] <+285>: nopl   (%rax)
  ```

  Cleanup and repeat after changing the zeromq cxxflags to be `$(package)_cxxflags+=-std=c++17`:
  ```bash
  gmake clean
  gmake -C depends NO_QT=1 NO_UPNP=1 NO_NATPMP=1 NO_WALLET=1 -j9
  gmake -C src bitcoind -j9

  nm -C src/bitcoind | rg zmq
  ...
  00000001004d5170 T _zmq_ctx_new
  ```

  Disassemble the same function which has now been built with `-O2`:
  ```bash
  lldb src/bitcoind
  disassemble -a 00000001004d5170
  ...
  bitcoind`zmq_ctx_new:
  bitcoind[0x1004d5170] <+0>:   pushq  %rbp
  bitcoind[0x1004d5171] <+1>:   movq   %rsp, %rbp
  bitcoind[0x1004d5174] <+4>:   pushq  %r14
  bitcoind[0x1004d5176] <+6>:   pushq  %rbx
  bitcoind[0x1004d5177] <+7>:   callq  0x10049cbc0               ; zmq::initialize_network()
  bitcoind[0x1004d517c] <+12>:  testb  %al, %al
  bitcoind[0x1004d517e] <+14>:  je     0x1004d51bd               ; <+77>
  bitcoind[0x1004d5180] <+16>:  movq   0xab139(%rip), %rsi       ; (void *)0x0000000000000000
  bitcoind[0x1004d5187] <+23>:  movl   $0x2b8, %edi              ; imm = 0x2B8
  bitcoind[0x1004d518c] <+28>:  callq  0x1004f0e5a               ; symbol stub for: operator new(unsigned long, std::nothrow_t const&)
  bitcoind[0x1004d5191] <+33>:  testq  %rax, %rax
  bitcoind[0x1004d5194] <+36>:  je     0x1004d51bd               ; <+77>
  bitcoind[0x1004d5196] <+38>:  movq   %rax, %rbx
  bitcoind[0x1004d5199] <+41>:  movq   %rax, %rdi
  bitcoind[0x1004d519c] <+44>:  callq  0x100493400               ; zmq::ctx_t::ctx_t()
  bitcoind[0x1004d51a1] <+49>:  movq   %rbx, %rdi
  bitcoind[0x1004d51a4] <+52>:  callq  0x1004936e0               ; zmq::ctx_t::valid() const
  bitcoind[0x1004d51a9] <+57>:  testb  %al, %al
  bitcoind[0x1004d51ab] <+59>:  jne    0x1004d51bf               ; <+79>
  bitcoind[0x1004d51ad] <+61>:  movq   %rbx, %rdi
  bitcoind[0x1004d51b0] <+64>:  callq  0x1004936d0               ; zmq::ctx_t::~ctx_t()
  bitcoind[0x1004d51b5] <+69>:  movq   %rbx, %rdi
  bitcoind[0x1004d51b8] <+72>:  callq  0x1004f0e42               ; symbol stub for: operator delete(void*)
  bitcoind[0x1004d51bd] <+77>:  xorl   %ebx, %ebx
  bitcoind[0x1004d51bf] <+79>:  movq   %rbx, %rax
  bitcoind[0x1004d51c2] <+82>:  popq   %rbx
  bitcoind[0x1004d51c3] <+83>:  popq   %r14
  bitcoind[0x1004d51c5] <+85>:  popq   %rbp
  bitcoind[0x1004d51c6] <+86>:  retq
  bitcoind[0x1004d51c7] <+87>:  movq   %rax, %r14
  bitcoind[0x1004d51ca] <+90>:  movq   0xab0ef(%rip), %rsi       ; (void *)0x0000000000000000
  bitcoind[0x1004d51d1] <+97>:  movq   %rbx, %rdi
  bitcoind[0x1004d51d4] <+100>: callq  0x1004f0e48               ; symbol stub for: operator delete(void*, std::nothrow_t const&)
  bitcoind[0x1004d51d9] <+105>: movq   %r14, %rdi
  bitcoind[0x1004d51dc] <+108>: callq  0x1004f0a6a               ; symbol stub for: _Unwind_Resume
  bitcoind[0x1004d51e1] <+113>: ud2
  bitcoind[0x1004d51e3] <+115>: nopw   %cs:(%rax,%rax)
  bitcoind[0x1004d51ed] <+125>: nopl   (%rax)
  ```

ACKs for top commit:
  theuni:
    ACK 76f031b050.

Tree-SHA512: 0f71d98387d88f36bd22fd4204f8116efc6d540b45a722281483f1f19f36a26daa197458006af6a35d80a52dd8f13c714c4c816ad6c279d6e52872c948fab987
2021-09-02 09:43:53 +08:00
.github doc: Remove label from good first issue template 2020-08-24 09:31:24 +02:00
.tx qt: Bump transifex slug for 22.x 2021-04-21 13:46:41 +02:00
build_msvc Merge bitcoin/bitcoin#22155: wallet test: Add test for subtract fee from recipient behavior 2021-07-27 11:21:46 +02:00
build-aux/m4 build, qt: Fix typo in QtInputSupport check 2021-08-27 17:50:30 +03:00
ci Merge bitcoin/bitcoin#22744: ci: Re-enable verify-commits.py check 2021-08-31 20:48:31 +08:00
contrib Merge bitcoin/bitcoin#22847: guix/prelude: Override VERSION with FORCE_VERSION 2021-09-02 09:35:15 +08:00
depends build: fix unoptimized libraries in depends 2021-08-31 11:43:48 +08:00
doc doc: mention bech32m/BIP350 in doc/descriptors.md 2021-08-30 13:45:22 -04:00
share refactor: replace remaining binascii method calls 2021-08-16 19:30:56 +01:00
src Merge bitcoin/bitcoin#22512: Consolidate XOnlyPubKey lookup hack 2021-09-02 13:31:10 +12:00
test Merge bitcoin/bitcoin#22437: test, refactor: add GetTransaction() coverage, improve rpc_rawtransaction 2021-09-01 18:16:20 +02:00
.appveyor.yml Switch Appveyor CI to VS2019 stable image 2021-06-14 20:35:00 +01:00
.cirrus.yml ci: Unconditionally set the global git author name in cirrys.yml 2021-08-26 11:17:07 +02:00
.editorconfig Add EditorConfig file. 2021-02-10 08:00:06 +01:00
.gitattributes
.gitignore build: add *~ to .gitignore 2021-05-12 18:10:47 +02:00
.python-version Bump minimum python version to 3.6 2020-11-09 17:53:47 +10:00
.style.yapf test: .style.yapf: Set column_limit=160 2019-03-04 18:28:13 -05:00
autogen.sh scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
configure.ac Merge bitcoin/bitcoin#20586: Fix Windows build with --enable-werror 2021-08-27 08:31:45 +02:00
CONTRIBUTING.md doc: Update GitHub documentation links 2021-08-19 20:42:26 +02:00
COPYING doc: Update license year range to 2021 2020-12-30 16:24:47 +01:00
INSTALL.md Update INSTALL landing redirection notice for build instructions. 2016-10-06 12:27:23 +13:00
libbitcoinconsensus.pc.in build: remove libcrypto as internal dependency in libbitcoinconsensus.pc 2019-11-19 15:03:44 +01:00
Makefile.am Merge bitcoin/bitcoin#22234: build: Mark print-% target as phony. 2021-07-18 13:41:24 +08:00
README.md doc: Rework internal and external links 2021-02-17 09:18:46 +01:00
REVIEWERS Update REVIEWERS: I've found that I keep track of PRs in need of review without the need for DrahtBot's automated notification :) 2021-06-10 09:00:05 +00:00
SECURITY.md doc: Remove explicit mention of version from SECURITY.md 2019-06-14 06:39:17 -04:00

Bitcoin Core integration/staging tree

https://bitcoincore.org

For an immediately usable, binary version of the Bitcoin Core software, see https://bitcoincore.org/en/download/.

Further information about Bitcoin Core is available in the doc folder.

What is Bitcoin?

Bitcoin is an experimental digital currency that enables instant payments to anyone, anywhere in the world. Bitcoin uses peer-to-peer technology to operate with no central authority: managing transactions and issuing money are carried out collectively by the network. Bitcoin Core is the name of open source software which enables the use of this currency.

For more information read the original Bitcoin whitepaper.

License

Bitcoin Core is released under the terms of the MIT license. See COPYING for more information or see https://opensource.org/licenses/MIT.

Development Process

The master branch is regularly built (see doc/build-*.md for instructions) and tested, but it is not guaranteed to be completely stable. Tags are created regularly from release branches to indicate new official, stable release versions of Bitcoin Core.

The https://github.com/bitcoin-core/gui repository is used exclusively for the development of the GUI. Its master branch is identical in all monotree repositories. Release branches and tags do not exist, so please do not fork that repository unless it is for development reasons.

The contribution workflow is described in CONTRIBUTING.md and useful hints for developers can be found in doc/developer-notes.md.

Testing

Testing and code review is the bottleneck for development; we get more pull requests than we can review and test on short notice. Please be patient and help out by testing other people's pull requests, and remember this is a security-critical project where any mistake might cost people lots of money.

Automated Testing

Developers are strongly encouraged to write unit tests for new code, and to submit new unit tests for old code. Unit tests can be compiled and run (assuming they weren't disabled in configure) with: make check. Further details on running and extending unit tests can be found in /src/test/README.md.

There are also regression and integration tests, written in Python. These tests can be run (if the test dependencies are installed) with: test/functional/test_runner.py

The CI (Continuous Integration) systems make sure that every pull request is built for Windows, Linux, and macOS, and that unit/sanity tests are run automatically.

Manual Quality Assurance (QA) Testing

Changes should be tested by somebody other than the developer who wrote the code. This is especially important for large or high-risk changes. It is useful to add a test plan to the pull request description if testing the changes is not straightforward.

Translations

Changes to translations as well as new translations can be submitted to Bitcoin Core's Transifex page.

Translations are periodically pulled from Transifex and merged into the git repository. See the translation process for details on how this works.

Important: We do not accept translation changes as GitHub pull requests because the next pull from Transifex would automatically overwrite them again.