-
Notifications
You must be signed in to change notification settings - Fork 37.7k
build: Enable C++11 in build, require C++11 compiler #7165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Concept requete-ACK, of course, I don't think anybody will dare to nack this (besides tested nits [and making travis happy]). |
concept ACK |
Concept ACK. |
Concept ACK, but only when it's determined to be safe (especially against possibly invisible consensus failures) and can be supported on all stable distros with standard OS libraries... |
For reference, that list of distros:
Those ticked have native support of This doens't necessarily act as a block, assuming #6211 (comment) |
@dcousens - Don't forget Windows (well, MinGW)! I guess this one's a little tricky since the Windows build is cross-compiled. I think Ubuntu 14.04 will be fine, although 16.04 (LTS) will be necessary if GCC 5 features are required, I suppose, due to Gitian requirements. |
That sounds OK to me, it seems like a realistic timeline too. |
@dcousens - Sorry for editing what you replied to. :) But yeah, maybe aim for throwing the switch around the time 16.04 comes out if, for whatever reasons, it's decided that GCC 5 support is required/highly desirable. 15.10 has it but I think Gitian officially supports only LTS releases. |
Edit: Forgot we switched to libsecp256k1, nevermind re Fedora. |
Ok, getting kind of tired of this, but postponing this another major release, I'm not going to push for this again. |
@luke-jr No reason why Fedora cannot be supported. A fedora programmer added the following commit to picocoin, illustrating a Fedora-compatible approach: jgarzik/picocoin#44 |
@jgarzik That seems unrelated to C++11?
|
I'm working on a fork off of Bitcoin core to implement zerocash. We require C++11 due to dependencies (eg It's not much effort to make C++11 compile, link, run, and pass We've been working on a fork off of both v0.10.0 and v0.11.2 with g++ First, some strong caveats:
So, I scanned through our deltas from upstream to hunt down changes I believe are necessitated by C++11 support:
I hope this helps. If I had time I'd work on this PR directly, but I can't promise anything. |
@sipa It is directly related to luke's comment. |
@jgarzik Oops, I missed that.
@luke-jr That's irrelevant. We don't use OpenSSL's EC code anywhere anymore.
I am really in favor of C++11 and don't understand the fuss at this point.
There are potential problems when mixing C++ code compiled against
different versions of the std library, but as far as I can tell, those are
things that result in link-time errors?
I would like to see this reopened.
|
Agree - urge re-opening this - this is not a big risk. |
Thanks for reopening, @laanwj. One thing I would like to say is that some IBLT simulation code (non-Core) was written in C++11. I believe the plan is to try to recycle some of it for the eventual Core commit. It would be nice to know if C++11 will be acceptable so that everybody working on the Core patch(es) can use or modify code as necessary. Also, I agree with @sipa. AFAIK, any library issues would come up as linker errors. I'm not aware offhand of any massive gotchas that would come with a switch to GCC 5 and a bit of time for distros to recompile everything. (AFAIK, Ubuntu did most of that before releasing 15.10, although it sounds like more work is needed for 16.04.) If anybody's aware of any specific issues, I'm all ears. |
This was discussed in the weekly IRC meeting. It seems we'll aim for C++11 in 0.13, by first adding build configuration and testing for C++11 on some targets (but not all), and if no problems appear, switch everything to C++11 and start using C++11 features. |
Looks like the only remaining issue in that list should be the throwing dtor. |
The patch for the dtor "fix" is:
This allows This patch is enabling a mechanism used for test verification, but we may not want that behavior in the application code. The only use I see is in |
c++11 for 0.13? I should miss more meetings so things go more my way... |
what's the latest status on this? |
@theuni has been chasing Travis about dependency caching support on the VMs that support c++11 (Ubuntu 14.04+) |
Wouldn't you need to bump travis to trusty as part of this pull? |
@theuni is working on that |
ACK a398549
and the build log contains millions of added |
No longer the latest version of the C++11 macro (see http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=history;f=m4/ax_cxx_compile_stdcxx.m4). Do we want to update? |
Tested ACK with the latest C++11 macro, as pointed out by Matt. Compiles fine on the latest OS X (10.11.4) and Xcode (7.3), make check passes, and I get the same output as Janik. |
ACK. builds, tests, runs. Throws a new build warning |
@randy-waterhouse What compiler do you use please? Edit: Travis has the warning here: https://travis-ci.org/bitcoin/bitcoin/jobs/126071750#L3267 |
@paveljanik That's a legitimate warning. We'll need to auto_ptr -> unique_ptr. But that's a hard fork :p |
Tested on OSX 10.11.4 & Xcode 7.3. compiles fine, make check passes. Same configure diff as above. |
removed WIP: tag, added commit that updates ax_cxx_compile_stdcxx (thanks @TheBlueMatt for noticing) @randy-waterhouse Indeed, the auto_ptr should be replaced, let's do that in a later pull. |
reACK 2aacc72 |
7df9224 doc: Add note about new build/test requirements to release notes (Wladimir J. van der Laan) 2aacc72 build: update ax_cxx_compile_stdcxx to serial 4 (Wladimir J. van der Laan) a398549 depends: use c++11 (Cory Fields) 67969af build: Enable C++11 build, require C++11 compiler (Wladimir J. van der Laan)
Darwin build fixes Includes fixes cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7136 - Only the third commit (to avoid a merge conflict) - bitcoin/bitcoin#7302 - Excluding the first commit, which is unnecessary (we use Boost 1.62) - bitcoin/bitcoin#7487 - bitcoin/bitcoin#7606 - bitcoin/bitcoin#7711 - bitcoin/bitcoin#7165 - bitcoin/bitcoin#8002 - bitcoin/bitcoin#8210 - Only the second commit - bitcoin/bitcoin#9114
Darwin build fixes Includes fixes cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7136 - Only the third commit (to avoid a merge conflict) - bitcoin/bitcoin#7302 - Excluding the first commit, which is unnecessary (we use Boost 1.62) - bitcoin/bitcoin#7487 - bitcoin/bitcoin#7606 - bitcoin/bitcoin#7711 - bitcoin/bitcoin#7165 - bitcoin/bitcoin#8002 - bitcoin/bitcoin#8210 - Only the second commit - bitcoin/bitcoin#9114
Darwin build fixes Includes fixes cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7136 - Only the third commit (to avoid a merge conflict) - bitcoin/bitcoin#7302 - Excluding the first commit, which is unnecessary (we use Boost 1.62) - bitcoin/bitcoin#7487 - bitcoin/bitcoin#7606 - bitcoin/bitcoin#7711 - bitcoin/bitcoin#7165 - bitcoin/bitcoin#8002 - bitcoin/bitcoin#8210 - Only the second commit - bitcoin/bitcoin#9114
0ae8f18 build: add -Wgnu to compile flags (fanquake) 3a0fd77 Remove use of non-standard zero variadic macros (Ben Woosley) 49f6178 Drop unused LOG_TIME_MICROS helper (Ben Woosley) 5d49999 prevector: Avoid unnamed struct, which is a GNU extension (DesWurstes) Pull request description: Since we [started using](#7165) the `ax_cxx_compile_stdcxx.m4` macro we've been passing `[noext]` to indicate that we don't want to use an extended mode, i.e GNU extensions. Speaking to Cory he clarified that the intention was to "require only vanilla c++11 and turn _off_ extension support so they would fail to compile". However in the codebase we are currently making use of some GNU extensions. We should either remove there usage, or at least amend our CXX compiler checks. I'd prefer the former. #### anonymous structs ```bash ./prevector.h:153:9: warning: anonymous structs are a GNU extension [-Wgnu-anonymous-struct] struct { ``` This is fixed in b849212. #### variadic macros ```bash ./undo.h:57:50: warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments] ::Unserialize(s, VARINT(nVersionDummy)); ``` This is taken care of in #18087. The `LOG_TIME_*` macros introduced in #16805 make use of a [GNU extension](https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html). ```bash In file included from validation.cpp:22: ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] BCLog::Timer<std::chrono::milliseconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, ## __VA_ARGS__) ^ ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] ./logging/timer.h:101:92: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] BCLog::Timer<std::chrono::seconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, ## __VA_ARGS__) ^ 6 warnings generated. ``` This is fixed in 081a0ab and 612e8e1. #### prevention To ensure that usage doesn't creep back in we can add [`-Wgnu`](https://clang.llvm.org/docs/DiagnosticsReference.html#wgnu) to our compile time flags, which will make Clang warn whenever it encounters GNU extensions. This would close #14130. Also related to #17230, where it's suggested we use a GNU extension, the `gnu::pure` attribute. ACKs for top commit: practicalswift: ACK 0ae8f18 -- diff looks correct MarcoFalke: ACK 0ae8f18 vasild: utACK 0ae8f18 dongcarl: ACK 0ae8f18 Tree-SHA512: c517404681ef8edf04c785731d26105bac9f3c9c958605aa24cbe399c649e7c5ee0c4aa8e714fd2b2d335e2fbea4d571e09b0dec36678ef871f0a6683ba6bb7f
0ae8f18 build: add -Wgnu to compile flags (fanquake) 3a0fd77 Remove use of non-standard zero variadic macros (Ben Woosley) 49f6178 Drop unused LOG_TIME_MICROS helper (Ben Woosley) 5d49999 prevector: Avoid unnamed struct, which is a GNU extension (DesWurstes) Pull request description: Since we [started using](bitcoin#7165) the `ax_cxx_compile_stdcxx.m4` macro we've been passing `[noext]` to indicate that we don't want to use an extended mode, i.e GNU extensions. Speaking to Cory he clarified that the intention was to "require only vanilla c++11 and turn _off_ extension support so they would fail to compile". However in the codebase we are currently making use of some GNU extensions. We should either remove there usage, or at least amend our CXX compiler checks. I'd prefer the former. #### anonymous structs ```bash ./prevector.h:153:9: warning: anonymous structs are a GNU extension [-Wgnu-anonymous-struct] struct { ``` This is fixed in bitcoin@b849212. #### variadic macros ```bash ./undo.h:57:50: warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments] ::Unserialize(s, VARINT(nVersionDummy)); ``` This is taken care of in bitcoin#18087. The `LOG_TIME_*` macros introduced in bitcoin#16805 make use of a [GNU extension](https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html). ```bash In file included from validation.cpp:22: ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] BCLog::Timer<std::chrono::milliseconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, ## __VA_ARGS__) ^ ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] ./logging/timer.h:99:99: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] ./logging/timer.h:101:92: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments] BCLog::Timer<std::chrono::seconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, ## __VA_ARGS__) ^ 6 warnings generated. ``` This is fixed in 081a0ab and 612e8e1. #### prevention To ensure that usage doesn't creep back in we can add [`-Wgnu`](https://clang.llvm.org/docs/DiagnosticsReference.html#wgnu) to our compile time flags, which will make Clang warn whenever it encounters GNU extensions. This would close bitcoin#14130. Also related to bitcoin#17230, where it's suggested we use a GNU extension, the `gnu::pure` attribute. ACKs for top commit: practicalswift: ACK 0ae8f18 -- diff looks correct MarcoFalke: ACK 0ae8f18 vasild: utACK 0ae8f18 dongcarl: ACK 0ae8f18 Tree-SHA512: c517404681ef8edf04c785731d26105bac9f3c9c958605aa24cbe399c649e7c5ee0c4aa8e714fd2b2d335e2fbea4d571e09b0dec36678ef871f0a6683ba6bb7f
76f031b 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 (7be143a): ``` 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 76f031b. Tree-SHA512: 0f71d98387d88f36bd22fd4204f8116efc6d540b45a722281483f1f19f36a26daa197458006af6a35d80a52dd8f13c714c4c816ad6c279d6e52872c948fab987
76f031b 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 bitcoin#22380. For bdb & zeromq, I assume (haven't checked) this has been the case since bitcoin#7165. You can inspect the effcts in bitcoind comparing a function from a unoptimised library, i.e libzmq. Build bitcoind with zeromq from depends (7be143a): ``` 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 76f031b. Tree-SHA512: 0f71d98387d88f36bd22fd4204f8116efc6d540b45a722281483f1f19f36a26daa197458006af6a35d80a52dd8f13c714c4c816ad6c279d6e52872c948fab987
Implements #6211.
Just meant for testing for now. Probably doesn't pass Travis.
TODO:
Possibly TODO: