refactor: Fix clang compile failure #19333

pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:2006-FixClangBuild changing 2 files +3 −6
  1. MarcoFalke commented at 11:32 PM on June 19, 2020: member

    Fix

    script/standard.cpp:278:22: error: default initialization of an object of const type 'const (anonymous namespace)::CScriptVisitor' without a user-provided default constructor
    const CScriptVisitor g_script_visitor;
                         ^
                                         {}
    1 error generated.
    
  2. refactor: Fix clang compile failure
    script/standard.cpp:278:22: error: default initialization of an object of const type 'const (anonymous namespace)::CScriptVisitor' without a user-provided default constructor
    const CScriptVisitor g_script_visitor;
                         ^
                                         {}
    1 error generated.
    faa7431fee
  3. MarcoFalke added the label Refactoring on Jun 19, 2020
  4. MarcoFalke commented at 11:33 PM on June 19, 2020: member

    Broken in 5f72ddb7ee4cc177de31f43c69390ee72687222a cc @promag

  5. sipa commented at 11:39 PM on June 19, 2020: member

    utACK code change. I don't understand what the clang version bump accomplishes.

  6. MarcoFalke commented at 11:44 PM on June 19, 2020: member

    We use C++11 features such as https://en.cppreference.com/w/cpp/io/ios_base/failure, which is not part of clang-3.7, so Bitcoin Core can only be compiled with clang-3.8 (or higher).

  7. sipa commented at 11:54 PM on June 19, 2020: member

    Strange. https://clang.llvm.org/cxx_status.html says clang 3.3 implement all of C++11.

  8. MarcoFalke commented at 12:03 AM on June 20, 2020: member

    Hmm

    No supported versions of Bitcoin Core can be compiled with clang-3.7 (see compile log below) and we haven't had any bug reports, so I doubt there is a user or even an operating system running on clang-3.7 today.

    <details><summary>compile log</summary>

    git log -1 && make V=1
    commit 58ba7c314d552cea8cb024960a8504577aee586f
    Author: Wladimir J. van der Laan <laanwj@protonmail.com>
    Date:   Wed Mar 4 13:13:02 2020 +0100
    
        build: Bump version for 0.19.1 final
        
        Tree-SHA512: c0a5fbc072b03e36ffb9af23e699c6b3a897fcd509fdc3c6741ecc8e510aea5d87851c5a7926909746d03d390af10cae266189160b4a7b303f8be9418ea6a0c0
    Making all in src
    make[1]: Entering directory '/bitcoin/src'
    make[2]: Entering directory '/bitcoin/src'
    make[3]: Entering directory '/bitcoin'
    make[3]: Leaving directory '/bitcoin'
    /bin/bash ../libtool  --tag=CXX --preserve-dup-deps  --mode=link /usr/bin/ccache clang++-3.7 -std=c++11  -Wstack-protector -fstack-protector-all -Wall -Wextra -Wformat -Wvla -Wswitch -Wformat-security -Wthread-safety-analysis -Wrange-loop-analysis -Wredundant-decls -Wno-unused-parameter -Wno-self-assign -Wno-unused-local-typedef -Wno-deprecated-register -Wno-implicit-fallthrough    -fPIE -g -O2  -pthread  -Wl,-z,relro -Wl,-z,now -pie      -o bitcoind bitcoind-bitcoind.o  libbitcoin_server.a  libbitcoin_server.a libbitcoin_common.a univalue/libunivalue.la libbitcoin_util.a  libbitcoin_consensus.a crypto/libbitcoin_crypto_base.a crypto/libbitcoin_crypto_sse41.a crypto/libbitcoin_crypto_avx2.a crypto/libbitcoin_crypto_shani.a leveldb/libleveldb.a leveldb/libleveldb_sse42.a leveldb/libmemenv.a secp256k1/libsecp256k1.la -L/usr/lib/x86_64-linux-gnu -lboost_system -lboost_filesystem -lboost_thread -lpthread -lboost_chrono  -lcrypto  -levent_pthreads -levent -levent  
    libtool: link: /usr/bin/ccache clang++-3.7 -std=c++11 -Wstack-protector -fstack-protector-all -Wall -Wextra -Wformat -Wvla -Wswitch -Wformat-security -Wthread-safety-analysis -Wrange-loop-analysis -Wredundant-decls -Wno-unused-parameter -Wno-self-assign -Wno-unused-local-typedef -Wno-deprecated-register -Wno-implicit-fallthrough -fPIE -g -O2 -pthread -Wl,-z -Wl,relro -Wl,-z -Wl,now -pie -o bitcoind bitcoind-bitcoind.o  libbitcoin_server.a libbitcoin_server.a libbitcoin_common.a univalue/.libs/libunivalue.a libbitcoin_util.a libbitcoin_consensus.a crypto/libbitcoin_crypto_base.a crypto/libbitcoin_crypto_sse41.a crypto/libbitcoin_crypto_avx2.a crypto/libbitcoin_crypto_shani.a leveldb/libleveldb.a leveldb/libleveldb_sse42.a leveldb/libmemenv.a secp256k1/.libs/libsecp256k1.a -L/usr/lib/x86_64-linux-gnu -lboost_system -lboost_filesystem -lboost_thread -lpthread -lboost_chrono -lcrypto -levent_pthreads -levent -levent -pthread
    libbitcoin_server.a(libbitcoin_server_a-dbwrapper.o): In function `unsigned long ReadCompactSize<CDataStream>(CDataStream&)':
    /bitcoin/src/./serialize.h:313: undefined reference to `std::ios_base::failure::failure(char const*, std::error_code const&)'
    /bitcoin/src/./serialize.h:316: undefined reference to `std::ios_base::failure::failure(char const*, std::error_code const&)'
    /bitcoin/src/./serialize.h:307: undefined reference to `std::ios_base::failure::failure(char const*, std::error_code const&)'
    /bitcoin/src/./serialize.h:301: undefined reference to `std::ios_base::failure::failure(char const*, std::error_code const&)'
    libbitcoin_server.a(libbitcoin_server_a-dbwrapper.o): In function `CDataStream::read(char*, unsigned long)':
    /bitcoin/src/./streams.h:406: undefined reference to `std::ios_base::failure::failure(char const*, std::error_code const&)'
    libbitcoin_server.a(libbitcoin_server_a-net_processing.o):/bitcoin/src/./serialize.h:510: more undefined references to `std::ios_base::failure::failure(char const*, std::error_code const&)' follow
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    Makefile:4817: recipe for target 'bitcoind' failed
    make[2]: *** [bitcoind] Error 1
    make[2]: Leaving directory '/bitcoin/src'
    Makefile:13231: recipe for target 'all-recursive' failed
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory '/bitcoin/src'
    Makefile:775: recipe for target 'all-recursive' failed
    make: *** [all-recursive] Error 1
    
    

    </details>

  9. sipa commented at 12:17 AM on June 20, 2020: member

    @MarcoFalke No objection to bumping this if it reflects reality - 3.7 is certainly quite old (though GCC 4.8 is older).

    However, I don't understand what's happening here. The std::ios_base::failure(const std::string&) constructor has been used in the codebase since 2009: https://github.com/bitcoin/bitcoin/blob/v0.1.5/serialize.h#L289. Could it be an ABI incompatibility issue?

  10. ci: Add test for clang-3.8 C++11 support fa3b35a189
  11. MarcoFalke force-pushed on Jun 20, 2020
  12. MarcoFalke commented at 12:36 AM on June 20, 2020: member

    Reverted doc change for now. I might take another look some time later.

  13. DrahtBot commented at 3:35 AM on June 20, 2020: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #16546 (External signer support - Wallet Box edition by Sjors)
    • #15382 (util: add RunCommandParseJSON by Sjors)

    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.

  14. ajtowns commented at 10:32 AM on June 22, 2020: member

    Looks to me like this is https://bugs.llvm.org/show_bug.cgi?id=23529 (see also https://bugs.llvm.org/show_bug.cgi?id=24844) which seems to be that clang prior to 3.9 doesn't work with libstdc++ from gcc version 5 or later? Fix seems to have been backported to 3.8 in debian, https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=797038 if I'm following correctly.

  15. MarcoFalke commented at 10:59 AM on June 22, 2020: member

    Thanks. I'll deal with the clang-3.7 linker bug in a different pull. Let's focus here on fixing the compile failure with clang-3.8

  16. MarcoFalke requested review from promag on Jun 25, 2020
  17. MarcoFalke commented at 6:54 PM on June 26, 2020: member

    Anything left to do here?

  18. in src/script/standard.cpp:281 in fa3b35a189
     280 |  } // namespace
     281 |  
     282 |  CScript GetScriptForDestination(const CTxDestination& dest)
     283 |  {
     284 | -    return boost::apply_visitor(::g_script_visitor, dest);
     285 | +    return boost::apply_visitor(CScriptVisitor{}, dest);
    


    laanwj commented at 2:39 PM on June 29, 2020:

    I think this is an improvement in any case. No value in using a global here, the only case where a setup like this would make sense is when there is an expensive pre-computation.


    MarcoFalke commented at 2:44 PM on June 29, 2020:

    This is also restoring the way it has always been before commit 5f72ddb

  19. laanwj commented at 2:50 PM on June 29, 2020: member

    ACK fa3b35a189c4a4fd9667ef0af1c7059471ac8b01

  20. laanwj merged this on Jun 29, 2020
  21. laanwj closed this on Jun 29, 2020

  22. MarcoFalke deleted the branch on Jun 29, 2020
  23. kittywhiskers referenced this in commit 2c5504fc24 on Jul 15, 2021
  24. kittywhiskers referenced this in commit a73f8866b9 on Jul 17, 2021
  25. Fabcien referenced this in commit 62401bcf2f on Aug 30, 2021
  26. kittywhiskers referenced this in commit eaeaa30ba5 on Sep 11, 2021
  27. kittywhiskers referenced this in commit 267490ae8a on Sep 15, 2021
  28. thelazier referenced this in commit d6148b40ef on Sep 19, 2021
  29. thelazier referenced this in commit 4a5c9c0c63 on Sep 25, 2021
  30. DrahtBot locked this on Feb 15, 2022


promag


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me